[Orxonox-commit 1988] r6705 - in code/branches/ppspickups1/src: modules/pickup modules/pickup/items orxonox/items orxonox/worldentities/pawns
dafrick at orxonox.net
dafrick at orxonox.net
Tue Apr 13 00:09:11 CEST 2010
Author: dafrick
Date: 2010-04-13 00:09:10 +0200 (Tue, 13 Apr 2010)
New Revision: 6705
Modified:
code/branches/ppspickups1/src/modules/pickup/Pickup.cc
code/branches/ppspickups1/src/modules/pickup/Pickup.h
code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h
code/branches/ppspickups1/src/orxonox/items/Engine.h
code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc
Log:
Minor cleanup.
Modified: code/branches/ppspickups1/src/modules/pickup/Pickup.cc
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/Pickup.cc 2010-04-12 21:23:45 UTC (rev 6704)
+++ code/branches/ppspickups1/src/modules/pickup/Pickup.cc 2010-04-12 22:09:10 UTC (rev 6705)
@@ -36,8 +36,8 @@
#include "core/CoreIncludes.h"
#include "util/StringUtils.h"
#include "pickup/PickupIdentifier.h"
-#include "DroppedPickup.h"
-
+#include "DroppedPickup.h"
+
#include "tools/Timer.h"
namespace orxonox
@@ -231,25 +231,31 @@
{
new DroppedPickup(this, this, this->getCarrier());
return true;
- }
+ }
- /**
- @brief
- Starts the Pickup duration Timer.
- */
- bool Pickup::startPickupTimer(float durationTime)
- {
- if (durationTime<=0)
- {
- COUT(1) << "Invalid durationTime in pickup." << std::endl;
- return false;
- }
- if (false) /* TODO: 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;
+ /**
+ @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/branches/ppspickups1/src/modules/pickup/Pickup.h
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/Pickup.h 2010-04-12 21:23:45 UTC (rev 6704)
+++ code/branches/ppspickups1/src/modules/pickup/Pickup.h 2010-04-12 22:09:10 UTC (rev 6705)
@@ -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.
@@ -156,6 +156,9 @@
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.
@@ -164,9 +167,6 @@
static const std::string activationTypeOnUse_s;
static const std::string durationTypeOnce_s;
static const std::string durationTypeContinuous_s;
-
- float durationTime_;
- Timer durationTimer_;
};
}
Modified: code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h
===================================================================
--- code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h 2010-04-12 21:23:45 UTC (rev 6704)
+++ code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h 2010-04-12 22:09:10 UTC (rev 6705)
@@ -93,4 +93,4 @@
};
}
-#endif // _HealthPickup_H__
+#endif // _SpeedPickup_H__
Modified: code/branches/ppspickups1/src/orxonox/items/Engine.h
===================================================================
--- code/branches/ppspickups1/src/orxonox/items/Engine.h 2010-04-12 21:23:45 UTC (rev 6704)
+++ code/branches/ppspickups1/src/orxonox/items/Engine.h 2010-04-12 22:09:10 UTC (rev 6705)
@@ -114,7 +114,7 @@
virtual const Vector3& getCarrierPosition(void);
- /* Should not be here */
+ //TODO: Move to protected or private. How?
inline void setSpeedAdd(float speedAdd)
{ this->speedAdd_=speedAdd; }
inline void setSpeedMultiply(float speedMultiply)
Modified: code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc 2010-04-12 21:23:45 UTC (rev 6704)
+++ code/branches/ppspickups1/src/orxonox/worldentities/pawns/SpaceShip.cc 2010-04-12 22:09:10 UTC (rev 6705)
@@ -223,7 +223,7 @@
std::list<PickupCarrier*>* SpaceShip::getCarrierChildren(void)
{
std::list<PickupCarrier*>* list = new std::list<PickupCarrier*>();
- list->push_front(engine_);
+ list->push_front(this->engine_);
return list;
}
}
More information about the Orxonox-commit
mailing list