[Orxonox-commit 2838] r7541 - code/trunk/src/modules/pickup/items
dafrick at orxonox.net
dafrick at orxonox.net
Thu Oct 14 12:56:00 CEST 2010
Author: dafrick
Date: 2010-10-14 12:55:59 +0200 (Thu, 14 Oct 2010)
New Revision: 7541
Modified:
code/trunk/src/modules/pickup/items/DronePickup.cc
code/trunk/src/modules/pickup/items/DronePickup.h
code/trunk/src/modules/pickup/items/HealthPickup.cc
code/trunk/src/modules/pickup/items/HealthPickup.h
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
code/trunk/src/modules/pickup/items/InvisiblePickup.h
Log:
Some more documentation.
Modified: code/trunk/src/modules/pickup/items/DronePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/DronePickup.cc 2010-10-14 09:20:16 UTC (rev 7540)
+++ code/trunk/src/modules/pickup/items/DronePickup.cc 2010-10-14 10:55:59 UTC (rev 7541)
@@ -32,18 +32,19 @@
*/
#include "DronePickup.h"
-#include "worldentities/Drone.h"
-#include "controllers/DroneController.h"
+#include <sstream>
+
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "util/StringUtils.h"
+#include "controllers/DroneController.h"
+#include "pickup/PickupIdentifier.h"
#include "worldentities/pawns/Pawn.h"
-#include "pickup/PickupIdentifier.h"
+#include "worldentities/Drone.h"
+#include "worldentities/StaticEntity.h"
-#include <sstream>
-
namespace orxonox
{
@@ -103,10 +104,22 @@
this->initializeIdentifier();
}
+ /**
+ @brief
+ Set the droneTemplate.
+ @param templatename
+ The name of the Template to e set.
+ */
void DronePickup::setDroneTemplate(std::string templatename){
droneTemplate_ = templatename;
}
+ /**
+ @brief
+ Get the name of the droneTemplate.
+ @return
+ Returns the name of the droneTemplate.
+ */
const std::string& DronePickup::getDroneTemplate() const
{
return droneTemplate_;
@@ -120,16 +133,16 @@
{
SUPER(DronePickup, changedUsed);
- //! If the pickup is not picked up nothing must be done.
+ // If the pickup is not picked up nothing must be done.
if(!this->isPickedUp())
return;
- //! If the pickup has transited to used.
+ // If the pickup has transited to used.
if(this->isUsed())
{
Pawn* pawn = this->carrierToPawnHelper();
- if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
this->Pickupable::destroy();
//Attach to pawn
@@ -146,12 +159,12 @@
Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30);
drone->setPosition(spawnPosition);
- //! The pickup has been used up.
+ // The pickup has been used up.
this->setUsed(false);
}
else
{
- //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
+ // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
if(this->isOnce() || (this->isContinuous() ))
{
this->Pickupable::destroy();
Modified: code/trunk/src/modules/pickup/items/DronePickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/DronePickup.h 2010-10-14 09:20:16 UTC (rev 7540)
+++ code/trunk/src/modules/pickup/items/DronePickup.h 2010-10-14 10:55:59 UTC (rev 7541)
@@ -38,17 +38,26 @@
#include "pickup/PickupPrereqs.h"
#include <string>
-#include <worldentities/pawns/Pawn.h>
-#include <worldentities/Drone.h>
-#include "worldentities/StaticEntity.h"
-
#include "pickup/Pickup.h"
#include "tools/interfaces/Tickable.h"
namespace orxonox {
+ /**
+ @brief
+ The DronePickup adds a Drone to the Pawn upon being picked up.
+ It can be used in XML as follows:
+ @code
+ <DronePickup droneTemplate="myDroneTemplate" />
+ @endcode
+ Where <em>droneTemplate</em> specifies a @ref orxonox::Template "Template" based on which the Drone is created.
+ @author
+ Lukas Gassner
+
+ @ingroup PickupItems
+ */
class _PickupExport DronePickup : public Pickup, public Tickable
{
public:
@@ -61,15 +70,15 @@
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.
- void setDroneTemplate(std::string templatename);
- const std::string& getDroneTemplate() const;
+ void setDroneTemplate(std::string templatename); //!< Set the droneTemplate.
+ const std::string& getDroneTemplate() const; //!< Get the name of the droneTemplate.
protected:
void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
private:
void initialize(void); //!< Initializes the member variables.
- std::string droneTemplate_;
+ std::string droneTemplate_; //!< The name of the template, based upon which the Drone is created.
Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
Modified: code/trunk/src/modules/pickup/items/HealthPickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.cc 2010-10-14 09:20:16 UTC (rev 7540)
+++ code/trunk/src/modules/pickup/items/HealthPickup.cc 2010-10-14 10:55:59 UTC (rev 7541)
@@ -141,14 +141,14 @@
if(this->isContinuous() && this->isUsed())
{
Pawn* pawn = this->carrierToPawnHelper();
- if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
this->Pickupable::destroy();
- //! Calculate the health that is added this tick.
+ // Calculate the health that is added this tick.
float health = dt*this->getHealthRate();
if(health > this->getHealth())
health = this->getHealth();
- //! Calculate the health the Pawn will have once the health is added.
+ // Calculate the health the Pawn will have once the health is added.
float fullHealth = pawn->getHealth() + health;
this->setHealth(this->getHealth()-health);
@@ -173,7 +173,7 @@
COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
}
- //! If all health has been transfered.
+ // If all health has been transferred.
if(this->getHealth() == 0)
{
this->setUsed(false);
@@ -189,17 +189,17 @@
{
SUPER(HealthPickup, changedUsed);
- //! If the pickup is not picked up nothing must be done.
+ // If the pickup is not picked up nothing must be done.
if(!this->isPickedUp()) //TODO: Needed?
return;
- //! If the pickup has transited to used.
+ // If the pickup has transited to used.
if(this->isUsed())
{
if(this->isOnce())
{
Pawn* pawn = this->carrierToPawnHelper();
- if(pawn == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
+ if(pawn == NULL) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
this->Pickupable::destroy();
float health = 0;
@@ -226,7 +226,7 @@
COUT(1) << "Invalid healthType in HealthPickup." << std::endl;
}
- //! The pickup has been used up.
+ // The pickup has been used up.
this->setUsed(false);
}
}
@@ -252,7 +252,7 @@
}
}
- //! If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
+ // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.
if(this->isOnce() || (this->isContinuous() && this->getHealth() == 0))
{
this->Pickupable::destroy();
Modified: code/trunk/src/modules/pickup/items/HealthPickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/HealthPickup.h 2010-10-14 09:20:16 UTC (rev 7540)
+++ code/trunk/src/modules/pickup/items/HealthPickup.h 2010-10-14 10:55:59 UTC (rev 7541)
@@ -46,27 +46,45 @@
namespace orxonox {
- //! Enum for the type of the HealthPickup
+ /**
+ @brief
+ Enum for the type of the @ref orxonox::HealthPickup "HealthPickup".
+
+ @ingroup PickupItems
+ */
namespace pickupHealthType
{
enum Value
{
- limited,
- temporary,
- permanent
+ limited, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" only increases the users health to its maximum health.
+ temporary, //!< Means that the @ref orxonox::HealthPickup "HealthPickup" temporarily increases the users health even above its maximum health, but only as long as it is in use.
+ permanent //!< Means that the @ref orxonox::HealthPickup "HealthPickup" increases the users health even above its maximum health and increases the maximum health permanently such that it matches the new health.
};
}
/**
@brief
- A pickup that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
+ The Health Pickup is a Pickupable that can do (dependent upon the parameters) lots of different things to the health of a Pawn.
There are 4 parameters that can be chosen:
- - The @b health The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn.
- - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it.
- - The @b duration @b type It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter.
- - The @b health @b type The health type can be chosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
+ - The <b>health</b> The amount of health that (in a way dependent on the other parameters) is transferred to the Pawn.
+ - The <b>activation type</b> It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the health is transferred, either immediately after being picked up or only after the player uses it.
+ - The <b>duration type</b> It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the specified health is transferred once to the Pawn, for <em>continuous</em> the set health is transferred over a span of time at a rate defined by the health rate parameter.
+ - The <b>health type</b> The health type can be chosen to be <em>limited</em>, <em>temporary</em> or <em>permanent</em>. <em>limited</em> means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. <em>permanent</em> means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way.
+
+ An examle of a XML implementation of a HealthPickup would be:
+ @code
+ <HealthPickup
+ health = 33
+ healthType = "limited"
+ activationType = "immediate"
+ durationType = "once"
+ />
+ @endcode
+
@author
Damian 'Mozork' Frick
+
+ @ingroup PickupItems
*/
class _PickupExport HealthPickup : public Pickup, public Tickable
{
@@ -82,7 +100,7 @@
virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
/**
- @brief Get the health that is transfered to the Pawn upon usage of this pickup.
+ @brief Get the health that is transferred to the Pawn upon usage of this pickup.
@return Returns the health.
*/
inline float getHealth(void)
Modified: code/trunk/src/modules/pickup/items/InvisiblePickup.cc
===================================================================
--- code/trunk/src/modules/pickup/items/InvisiblePickup.cc 2010-10-14 09:20:16 UTC (rev 7540)
+++ code/trunk/src/modules/pickup/items/InvisiblePickup.cc 2010-10-14 10:55:59 UTC (rev 7541)
@@ -56,7 +56,6 @@
InvisiblePickup::InvisiblePickup(BaseObject* creator) : Pickup(creator)
{
RegisterObject(InvisiblePickup);
- //! Defines who is allowed to pick up the pickup.
this->initialize();
}
@@ -85,6 +84,7 @@
void InvisiblePickup::initialize(void)
{
this->duration_ = 0.0f;
+ // Defines who is allowed to pick up the pickup.
this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
}
@@ -98,6 +98,7 @@
XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
this->initializeIdentifier();
+ this->setDurationType(Pickup::durationTypeOnce_s); // The duration type is always once.
}
/**
@@ -108,20 +109,23 @@
{
SUPER(InvisiblePickup, changedUsed);
- //! If the pickup is not picked up nothing must be done.
+ // If the pickup is not picked up nothing must be done.
if(!this->isPickedUp())
return;
if (this->isUsed())
{
- if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
+ if(this->isContinuous()
{
- this->durationTimer_.unpauseTimer();
+ if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
+ {
+ this->durationTimer_.unpauseTimer();
+ }
+ else
+ {
+ this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this)));
+ }
}
- else
- {
- this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this)));
- }
this->setInvisible(true);
Modified: code/trunk/src/modules/pickup/items/InvisiblePickup.h
===================================================================
--- code/trunk/src/modules/pickup/items/InvisiblePickup.h 2010-10-14 09:20:16 UTC (rev 7540)
+++ code/trunk/src/modules/pickup/items/InvisiblePickup.h 2010-10-14 10:55:59 UTC (rev 7541)
@@ -49,10 +49,14 @@
@brief
A pickup that makes the Pawn invisible.
There are 2 parameters that can be chosen:
- - The @b activation @b type It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
- - The @b duration @b type It can be chosen how long the Pawn will be invisibel.
+ - The <b>activation type</b> It can be chosen to be either <em>immediate</em> or <em>onUse</em>. The activation type essentially (as indicated by the name) defines when the Pawn will be invisible, either immediately after being picked up or only after the player uses it.
+ - The <b>duration type</b> It can be chosen to be either <em>once</em> or <em>continuous</em>. For <em>once</em> the InvisiblePickup just makes the Pawn invisible for as long as it is used, for <em>continuous</em> the Pawn is invisible for the specified duration.
+ - The <b>duration</b> Specifies how long (in seconds) the invisibility lasts.
+
@author
Benedict Simlinger
+
+ @ingroup PickupItems
*/
class _PickupExport InvisiblePickup : public Pickup
{
More information about the Orxonox-commit
mailing list