[Orxonox-commit 1991] r6708 - in code/branches/ppspickups2/src/modules/pickup: . items
dafrick at orxonox.net
dafrick at orxonox.net
Tue Apr 13 09:07:08 CEST 2010
Author: dafrick
Date: 2010-04-13 09:07:08 +0200 (Tue, 13 Apr 2010)
New Revision: 6708
Modified:
code/branches/ppspickups2/src/modules/pickup/Pickup.cc
code/branches/ppspickups2/src/modules/pickup/Pickup.h
code/branches/ppspickups2/src/modules/pickup/PickupPrereqs.h
code/branches/ppspickups2/src/modules/pickup/PickupSpawner.cc
code/branches/ppspickups2/src/modules/pickup/items/CMakeLists.txt
code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.cc
code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.h
Log:
Some cleanup.
Modified: code/branches/ppspickups2/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/Pickup.cc 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/Pickup.cc 2010-04-13 07:07:08 UTC (rev 6708)
@@ -249,7 +249,7 @@
COUT(1) << "Pickup durationTimer already in use." << std::endl;
return false;
}
- this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::PickupTimerCallBack, this)));
+ this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::pickupTimerCallback, this)));
return true;
}
}
Modified: code/branches/ppspickups2/src/modules/pickup/Pickup.h
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/Pickup.h 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/Pickup.h 2010-04-13 07:07:08 UTC (rev 6708)
@@ -37,12 +37,12 @@
#include "pickup/PickupPrereqs.h"
#include "core/BaseObject.h"
-#include "core/XMLPort.h"
+#include "core/XMLPort.h"
#include "interfaces/Pickupable.h"
-
-#include "tools/Timer.h"
+#include "tools/Timer.h"
+
namespace orxonox
{
@@ -133,11 +133,11 @@
void initializeIdentifier(void);
virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
-
- bool startPickupTimer(float durationTime);
-
- virtual void PickupTimerCallBack(void) {}
+ bool startPickupTimer(float durationTime);
+
+ virtual void pickupTimerCallback(void) {}
+
/**
@brief Set the activation type of the pickup.
@param type The activation type of the pickup.
@@ -164,8 +164,8 @@
static const std::string activationTypeOnUse_s;
static const std::string durationTypeOnce_s;
static const std::string durationTypeContinuous_s;
-
- float durationTime_;
+
+ float durationTime_;
Timer durationTimer_;
};
Modified: code/branches/ppspickups2/src/modules/pickup/PickupPrereqs.h
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/PickupPrereqs.h 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/PickupPrereqs.h 2010-04-13 07:07:08 UTC (rev 6708)
@@ -75,6 +75,7 @@
//items
class HealthPickup;
+ class InvisiblePickup;
class MetaPickup;
}
Modified: code/branches/ppspickups2/src/modules/pickup/PickupSpawner.cc
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/PickupSpawner.cc 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/PickupSpawner.cc 2010-04-13 07:07:08 UTC (rev 6708)
@@ -102,7 +102,7 @@
*/
void PickupSpawner::initialize(void)
{
- this->triggerDistance_ = 20;
+ this->triggerDistance_ = 10;
this->respawnTime_ = 0;
this->maxSpawnedItems_ = INF;
this->spawnsRemaining_ = INF;
Modified: code/branches/ppspickups2/src/modules/pickup/items/CMakeLists.txt
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/items/CMakeLists.txt 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/items/CMakeLists.txt 2010-04-13 07:07:08 UTC (rev 6708)
@@ -1,5 +1,5 @@
ADD_SOURCE_FILES(PICKUP_SRC_FILES
HealthPickup.cc
+ InvisiblePickup.cc
MetaPickup.cc
- InvisiblePickup.cc
)
Modified: code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.cc
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.cc 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.cc 2010-04-13 07:07:08 UTC (rev 6708)
@@ -54,8 +54,8 @@
InvisiblePickup::InvisiblePickup(BaseObject* creator) : Pickup(creator)
{
RegisterObject(InvisiblePickup);
- //! Defines who is allowed to pick up the pickup.
- this->initialize();
+ //! Defines who is allowed to pick up the pickup.
+ this->initialize();
}
/**
@@ -69,11 +69,11 @@
void InvisiblePickup::initializeIdentifier(void)
{
- std::stringstream stream;
- stream << this->getDuration();
- std::string type1 = "duration";
- std::string val1 = stream.str();
- this->pickupIdentifier_->addParameter(type1, val1);
+ std::stringstream stream;
+ stream << this->getDuration();
+ std::string type1 = "duration";
+ std::string val1 = stream.str();
+ this->pickupIdentifier_->addParameter(type1, val1);
}
/**
@@ -82,8 +82,8 @@
*/
void InvisiblePickup::initialize(void)
{
- this->duration_ = 0.0;
- this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
+ this->duration_ = 0.0f;
+ this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
}
/**
@@ -93,9 +93,9 @@
void InvisiblePickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode)
{
SUPER(InvisiblePickup, XMLPort, xmlelement, mode);
- XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
-
- this->initializeIdentifier();
+ XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
+
+ this->initializeIdentifier();
}
/**
@@ -105,19 +105,22 @@
void InvisiblePickup::changedUsed(void)
{
SUPER(InvisiblePickup, changedUsed);
-
//! If the pickup is not picked up nothing must be done.
if(!this->isPickedUp())
return;
- if (this->isUsed())
- {
- this->startPickupTimer(this->getDuration());
- this->setInvisible(true);
- }
- else
- this->setInvisible(false);
-
+
+ if (this->isUsed())
+ {
+ this->startPickupTimer(this->getDuration());
+ this->setInvisible(true);
+ }
+ else
+ {
+ this->setInvisible(false);
+ this->destroy();
+ }
+
}
/**
@@ -150,48 +153,50 @@
item = new InvisiblePickup(this);
SUPER(InvisiblePickup, clone, item);
-
- InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
- pickup->setDuration(this->getDuration());
- pickup->initializeIdentifier();
+
+ InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
+ pickup->setDuration(this->getDuration());
+ pickup->initializeIdentifier();
}
/**
@brief
Sets the invisibility.
- @param health
+ @param invisibility
The invisibility.
*/
bool InvisiblePickup::setInvisible(bool invisibility)
{
-
- Pawn* pawn = this->carrierToPawnHelper();
- pawn->setVisible(!invisibility);
- return 0;
+ Pawn* pawn = this->carrierToPawnHelper();
+ if(pawn == NULL)
+ return false;
+
+ pawn->setVisible(!invisibility);
+ return true;
}
/**
@brief
- Sets the duration.
+ Sets the duration.
@param duration
- The duration
+ The duration
*/
void InvisiblePickup::setDuration(float duration)
{
- if(duration >= 0.0f)
- {
- this->duration_ = duration;
- }
- else
- {
- COUT(1) << "Invalid duration in InvisiblePickup." << std::endl;
- this->duration_ = 0;
- }
+ if(duration >= 0.0f)
+ {
+ this->duration_ = duration;
+ }
+ else
+ {
+ COUT(1) << "Invalid duration in InvisiblePickup." << std::endl;
+ this->duration_ = 0.0f;
+ }
}
- void InvisiblePickup::PickupTimerCallBack(void)
+ void InvisiblePickup::pickupTimerCallback(void)
{
- this->setInvisible(false);
+ this->setUsed(false);
}
}
Modified: code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.h
===================================================================
--- code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.h 2010-04-13 06:46:20 UTC (rev 6707)
+++ code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.h 2010-04-13 07:07:08 UTC (rev 6708)
@@ -63,26 +63,26 @@
virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around.
virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
- /**
- @brief Checks wether the Pawn is invisible.
+ /**
+ @brief Checks whether the Pawn is invisible.
@return Returns if the Pawn is invisible.
*/
inline bool getInvisibility(bool)
{ return this->invisible_; }
- inline float getDuration()
- {return this->duration_;}
+ inline float getDuration()
+ { return this->duration_; }
protected:
- bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
- void setDuration(float duration);
- void initializeIdentifier(void);
+ bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
+ void setDuration(float duration);
+ void initializeIdentifier(void);
+ virtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends.
private:
- void initialize(void); //!< Initializes the member variables.
+ void initialize(void); //!< Initializes the member variables.
Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
- void PickupTimerCallBack(void); //!< Function that gets called when the timer ends.
- bool invisible_; //!< Helper to remember wether the Pawn is invisible.
- float duration_; //! Duration of invisibility.
+ bool invisible_; //!< Helper to remember wether the Pawn is invisible.
+ float duration_; //! Duration of invisibility.
};
}
More information about the Orxonox-commit
mailing list