[Orxonox-commit 2501] r7208 - in code/trunk/src/modules/pickup: . items
dafrick at orxonox.net
dafrick at orxonox.net
Tue Aug 24 09:49:54 CEST 2010
Author: dafrick
Date: 2010-08-24 09:49:54 +0200 (Tue, 24 Aug 2010)
New Revision: 7208
Modified:
code/trunk/src/modules/pickup/Pickup.cc
code/trunk/src/modules/pickup/Pickup.h
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
code/trunk/src/modules/pickup/items/InvisiblePickup.h
code/trunk/src/modules/pickup/items/ShieldPickup.cc
code/trunk/src/modules/pickup/items/ShieldPickup.h
code/trunk/src/modules/pickup/items/SpeedPickup.cc
code/trunk/src/modules/pickup/items/SpeedPickup.h
Log:
Removed Timer from Pickup, as this is no his core functionality.
Modified: code/trunk/src/modules/pickup/Pickup.cc
===================================================================
--- code/trunk/src/modules/pickup/Pickup.cc 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/Pickup.cc 2010-08-24 07:49:54 UTC (rev 7208)
@@ -235,29 +235,4 @@
return true;
}
- /**
- @brief
- Starts the pickup duration timer.
- After the specified durationTime has expired the function pickupTimerCallback is called.
- pickupTimerCallback can be overloaded and thus the desired functionality can be implemented.
- @param durationTime
- The duration after which the expires and the callback function is called.
- @return
- Returns true if the pickup duration timer was started successfully, false if not.
- */
- bool Pickup::startPickupTimer(float durationTime)
- {
- if (durationTime<=0)
- {
- COUT(1) << "Invalid durationTime in pickup." << std::endl;
- return false;
- }
- if (this->durationTimer_.isActive()) //!< Check if Timer is already running
- {
- COUT(1) << "Pickup durationTimer already in use." << std::endl;
- return false;
- }
- this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::pickupTimerCallback, this)));
- return true;
- }
}
Modified: code/trunk/src/modules/pickup/Pickup.h
===================================================================
--- code/trunk/src/modules/pickup/Pickup.h 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/Pickup.h 2010-08-24 07:49:54 UTC (rev 7208)
@@ -132,21 +132,7 @@
virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
- bool startPickupTimer(float durationTime); //!< Starts the pickup duration timer.
/**
- @brief Get your Timer.
- @return Returns a pointer to the Timer.
- */
- inline Timer* getTimer(void)
- { return &this->durationTimer_; }
-
- /**
- @brief The callback method for the Timer.
- Can be overloaded to implement desired functionality.
- */
- virtual void pickupTimerCallback(void) {}
-
- /**
@brief Set the activation type of the pickup.
@param type The activation type of the pickup.
*/
@@ -165,9 +151,6 @@
private:
void initialize(void); //!< Initializes the member variables.
- //TODO: Problems, when there are more Timers needed? Solutions?
- Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup.
-
pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
pickupDurationType::Value durationType_; //!< The duration type of the pickup.
Modified: code/trunk/src/modules/pickup/items/InvisiblePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/InvisiblePickup.cc 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/items/InvisiblePickup.cc 2010-08-24 07:49:54 UTC (rev 7208)
@@ -114,13 +114,13 @@
if (this->isUsed())
{
- if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
{
- this->getTimer()->unpauseTimer();
+ this->durationTimer_.unpauseTimer();
}
else
{
- this->startPickupTimer(this->getDuration());
+ this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this)));
}
this->setInvisible(true);
@@ -130,13 +130,13 @@
{
this->setInvisible(false);
- if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
{
this->Pickupable::destroy();
}
else
{
- this->getTimer()->pauseTimer();
+ this->durationTimer_.pauseTimer();
}
}
Modified: code/trunk/src/modules/pickup/items/InvisiblePickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/InvisiblePickup.h 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/items/InvisiblePickup.h 2010-08-24 07:49:54 UTC (rev 7208)
@@ -76,11 +76,14 @@
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.
+ void pickupTimerCallback(void); //!< Function that gets called when the timer ends.
private:
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.
+
+ Timer durationTimer_; //!< Timer.
+
bool invisible_; //!< Helper to remember wether the Pawn is invisible.
float duration_; //! Duration of invisibility.
};
Modified: code/trunk/src/modules/pickup/items/ShieldPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/ShieldPickup.cc 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/items/ShieldPickup.cc 2010-08-24 07:49:54 UTC (rev 7208)
@@ -159,13 +159,13 @@
//! If the pickup has transited to used.
if(this->isUsed())
{
- if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
{
- this->getTimer()->unpauseTimer();
+ this->durationTimer_.unpauseTimer();
}
else
{
- this->startPickupTimer(this->getDuration());
+ this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&ShieldPickup::pickupTimerCallback, this)));
}
pawn->setShieldAbsorption(this->getShieldAbsorption());
pawn->setShieldHealth(this->getShieldHealth());
@@ -178,13 +178,13 @@
if(this->isOnce())
{
- if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
{
this->Pickupable::destroy();
}
else
{
- this->getTimer()->pauseTimer();
+ this->durationTimer_.pauseTimer();
}
}
}
Modified: code/trunk/src/modules/pickup/items/ShieldPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/ShieldPickup.h 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/items/ShieldPickup.h 2010-08-24 07:49:54 UTC (rev 7208)
@@ -79,7 +79,7 @@
protected:
void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
- virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
+ void pickupTimerCallback(void); //!< Function that gets called when timer ends.
void setDuration(float duration);
void setShieldHealth(float shieldHealth);
@@ -89,6 +89,8 @@
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.
+ Timer durationTimer_; //!< Timer.
+
float duration_; //!< The health that is transferred to the Pawn.
float shieldHealth_;
float shieldAbsorption_; // Has to be between 0 and 1
Modified: code/trunk/src/modules/pickup/items/SpeedPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/SpeedPickup.cc 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/items/SpeedPickup.cc 2010-08-24 07:49:54 UTC (rev 7208)
@@ -140,13 +140,13 @@
//! If the pickup has transited to used.
if(this->isUsed())
{
- if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
{
- this->getTimer()->unpauseTimer();
+ this->durationTimer_.unpauseTimer();
}
else
{
- this->startPickupTimer(this->getDuration());
+ this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this)));
}
engine->setSpeedAdd(this->getSpeedAdd());
engine->setSpeedMultiply(this->getSpeedMultiply());
@@ -158,13 +158,13 @@
if(this->isOnce())
{
- if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
{
this->Pickupable::destroy();
}
else
{
- this->getTimer()->pauseTimer();
+ this->durationTimer_.pauseTimer();
}
}
}
Modified: code/trunk/src/modules/pickup/items/SpeedPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/SpeedPickup.h 2010-08-23 16:50:22 UTC (rev 7207)
+++ code/trunk/src/modules/pickup/items/SpeedPickup.h 2010-08-24 07:49:54 UTC (rev 7208)
@@ -78,7 +78,7 @@
protected:
void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
- virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
+ void pickupTimerCallback(void); //!< Function that gets called when timer ends.
void setDuration(float duration);
void setSpeedAdd(float speedAdd);
@@ -88,6 +88,8 @@
void initialize(void); //!< Initializes the member variables.
Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
+ Timer durationTimer_; //!< Timer.
+
float duration_; //!< The health that is transferred to the Pawn.
float speedAdd_;
float speedMultiply_;
More information about the Orxonox-commit
mailing list