[Orxonox-commit 1229] r5947 - in code/branches/pickup2/src/orxonox/pickup: . items
rgrieder at orxonox.net
rgrieder at orxonox.net
Wed Oct 14 13:44:19 CEST 2009
Author: rgrieder
Date: 2009-10-14 13:44:19 +0200 (Wed, 14 Oct 2009)
New Revision: 5947
Modified:
code/branches/pickup2/src/orxonox/pickup/BaseItem.cc
code/branches/pickup2/src/orxonox/pickup/BaseItem.h
code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
code/branches/pickup2/src/orxonox/pickup/DroppedItem.h
code/branches/pickup2/src/orxonox/pickup/EquipmentItem.cc
code/branches/pickup2/src/orxonox/pickup/EquipmentItem.h
code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc
code/branches/pickup2/src/orxonox/pickup/ModifierPickup.h
code/branches/pickup2/src/orxonox/pickup/ModifierType.h
code/branches/pickup2/src/orxonox/pickup/PassiveItem.cc
code/branches/pickup2/src/orxonox/pickup/PassiveItem.h
code/branches/pickup2/src/orxonox/pickup/PickupCollection.h
code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc
code/branches/pickup2/src/orxonox/pickup/PickupInventory.h
code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc
code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h
code/branches/pickup2/src/orxonox/pickup/UsableItem.cc
code/branches/pickup2/src/orxonox/pickup/UsableItem.h
code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.cc
code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.h
code/branches/pickup2/src/orxonox/pickup/items/HealthUsable.cc
code/branches/pickup2/src/orxonox/pickup/items/Jump.h
Log:
Merged pickup branch revisions to pickup2.
Modified: code/branches/pickup2/src/orxonox/pickup/BaseItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/BaseItem.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/BaseItem.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -40,8 +40,8 @@
namespace orxonox
{
/**
- @brief Constructor. Registers the BaseItem.
- @param creator Pointer to the object which created this item.
+ @brief Constructor. Registers the BaseItem.
+ @param creator Pointer to the object which created this item.
*/
BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator)
{
@@ -58,9 +58,9 @@
}
/**
- @brief XMLPort for BaseItem.
- @param xmlelement Element of the XML-file.
- @param mode XMLPort mode to use.
+ @brief XMLPort for BaseItem.
+ @param xmlelement Element of the XML-file.
+ @param mode XMLPort mode to use.
*/
void BaseItem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
@@ -71,15 +71,15 @@
}
/**
- @brief Method to add the item to a pawn.
- @param pawn Pawn to which the item should get added.
- @return Returns whether the pawn's PickupCollection accepted the item.
+ @brief Method to add the item to a pawn.
+ @param pawn Pawn to which the item should get added.
+ @return Returns whether the pawn's PickupCollection accepted the item.
*/
bool BaseItem::addTo(Pawn* pawn)
{
this->setOwner(pawn);
- if (pawn->getPickups().add(this))
+ if (pawn->getPickups().add(this)) //TODO: Does the pawn store his pickups?
{
COUT(3) << "Added '" << this->getPickupIdentifier() << "' item." << std::endl;
return true;
Modified: code/branches/pickup2/src/orxonox/pickup/BaseItem.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/BaseItem.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/BaseItem.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -43,32 +43,33 @@
namespace orxonox
{
/**
- @brief
- Base class for all items/pickups.
+ @brief
+ Base class for all items/pickups.
- Provides common methods to be used in derived classes.
- @author
- Daniel 'Huty' Haggenmueller
+ Provides common methods to be used in derived classes.
+ @author
+ Daniel 'Huty' Haggenmueller
*/
class _OrxonoxExport BaseItem : public BaseObject
{
// tolua_end
- public:
- BaseItem(BaseObject* creator);
- virtual ~BaseItem();
+ public:
+ BaseItem(BaseObject* creator);
+ virtual ~BaseItem();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
- /**
+ /**
@brief Checks how many instances of this item can be carried at a time.
@return How many of this item can be carried.
- */
- virtual int getMaxCarryAmount() const
- { return 1; }
+ */
+ virtual int getMaxCarryAmount() const //TODO: Maybe, better to just be virtual.
+ { return BaseItem::MAX_CARRY_AMOUNT; }
- bool addTo(Pawn* pawn); //!< Add the item to a pawn.
- bool removeFrom(Pawn* pawn); //!< Removes the item from a pawn.
- /**
+ //TODO: Need to be public?
+ bool addTo(Pawn* pawn); //!< Add the item to a pawn.
+ bool removeFrom(Pawn* pawn); //!< Removes the item from a pawn.
+ /**
@brief
Method invoked when the item gets picked up.
@@ -77,10 +78,10 @@
@param pawn Pawn who picks up the item.
@return Returns whether the pawn was able to pick up the item.
- */
- virtual bool pickedUp(Pawn* pawn)
- { return false; }
- /**
+ */
+ virtual bool pickedUp(Pawn* pawn) //TODO: Maybe better to be just virtual.
+ { return false; }
+ /**
@brief
Method invoked when the item is dropped from a player.
@@ -89,61 +90,66 @@
@param pawn Pawn which dropped the item.
@return Returns whether the item was able to get dropped by the pawn.
- */
- virtual bool dropped(Pawn* pawn)
- { return false; }
+ */
+ virtual bool dropped(Pawn* pawn)
+ { return false; }
- /**
+ /**
@brief Gets the current owner of the pickup.
@return Returns the current owner.
- */
- inline Pawn* getOwner() const
- { return this->owner_; }
- /**
+ */
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+ /**
@brief Sets the owner of the pickup.
@param owner New owner for the pickup.
- */
- inline void setOwner(Pawn* owner)
- { this->owner_ = owner; }
+ */
+ inline void setOwner(Pawn* owner)
+ { this->owner_ = owner; }
- /**
+ /**
@brief Gets the pickupIdentifier of the item.
@return Returns the pickupIdentifier of the item.
@see pickupIdentifier_
- */
- inline const std::string& getPickupIdentifier() const
- { return this->pickupIdentifier_; }
- /**
+ */
+ inline const std::string& getPickupIdentifier() const
+ { return this->pickupIdentifier_; }
+ /**
@brief Sets the pickupIdentifier for the item.
@param identifier New pickupIdentifier for the item.
@see pickupIdentifier_
- */
- inline void setPickupIdentifier(const std::string& identifier)
- { this->pickupIdentifier_ = identifier; }
+ */
+ //TODO: Needs to be public?
+ inline void setPickupIdentifier(const std::string& identifier)
+ { this->pickupIdentifier_ = identifier; }
- // GUI stuff
- virtual const std::string& getGUIText() const; // tolua_export
- inline void setGUIText(const std::string& text)
- { this->guiText_ = text; }
+ // GUI stuff
+ //TODO: Comment. Maybe seperate GUI from Pickup, e.g. ItemDescription...
+ virtual const std::string& getGUIText() const; // tolua_export
+ inline void setGUIText(const std::string& text)
+ { this->guiText_ = text; }
- virtual const std::string& getGUIImage() const
- { return this->guiImage_; }
- inline void setGUIImage(const std::string& image)
- { this->guiImage_ = image; }
- private:
- Pawn* owner_; //!< The current owner of the item.
+ virtual const std::string& getGUIImage() const
+ { return this->guiImage_; }
+ inline void setGUIImage(const std::string& image)
+ { this->guiImage_ = image; }
+ private:
+ static const int MAX_CARRY_AMOUNT = 1;
- /**
+ Pawn* owner_; //!< The current owner of the item.
+
+ /**
@brief
The pickupIdentifier of the item..
Usually set to the template name used by a PickupSpawner,
used to index items in the PickupCollection.
- */
- std::string pickupIdentifier_;
+ */
+ std::string pickupIdentifier_; //TODO: Remove, when always just this->getName().
- std::string guiText_;
- std::string guiImage_;
+ //TODO: Comment.
+ std::string guiText_;
+ std::string guiImage_;
}; // tolua_export
} // tolua_export
Modified: code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/DroppedItem.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -40,22 +40,41 @@
{
CreateFactory(DroppedItem);
+ /**
+ @brief
+ Constructor. Registers object and sets default values.
+ */
DroppedItem::DroppedItem(BaseObject* creator) : StaticEntity(creator)
{
RegisterObject(DroppedItem);
this->triggerDistance_ = 20.0f;
this->timeToLive_ = 0;
- this->item_ = 0;
+ this->item_ = NULL;
}
+
+ /**
+ @brief
+ Default destructor.
+ */
+ //TODO: Destroy something?
DroppedItem::~DroppedItem()
{
+
}
+
+ /**
+ @brief
+ Checks whether any pawn is in triggerDistance of the Item and calls this->trigger if so.
+ @param dt
+ The duration of the last time interval.
+ */
+ //TODO: Replace this with a DistanceTrigger!
void DroppedItem::tick(float dt)
{
if (this->item_)
{
- for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it)
+ for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); ++it) //!< Iterate through all Pawns.
{
Vector3 distance = it->getWorldPosition() - this->getWorldPosition();
if (distance.length() < this->triggerDistance_)
@@ -63,14 +82,25 @@
}
}
}
+
+ /**
+ @brief
+ Called when the DroppedItem is triggered. Adds the item to the triggering pawn.
+ */
void DroppedItem::trigger(Pawn* pawn)
{
- if (this->item_->pickedUp(pawn))
+ if (this->item_->pickedUp(pawn)) //If pickup was successful.
{
COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl;
this->destroy();
}
}
+
+ /**
+ @brief
+ Creates a timer to call this->timerCallback() at expiration of timeToLive.
+ */
+ //TODO: Better Comments.
void DroppedItem::createTimer()
{
if (this->timeToLive_ > 0)
@@ -78,6 +108,14 @@
this->timer_.setTimer(this->timeToLive_, false, createExecutor(createFunctor(&DroppedItem::timerCallback, this)), false);
}
}
+
+ /**
+ @brief
+ Destroys the item. Called by the set timer upon its expiration.
+ */
+ //TODO: Choose better function name if this doesn't create dependency inconsistencies. e.g. this->destroy() or this->timeOut()
+ //Make certain that only one pawn has the same item, because if not, deliting the item would lead to a possible segfault.
+ //If the item is destroyed here, shouldn't it be destroyed in the destructor as well?
void DroppedItem::timerCallback()
{
if (this->item_)
@@ -89,7 +127,18 @@
this->destroy();
}
- DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
+ /**
+ @brief
+
+ */
+ //TODO: Comment.
+ //This is for pawns dropping items they have...
+ //Probably better to create a spawner with only 1 item in it.
+ //Various different thigs are done here, which in my opinion should eighter be done in XML or some where else, preferably in XML.
+ //Each pickup should have a XML template where the Model and Billboard, and so on, is specified.
+ //The position, item and timetoLive should be specified by this Classes XMLPort function.
+ //These adjustments above, will very likely create inkonsistencies in the level files, possibly templates.
+ /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive)
{
DroppedItem* drop = new DroppedItem(item);
Model* model = new Model(item);
@@ -115,6 +164,12 @@
return drop;
}
+
+ /**
+ @brief
+
+ */
+ //TODO: See one function above.
DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive)
{
Vector3 after = pawn->getPosition() + pawn->getOrientation() * Vector3(0.0f, 0.0f, 50.0f);
Modified: code/branches/pickup2/src/orxonox/pickup/DroppedItem.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/DroppedItem.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/DroppedItem.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -48,14 +48,21 @@
DroppedItem(BaseObject* creator);
virtual ~DroppedItem();
+ //TODO: Comment.
+ //DroppedItem -> Item with no owner, alone in space?
+ //Would be much nicer if it would be triggered by a standard issue DistanceTrigger.
+ //Where is this created? I see no XMLPort.
+ //Where is the item for this created? What happens if more than one pawn triggers this?
+ //Add more than just one items, or even better create the ability to add a Collection.? Rename to ...?
+
void tick(float dt);
void trigger(Pawn* pawn);
static DroppedItem* createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
static DroppedItem* createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0);
- void createTimer();
- void timerCallback();
+ void createTimer(); //TODO: Can this be made private, too?
+ void timerCallback(); //TODO: This should really be private.
inline float getTriggerDistance() const
{ return this->triggerDistance_; }
@@ -64,11 +71,13 @@
inline BaseItem* getItem() const
{ return this->item_; }
+ //TODO: Needs to be public?
inline void setItem(BaseItem* item)
{ this->item_ = item; }
inline float getTimeToLive() const
{ return this->timeToLive_; }
+ //TODO: Needs to be public?
inline void setTimeToLive(float time)
{ this->timeToLive_ = time; }
private:
Modified: code/branches/pickup2/src/orxonox/pickup/EquipmentItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/EquipmentItem.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/EquipmentItem.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -37,8 +37,8 @@
namespace orxonox
{
/**
- @brief Constructor. Registers the EquipmentItem.
- @param creator Pointer to the object which created this item.
+ @brief Constructor. Registers the EquipmentItem.
+ @param creator Pointer to the object which created this item.
*/
EquipmentItem::EquipmentItem(BaseObject* creator) : BaseItem(creator)
{
Modified: code/branches/pickup2/src/orxonox/pickup/EquipmentItem.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/EquipmentItem.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/EquipmentItem.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -40,14 +40,19 @@
namespace orxonox
{
/**
- @brief Base class for all equipment-type items.
- @author Daniel 'Huty' Haggenmueller
+ @brief Base class for all equipment-type items.
+ @author Daniel 'Huty' Haggenmueller
*/
class _OrxonoxExport EquipmentItem : public BaseItem
{
- public:
- EquipmentItem(BaseObject* creator);
- virtual ~EquipmentItem() {}
+ //TODO: What is this class for?
+ //Probably falls under UsableItem or PassiveItem
+ public:
+ EquipmentItem(BaseObject* creator);
+ virtual ~EquipmentItem() {}
+
+
+
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/ModifierPickup.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -42,8 +42,10 @@
CreateFactory(ModifierPickup);
/**
- @brief Constructor. Registers the ModifierPickup.
- @param creator Pointer to the object which created this item.
+ @brief
+ Constructor. Registers the ModifierPickup.
+ @param creator
+ Pointer to the object which created this item.
*/
ModifierPickup::ModifierPickup(BaseObject* creator) : PassiveItem(creator)
{
@@ -51,15 +53,25 @@
this->duration_ = 0.0f;
}
- //! Deconstructor.
+
+ /**
+ @brief
+ Destructor.
+ */
ModifierPickup::~ModifierPickup()
{
+
}
+
/**
- @brief Method for loading information from a level file.
- @param element XMLElement from which to read the data.
- @param mode XMLPort mode to use.
+ @brief
+ Method for loading information from a level file.
+ @param element
+ XMLElement from which to read the data.
+ @param mode
+ XMLPort mode to use.
*/
+ //TODO: Comments: params can probably be ommitted.
void ModifierPickup::XMLPort(Element& element, XMLPort::Mode mode)
{
SUPER(ModifierPickup, XMLPort, element, mode);
@@ -72,15 +84,18 @@
XMLPortParamTemplate(ModifierPickup, "accelerationAdd", setAdditiveAcceleration, getAdditiveAcceleration, element, mode, float);
XMLPortParamTemplate(ModifierPickup, "accelerationMulti", setMultiplicativeAcceleration, getMultiplicativeAcceleration, element, mode, float);
}
+
/**
- @brief
- Invoked when a pawn picks up the pickup.
+ @brief
+ Invoked when a pawn picks up the pickup.
- Adds the modifiers to the pawn and sets a timer (if effect is limited)
- if the pickup could be added to the pawn's PickupCollection.
+ Adds the modifiers to the pawn and sets a timer (if effect is limited)
+ if the pickup could be added to the pawn's PickupCollection.
- @param pawn Pawn which picked up the pickup.
- @return Returns whether the pickup was able to be added to the pawn.
+ @param pawn
+ Pawn which picked up the pickup.
+ @return
+ Returns whether the pickup was able to be added to the pawn.
*/
bool ModifierPickup::pickedUp(Pawn* pawn)
{
@@ -109,15 +124,18 @@
}
return false;
}
+
/**
- @brief
- Invoked when a pawn drops the pickup.
+ @brief
+ Invoked when a pawn drops the pickup.
- Removes the modifiers from the pawn if the pickup
- was successfully removed from it's PickupCollection.
+ Removes the modifiers from the pawn if the pickup
+ was successfully removed from it's PickupCollection.
- @param pawn Pawn which dropped the pickup.
- @return Returns whether the pickup could be removed.
+ @param pawn
+ Pawn which dropped the pickup.
+ @return
+ Returns whether the pickup could be removed.
*/
bool ModifierPickup::dropped(Pawn* pawn)
{
@@ -144,18 +162,24 @@
}
return false;
}
+
/**
- @brief Invoked when the timer finished, calls dropped().
+ @brief Invoked when the timer finished, calls dropped().
*/
+ //TODO: Other name for function?
void ModifierPickup::timerCallback(Pawn* pawn)
{
if (!this->dropped(pawn))
COUT(2) << "Failed to remove modifier pickup after the timer ran out!" << std::endl;
}
+
/**
- @brief Gets the additive modifier of a given type.
- @param type ModifierType for which to return the modifier.
- @return Returns the additive modifier for type (or 0 if not exists).
+ @brief
+ Gets the additive modifier of a given type.
+ @param type
+ ModifierType for which to return the modifier.
+ @return
+ Returns the additive modifier for type (or 0 if not exists).
*/
float ModifierPickup::getAdditiveModifier(ModifierType::Value type) const
{
@@ -165,10 +189,14 @@
else
return 0.0f;
}
+
/**
- @brief Gets the multiplicative modifier of a given type.
- @param type ModifierType for which to return the modifier.
- @return Returns the multiplicative modifier for type (or 1 if not exists).
+ @brief
+ Gets the multiplicative modifier of a given type.
+ @param type
+ ModifierType for which to return the modifier.
+ @return
+ Returns the multiplicative modifier for type (or 1 if not exists).
*/
float ModifierPickup::getMultiplicativeModifier(ModifierType::Value type) const
{
@@ -178,10 +206,14 @@
else
return 1.0f;
}
+
/**
- @brief Gets the additive modifier of a given type.
- @param type ModifierType for which to return the modifier.
- @param value The new additive modifier for type.
+ @brief
+ Gets the additive modifier of a given type.
+ @param type
+ ModifierType for which to return the modifier.
+ @param value
+ The new additive modifier for type.
*/
void ModifierPickup::setAdditiveModifier(ModifierType::Value type, float value)
{
@@ -190,10 +222,14 @@
else
this->additiveModifiers_[type] = value;
}
+
/**
- @brief Gets the multiplicative modifier of a given type.
- @param type ModifierType for which to return the modifier.
- @param value The new multiplicative modifier for type.
+ @brief
+ Gets the multiplicative modifier of a given type.
+ @param type
+ ModifierType for which to return the modifier.
+ @param value
+ The new multiplicative modifier for type.
*/
void ModifierPickup::setMultiplicativeModifier(ModifierType::Value type, float value)
{
@@ -202,4 +238,5 @@
else
this->multiplicativeModifiers_[type] = value;
}
+
}
Modified: code/branches/pickup2/src/orxonox/pickup/ModifierPickup.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/ModifierPickup.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/ModifierPickup.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -46,100 +46,112 @@
namespace orxonox
{
/**
- @brief Class for a (temporary) modifier effect.
- @author Daniel 'Huty' Haggenmueller
+ @brief Class for a (temporary) modifier effect.
+ @author Daniel 'Huty' Haggenmueller
*/
+ //TODO: More elaborate comments.
class _OrxonoxExport ModifierPickup : public PassiveItem
{
- public:
- ModifierPickup(BaseObject* creator);
- virtual ~ModifierPickup();
+ //TODO: What does being derived from PassiveItem add exactly? Probably better to kill PassiveItem and just derive from BaseItem.
+ //Include ModifierType here, no additional header file needed for that, imo.
+ public:
+ ModifierPickup(BaseObject* creator);
+ virtual ~ModifierPickup();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file.
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file.
- virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method.
- virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method
+ virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method.
+ virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method
- virtual int getMaxCarryAmount(){ return INT_MAX; } //!< Allow the player to carry infinite ModPickups
+ //TODO: Where does this INT_MAX come from? Comment.
+ virtual int getMaxCarryAmount() //!< Allow the player to carry infinite ModPickups
+ { return INT_MAX; }
- /**
+ /**
@brief Get the duration of this pickup.
@return Returns how long the effect holds on.
- */
- inline float getDuration() const
- { return this->duration_; }
- /**
+ */
+ inline float getDuration() const
+ { return this->duration_; }
+ /**
@brief Set the duration of this pickup.
@param duration How long the effect should hold.
- */
- inline void setDuration(float duration)
- { this->duration_ = duration; }
+ */
+ //TODO: Better be private?
+ inline void setDuration(float duration)
+ { this->duration_ = duration; }
- /**
+ //TODO: Shouldn't these all be seperate pickup items? But, then, would this class really be needed? What does it actually add?
+ //Duration! Thus create two virtual functions addEffect() and removeEffect().
+ //Export the ideas here into seperate, individual subclasses.
+ //Shouldn't this, as an item be in the items folder? or is it, as merely the equivalent of an abstract class not specific enough?
+ //Specify what ModifierItem should do exactly. If the limited duration is the core functionality, another name would probably more fitting.
+ //Perhaps, limited effect duration could also just be another feature of BaseItem...
+ /**
@brief Get the amount of damage this pickup adds.
@return Returns how much damage this pickup adds.
- */
- inline float getAdditiveDamage() const
- { return this->getAdditiveModifier(ModifierType::Damage); }
- /**
+ */
+ inline float getAdditiveDamage() const
+ { return this->getAdditiveModifier(ModifierType::Damage); }
+ /**
@brief Get the factor by which this pickup multiplies the damage.
@return Returns the factor by which to multiply damage.
- */
- inline float getMultiplicativeDamage() const
- { return this->getMultiplicativeModifier(ModifierType::Damage); }
+ */
+ inline float getMultiplicativeDamage() const
+ { return this->getMultiplicativeModifier(ModifierType::Damage); }
- /**
+ /**
@brief Set the amount of damage this pickup adds.
@param value How much damage this pickup adds.
- */
- inline void setAdditiveDamage(float value)
- { this->setAdditiveModifier(ModifierType::Damage, value); }
- /**
+ */
+ inline void setAdditiveDamage(float value)
+ { this->setAdditiveModifier(ModifierType::Damage, value); }
+ /**
@brief Set the factor by which this pickup multiplies the damage.
@param value Factor by which to multiply damage.
- */
- inline void setMultiplicativeDamage(float value)
- { this->setMultiplicativeModifier(ModifierType::Damage, value); }
+ */
+ inline void setMultiplicativeDamage(float value)
+ { this->setMultiplicativeModifier(ModifierType::Damage, value); }
- /**
+ /**
@brief Get the amount of acceleration this pickup adds.
@return Returns how much acceleration this pickup adds.
- */
- inline float getAdditiveAcceleration() const
- { return this->getAdditiveModifier(ModifierType::Acceleration); }
- /**
+ */
+ inline float getAdditiveAcceleration() const
+ { return this->getAdditiveModifier(ModifierType::Acceleration); }
+ /**
@brief Get the factor by which this pickup multiplies the acceleration.
@return Returns the factor by which to multiply acceleration.
- */
- inline float getMultiplicativeAcceleration() const
- { return this->getMultiplicativeModifier(ModifierType::Acceleration); }
+ */
+ inline float getMultiplicativeAcceleration() const
+ { return this->getMultiplicativeModifier(ModifierType::Acceleration); }
- /**
+ /**
@brief Set the amount of acceleration this pickup adds.
@param value How much acceleration this pickup adds.
- */
- inline void setAdditiveAcceleration(float value)
- { this->setAdditiveModifier(ModifierType::Acceleration, value); }
- /**
+ */
+ inline void setAdditiveAcceleration(float value)
+ { this->setAdditiveModifier(ModifierType::Acceleration, value); }
+ /**
@brief Set the factor by which this pickup multiplies the acceleration.
@param value Factor by which to multiply acceleration.
- */
- inline void setMultiplicativeAcceleration(float value)
- { this->setMultiplicativeModifier(ModifierType::Acceleration, value); }
+ */
+ inline void setMultiplicativeAcceleration(float value)
+ { this->setMultiplicativeModifier(ModifierType::Acceleration, value); }
- void timerCallback(Pawn* pawn); //!< Method called when the timer runs out.
-
- private:
- float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType.
- float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType.
- void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType.
- void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType
+ //TODO: Make private?
+ void timerCallback(Pawn* pawn); //!< Method called when the timer runs out.
+ private:
+ float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType.
+ float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType.
+ void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType.
+ void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType
- std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.
- std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.
+ std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.
+ std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.
- float duration_; //!< Duration of this pickup's effect (0 for unlimited).
- Timer timer_; //!< Timer used if the pickup's effect has a time limit.
+ float duration_; //!< Duration of this pickup's effect (0 for unlimited).
+ Timer timer_; //!< Timer used if the pickup's effect has a time limit.
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/ModifierType.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/ModifierType.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/ModifierType.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -38,6 +38,7 @@
namespace orxonox
{
+ //TODO: Merge with ModifierPickup.
namespace ModifierType
{
/**
Modified: code/branches/pickup2/src/orxonox/pickup/PassiveItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PassiveItem.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PassiveItem.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -32,8 +32,8 @@
namespace orxonox
{
/**
- @brief Constructor. Registers the PassiveItem.
- @param creator Pointer to the object which created this item.
+ @brief Constructor. Registers the PassiveItem.
+ @param creator Pointer to the object which created this item.
*/
PassiveItem::PassiveItem(BaseObject* creator) : BaseItem(creator)
{
Modified: code/branches/pickup2/src/orxonox/pickup/PassiveItem.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PassiveItem.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PassiveItem.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -40,14 +40,17 @@
namespace orxonox
{
/**
- @brief Base class for all passive items.
- @author Daniel 'Huty' Haggenmueller
+ @brief Base class for all passive items.
+ @author Daniel 'Huty' Haggenmueller
*/
class _OrxonoxExport PassiveItem : public BaseItem
{
- public:
- PassiveItem(BaseObject* creator);
- virtual ~PassiveItem() {}
+ //TODO: What is this Class for. Where is ActiveItem?
+ //Rename it InstantItem?
+ public:
+ PassiveItem(BaseObject* creator);
+ virtual ~PassiveItem() {}
+
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/PickupCollection.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupCollection.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PickupCollection.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -46,76 +46,79 @@
namespace orxonox
{
/**
- @brief PickupCollection for organising items.
- @author Daniel 'Huty' Haggenmueller
+ @brief PickupCollection for organising items.
+ @author Daniel 'Huty' Haggenmueller
*/
class _OrxonoxExport PickupCollection
{
- public:
- PickupCollection();
+ public:
+ //TODO: Should probably be derived from OrxonoxClass???
+ PickupCollection();
- bool add(BaseItem* item); //!< Add an item to the collection.
+ bool add(BaseItem* item); //!< Add an item to the collection.
- bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item.
+ bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item.
- void clear(); //!< Empty the collection
- bool contains(BaseItem* item, bool anyOfType = false); //!< Check if the collection contains an item.
+ void clear(); //!< Empty the collection
+ bool contains(BaseItem* item, bool anyOfType = false); //!< Check if the collection contains an item.
- void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection.
+ void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection.
- void useItem(); //!< Use the first usable item.
- void useItem(UsableItem* item); //!< Use a usable item.
+ //TODO: What's up with that?
+ void useItem(); //!< Use the first usable item.
+ void useItem(UsableItem* item); //!< Use a usable item.
- void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier.
- void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier.
+ //TODO: This really shouldn't be here. It's nbot the Collections business to know about stuff like that.
+ void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier.
+ void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier.
- float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier.
- float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier.
+ float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier.
+ float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier.
- void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier.
- void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier.
+ void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier.
+ void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier.
- float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.
- Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.
+ float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.
+ Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.
- /**
- @brief Get the map of contained items.
- @return The map of items.
- */
- std::multimap<std::string, BaseItem*> getItems() const
- { return this->items_; }
+ /**
+ @brief Get the map of contained items.
+ @return The map of items.
+ */
+ std::multimap<std::string, BaseItem*> getItems() const
+ { return this->items_; }
- /**
- @brief Get the owner of the PickupCollection.
- @return Returns the pawn which owns the PickupCollection.
- */
- inline Pawn* getOwner() const
- { return this->owner_; }
- /**
- @brief Set the owner of the PickupCollection.
- @param owner The new Pawn which owns the PickupCollection.
- */
- inline void setOwner(Pawn* owner)
- { this->owner_ = owner; }
+ /**
+ @brief Get the owner of the PickupCollection.
+ @return Returns the pawn which owns the PickupCollection.
+ */
+ inline Pawn* getOwner() const
+ { return this->owner_; }
+ /**
+ @brief Set the owner of the PickupCollection.
+ @param owner The new Pawn which owns the PickupCollection.
+ */
+ inline void setOwner(Pawn* owner)
+ { this->owner_ = owner; }
- inline UsableItem* getCurrentUsable()
- { return this->currentUsable_; };
- inline void setCurrentUsable(UsableItem* usable)
- { this->currentUsable_ = usable; }
+ inline UsableItem* getCurrentUsable()
+ { return this->currentUsable_; };
+ inline void setCurrentUsable(UsableItem* usable)
+ { this->currentUsable_ = usable; }
- std::deque<EquipmentItem*> getEquipmentItems(); //!< Get a list of equipment-type items.
- std::deque<PassiveItem*> getPassiveItems(); //!< Get a list of passive items.
- std::deque<UsableItem*> getUsableItems(); //!< Get a list of usable items.
- private:
- Pawn* owner_; //!< The owner of the PickupCollection.
- UsableItem* currentUsable_;
+ std::deque<EquipmentItem*> getEquipmentItems(); //!< Get a list of equipment-type items.
+ std::deque<PassiveItem*> getPassiveItems(); //!< Get a list of passive items.
+ std::deque<UsableItem*> getUsableItems(); //!< Get a list of usable items.
+ private:
+ Pawn* owner_; //!< The owner of the PickupCollection.
+ UsableItem* currentUsable_;
- bool bBlockRemovals_; //!< Whether to block direct removals through remove().
+ bool bBlockRemovals_; //!< Whether to block direct removals through remove().
- std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).
- std::multimap<ModifierType::Value, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).
+ std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).
+ std::multimap<ModifierType::Value, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).
- std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items).
+ std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items).
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PickupInventory.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -51,6 +51,16 @@
SetConsoleCommandShortcut(PickupInventory, toggleInventory);
PickupInventory* PickupInventory::pickupInventory_s = NULL;
+
+ //TODO: Comment.
+
+ /**
+ @brief
+ Get a Pointer to the PickupInventory Singleton.
+ @return
+ A Pointer to the PickupInventory.
+ */
+ //TODO: Make SingeltonPtr?
PickupInventory* PickupInventory::getSingleton()
{
if(!PickupInventory::pickupInventory_s)
@@ -59,10 +69,16 @@
return PickupInventory::pickupInventory_s;
}
+ /**
+ @brief
+ Constructor.
+ */
PickupInventory::PickupInventory()
{
- this->bInventoryVisible_ = false;
- this->visibleEquipmentWindows_ = this->visibleUsableWIndows_ = 0;
+ //TODO: Maybe some abstraction for the usableWindows, e.g. push and pop...
+ //RegisterObject() ? In some other Class, too. Which?
+ this->bInventoryVisible_ = false; //TODO: If OrxonoxClass, this should already be there...
+ this->visibleEquipmentWindows_ = this->visibleUsableWindows_ = 0;
// Create some windows to avoid creating them while playing
CEGUI::WindowManager* winMgr = CEGUI::WindowManager::getSingletonPtr();
@@ -76,13 +92,21 @@
}
this->createdEquipmentWindows_ = this->createdUsableWindows_ = 10;
}
+
+ /**
+ @brief
+ Destructor.
+ */
+ //TODO: Destroy something?
PickupInventory::~PickupInventory()
{
}
-
-
- void PickupInventory::toggleInventory()
+ /**
+ @brief
+ Toggles the visibility of the inventory.
+ */
+ /*static*/ void PickupInventory::toggleInventory()
{
if(PickupInventory::getSingleton()->isVisible()) {
GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
@@ -98,6 +122,10 @@
PickupInventory::getSingleton()->setVisible(!PickupInventory::getSingleton()->isVisible());
}
+ /**
+ @brief
+
+ */
unsigned int PickupInventory::getCurrentUsableIndex()
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -114,6 +142,7 @@
return 0;
}
+
bool PickupInventory::isCurrentUsable(const BaseItem* item)
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -122,6 +151,7 @@
else
return false;
}
+
void PickupInventory::selectUsable(unsigned int i)
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -141,6 +171,7 @@
else
return 0;
}
+
unsigned int PickupInventory::getUsableCount()
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -149,6 +180,7 @@
else
return 0;
}
+
unsigned int PickupInventory::getPassiveCount()
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -157,6 +189,7 @@
else
return 0;
}
+
BaseItem* PickupInventory::getEquipmentItem(unsigned int i)
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -169,6 +202,7 @@
else
return NULL;
}
+
BaseItem* PickupInventory::getUsableItem(unsigned int i)
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -181,6 +215,7 @@
else
return NULL;
}
+
BaseItem* PickupInventory::getPassiveItem(unsigned int i)
{
Pawn* pawn = HumanController::getLocalControllerEntityAsPawn();
@@ -224,7 +259,7 @@
equipPane->removeChildWindow("orxonox/Inventory/Title/equ/" + id.str());
equipPane->removeChildWindow("orxonox/Inventory/Items/equ/" + id.str());*/
}
- for(unsigned int i = 0; i < this->visibleUsableWIndows_; i++)
+ for(unsigned int i = 0; i < this->visibleUsableWindows_; i++)
{
std::ostringstream id;
id << i;
@@ -238,6 +273,7 @@
usablePane->removeChildWindow("orxonox/Inventory/Items/use/" + id.str());*/
}
}
+
void PickupInventory::updateTabs(CEGUI::WindowManager *winMgr, CEGUI::Window *equipWindow, CEGUI::Window *usableWindow)
{
this->updateEquipment(winMgr, equipWindow);
@@ -268,6 +304,7 @@
this->visibleEquipmentWindows_ = items.size();
}
}
+
void PickupInventory::updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target)
{
Pawn* pawn;
@@ -295,7 +332,7 @@
PickupInventory::setWindowProperties(winMgr, target, id.str(), item, colour);
}
- this->visibleUsableWIndows_ = items.size();
+ this->visibleUsableWindows_ = items.size();
}
}
@@ -325,6 +362,7 @@
btn->subscribeScriptedEvent("Clicked", "PickupInventory.itemClicked");
btn->setVisible(false);
}
+
void PickupInventory::setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour)
{
CEGUI::Window* txt = winMgr->getWindow("orxonox/Inventory/Title/" + id);
@@ -349,4 +387,5 @@
target->addChildWindow(txt);
target->addChildWindow(btn);
}
+
}
Modified: code/branches/pickup2/src/orxonox/pickup/PickupInventory.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupInventory.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PickupInventory.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -43,55 +43,57 @@
namespace orxonox
{
/**
- @brief Static class for the inventory GUI window.
- @author Daniel 'Huty' Haggenmueller
+ @brief Static class for the inventory GUI window.
+ @author Daniel 'Huty' Haggenmueller
*/
class _OrxonoxExport PickupInventory
{
// tolua_end
- public:
- PickupInventory();
- virtual ~PickupInventory();
+ public:
+ //TODO: Be derived from OrxonoxClass and ScopedSingleton.
+ //Make some methods private?
+ PickupInventory();
+ virtual ~PickupInventory();
- static PickupInventory* getSingleton(); // tolua_export
+ static PickupInventory* getSingleton(); // tolua_export
- static void toggleInventory(); // tolua_export
+ static void toggleInventory(); // tolua_export
- static unsigned int getEquipmentCount(); // tolua_export
- static unsigned int getUsableCount(); // tolua_export
- static unsigned int getPassiveCount(); // tolua_export
+ static unsigned int getEquipmentCount(); // tolua_export
+ static unsigned int getUsableCount(); // tolua_export
+ static unsigned int getPassiveCount(); // tolua_export
- static unsigned int getCurrentUsableIndex(); // tolua_export
- static bool isCurrentUsable(const BaseItem* item); // tolua_export
- static void selectUsable(unsigned int i); // tolua_export
+ static unsigned int getCurrentUsableIndex(); // tolua_export
+ static bool isCurrentUsable(const BaseItem* item); // tolua_export
+ static void selectUsable(unsigned int i); // tolua_export
- static BaseItem* getEquipmentItem(unsigned int i); // tolua_export
- static BaseItem* getUsableItem(unsigned int i); // tolua_export
- static BaseItem* getPassiveItem(unsigned int i); // tolua_export
+ static BaseItem* getEquipmentItem(unsigned int i); // tolua_export
+ static BaseItem* getUsableItem(unsigned int i); // tolua_export
+ static BaseItem* getPassiveItem(unsigned int i); // tolua_export
- static std::string getImageForItem(const BaseItem* item); // tolua_export
+ static std::string getImageForItem(const BaseItem* item); // tolua_export
- void clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane); // tolua_export
- void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export
+ void clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane); // tolua_export
+ void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export
- void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
- void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+ void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
+ void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);
- static void createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y);
- static void setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour);
+ static void createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y);
+ static void setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour);
- const bool isVisible() const
- { return this->bInventoryVisible_; }
- void setVisible(bool visible)
- { this->bInventoryVisible_ = visible; }
- private:
- bool bInventoryVisible_;
- unsigned int createdEquipmentWindows_;
- unsigned int createdUsableWindows_;
- unsigned int visibleEquipmentWindows_;
- unsigned int visibleUsableWIndows_;
+ const bool isVisible() const
+ { return this->bInventoryVisible_; }
+ void setVisible(bool visible)
+ { this->bInventoryVisible_ = visible; }
+ private:
+ bool bInventoryVisible_;
+ unsigned int createdEquipmentWindows_;
+ unsigned int createdUsableWindows_;
+ unsigned int visibleEquipmentWindows_;
+ unsigned int visibleUsableWindows_;
- static PickupInventory* pickupInventory_s;
+ static PickupInventory* pickupInventory_s;
}; // tolua_export
} // tolua_export
Modified: code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PickupSpawner.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -52,8 +52,10 @@
CreateFactory(PickupSpawner);
/**
- @brief Constructor. Registers the PickupSpawner.
- @param creator Pointer to the object which created this item.
+ @brief
+ Constructor. Registers the PickupSpawner.
+ @param creator
+ Pointer to the object which created this item.
*/
PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator)
{
@@ -64,14 +66,23 @@
this->respawnTime_ = 0.0f;
this->tickSum_ = 0.0f;
}
- //! Deconstructor.
+
+ /**
+ @brief
+ Destructor.
+ */
PickupSpawner::~PickupSpawner()
{
+
}
+
/**
- @brief Method for creating a PickupSpawner through XML.
- @param xmlelement XML element which contains the PickupSpawner.
- @param mode XMLPort mode.
+ @brief
+ Method for creating a PickupSpawner through XML.
+ @param xmlelement
+ XML element which contains the PickupSpawner.
+ @param mode
+ XMLPort mode.
*/
void PickupSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
@@ -81,6 +92,7 @@
XMLPortParam(PickupSpawner, "triggerDistance", setTriggerDistance, getTriggerDistance, xmlelement, mode);
XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode);
+ //TODO: Kill hack.
// HACKs
// Load the GUI image as soon as the PickupSpawner gets loaded
// = less delays while running
@@ -99,8 +111,10 @@
GUIManager::getInstance().executeCode("hideGUI(\"PickupInventory\")");
PickupInventory::getSingleton();
}
+
/**
- @brief Invoked when the activity has changed. Sets visibility of attached objects.
+ @brief
+ Invoked when the activity has changed. Sets visibility of attached objects.
*/
void PickupSpawner::changedActivity()
{
@@ -109,19 +123,26 @@
for (std::set<WorldEntity*>::const_iterator it = this->getAttachedObjects().begin(); it != this->getAttachedObjects().end(); it++)
(*it)->setVisible(this->isActive());
}
+
/**
- @brief Set the template name of the item to spawn, also loads the template.
- @param name Name of the new template.
+ @brief
+ Set the template name of the item to spawn, also loads the template.
+ @param name
+ Name of the new template.
*/
void PickupSpawner::setItemTemplateName(const std::string& name)
{
this->itemTemplateName_ = name;
this->itemTemplate_ = Template::getTemplate(name);
}
+
/**
- @brief Tick, checks if any Pawn is close enough to trigger.
- @param dt Time since last tick.
+ @brief
+ Tick, checks if any Pawn is close enough to trigger.
+ @param dt
+ Time since last tick.
*/
+ //TODO: Replace this with a real DistanceTrigger.
void PickupSpawner::tick(float dt)
{
if (this->isActive())
@@ -139,14 +160,16 @@
this->tickSum_ -= 2*Ogre::Math::PI;
}
}
+
/**
- @brief
- Trigger the PickupSpawner.
+ @brief
+ Trigger the PickupSpawner.
- Adds the pickup to the Pawn that triggered,
- sets the timer to re-activate and deactives the PickupSpawner.
+ Adds the pickup to the Pawn that triggered,
+ sets the timer to re-activate and deactives the PickupSpawner.
- @param pawn Pawn which triggered the PickupSpawner.
+ @param pawn
+ Pawn which triggered the PickupSpawner.
*/
void PickupSpawner::trigger(Pawn* pawn)
{
@@ -176,8 +199,10 @@
}
}
}
+
/**
- @brief Invoked by the timer, re-activates the PickupSpawner.
+ @brief
+ Invoked by the timer, re-activates the PickupSpawner.
*/
void PickupSpawner::respawnTimerCallback()
{
Modified: code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/PickupSpawner.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -49,71 +49,72 @@
*/
class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
{
- public:
- PickupSpawner(BaseObject* creator);
- virtual ~PickupSpawner();
+ public:
+ //TODO: Add limit of items spawned here. Also possibility to spawn collections?
+ PickupSpawner(BaseObject* creator);
+ virtual ~PickupSpawner();
- virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML.
- virtual void tick(float dt);
+ virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML.
+ virtual void tick(float dt);
- void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
- void respawnTimerCallback(); //!< Method called when the timer runs out.
+ void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
+ void respawnTimerCallback(); //!< Method called when the timer runs out.
- /**
+ /**
@brief Get the template name for the item to spawn.
@return Returns the name of the template of the item to spawn.
- */
- inline const std::string& getItemTemplateName() const
- { return this->itemTemplateName_; }
- void setItemTemplateName(const std::string& name); //!< Set the template name of the item to spawn.
+ */
+ inline const std::string& getItemTemplateName() const
+ { return this->itemTemplateName_; }
+ void setItemTemplateName(const std::string& name); //!< Set the template name of the item to spawn.
- /**
- @brief Get the template for the item to spawn.
- @return Returns the template of the item to spawn.
- */
- inline Template* getItemTemplate() const
- { return this->itemTemplate_; }
+ /**
+ @brief Get the template for the item to spawn.
+ @return Returns the template of the item to spawn.
+ */
+ inline Template* getItemTemplate() const
+ { return this->itemTemplate_; }
- /**
- @brief Get the distance in which to trigger.
- @return Returns the distance in which this gets triggered.
- */
- inline float getTriggerDistance() const
- { return this->triggerDistance_; }
- /**
- @brief Set the distance in which to trigger.
- @param value The new distance in which to trigger.
- */
- inline void setTriggerDistance(float value)
- { this->triggerDistance_ = value; }
+ /**
+ @brief Get the distance in which to trigger.
+ @return Returns the distance in which this gets triggered.
+ */
+ inline float getTriggerDistance() const
+ { return this->triggerDistance_; }
+ /**
+ @brief Set the distance in which to trigger.
+ @param value The new distance in which to trigger.
+ */
+ inline void setTriggerDistance(float value)
+ { this->triggerDistance_ = value; }
- /**
- @brief Get the time to respawn.
- @returns Returns the time after which this gets re-actived.
- */
- inline float getRespawnTime() const
- { return this->respawnTime_; }
- /**
- @brief Set the time to respawn.
- @param time New time after which this gets re-actived.
- */
- inline void setRespawnTime(float time)
- { this->respawnTime_ = time; }
- private:
- std::string itemTemplateName_; //!< Template name of the item to spawn.
- Template* itemTemplate_; //!< Template of the item to spawn.
+ /**
+ @brief Get the time to respawn.
+ @returns Returns the time after which this gets re-actived.
+ */
+ inline float getRespawnTime() const
+ { return this->respawnTime_; }
+ /**
+ @brief Set the time to respawn.
+ @param time New time after which this gets re-actived.
+ */
+ inline void setRespawnTime(float time)
+ { this->respawnTime_ = time; }
+ private:
+ std::string itemTemplateName_; //!< Template name of the item to spawn.
+ Template* itemTemplate_; //!< Template of the item to spawn.
- float triggerDistance_; //!< Distance in which this gets triggered.
+ float triggerDistance_; //!< Distance in which this gets triggered.
- /* Pickup animation */
- float tickSum_; //!< Adds up tick to use in sine movement
- static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down
- static const float bounceDistance_s; //!< Distance the pickup bounces up and down
- static const float rotationSpeed_s; //!< Rotation speed of pickup
+ /* Pickup animation */
+ float tickSum_; //!< Adds up tick to use in sine movement
+ static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down
+ static const float bounceDistance_s; //!< Distance the pickup bounces up and down
+ static const float rotationSpeed_s; //!< Rotation speed of pickup
- float respawnTime_; //!< Time after which this gets re-actived.
- Timer respawnTimer_; //!< Timer used for re-activating.
+ float respawnTime_; //!< Time after which this gets re-actived.
+ Timer respawnTimer_; //!< Timer used for re-activating.
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/UsableItem.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/UsableItem.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/UsableItem.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -37,8 +37,8 @@
namespace orxonox
{
/**
- @brief Constructor. Registers the UsableItem.
- @param creator Pointer to the object which created this item.
+ @brief Constructor. Registers the UsableItem.
+ @param creator Pointer to the object which created this item.
*/
UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator)
{
Modified: code/branches/pickup2/src/orxonox/pickup/UsableItem.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/UsableItem.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/UsableItem.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -45,15 +45,16 @@
*/
class _OrxonoxExport UsableItem : public BaseItem
{
- public:
- UsableItem(BaseObject* creator);
- virtual ~UsableItem() { }
+ //TODO: What is this exactly?
+ public:
+ UsableItem(BaseObject* creator);
+ virtual ~UsableItem() { }
- /**
- @brief Method invoked when the item is being used.
- @param pawn Pawn which is using the item.
- */
- virtual void used(Pawn* pawn) { }
+ /**
+ @brief Method invoked when the item is being used.
+ @param pawn Pawn which is using the item.
+ */
+ virtual void used(Pawn* pawn) { }
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -58,6 +58,7 @@
XMLPortParam(HealthImmediate, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode);
}
+ //TODO: Should be destroyed anyways...
bool HealthImmediate::pickedUp(Pawn* pawn)
{
float maxH = pawn->getMaxHealth();
Modified: code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/items/HealthImmediate.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -44,21 +44,23 @@
*/
class _OrxonoxExport HealthImmediate : public PassiveItem
{
- public:
- HealthImmediate(BaseObject* creator);
- virtual ~HealthImmediate();
+ //TODO: Comment.
+ //Does this get destroyed, when the healt is delivered? It seems to me it doesn't.
+ public:
+ HealthImmediate(BaseObject* creator);
+ virtual ~HealthImmediate();
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
- virtual bool pickedUp(Pawn* pawn);
+ virtual bool pickedUp(Pawn* pawn);
- inline float getRecoveredHealth() const
- { return this->recoveredHealth_; }
- inline void setRecoveredHealth(float recovery)
- { this->recoveredHealth_ = recovery; }
+ inline float getRecoveredHealth() const
+ { return this->recoveredHealth_; }
+ inline void setRecoveredHealth(float recovery)
+ { this->recoveredHealth_ = recovery; }
- private:
- float recoveredHealth_;
+ private:
+ float recoveredHealth_;
};
}
Modified: code/branches/pickup2/src/orxonox/pickup/items/HealthUsable.cc
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/items/HealthUsable.cc 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/items/HealthUsable.cc 2009-10-14 11:44:19 UTC (rev 5947)
@@ -44,8 +44,8 @@
CreateFactory(HealthUsable);
/**
- @brief Constructor
- @param creator Object that created this item.
+ @brief Constructor
+ @param creator Object that created this item.
*/
HealthUsable::HealthUsable(BaseObject* creator) : UsableItem(creator)
{
@@ -53,14 +53,16 @@
this->recoveredHealth_ = 0;
}
+
//! Deconstructor
HealthUsable::~HealthUsable()
{
}
+
/**
- @brief XMLPort for Jump.
- @param xmlelement Element of the XML-file.
- @param mode XMLPort mode to use.
+ @brief XMLPort for Jump.
+ @param xmlelement Element of the XML-file.
+ @param mode XMLPort mode to use.
*/
void HealthUsable::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
@@ -68,10 +70,13 @@
XMLPortParam(HealthUsable, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode);
}
+
/**
- @brief Called when the item is used, makes the user "jump".
- @param pawn Pawn which used te item.
+ @brief Called when the item is used, makes the user "jump".
+ @param pawn Pawn which used te item.
*/
+ //TODO: Jump? Nope! => Comment.
+ //Should be destroyed anyways.
void HealthUsable::used(Pawn* pawn)
{
float maxH = pawn->getMaxHealth();
@@ -84,17 +89,19 @@
this->destroy();
}
}
+
/**
- @brief Called when the item is picked up.
- @param pawn Pawn which picked up the item.
+ @brief Called when the item is picked up.
+ @param pawn Pawn which picked up the item.
*/
bool HealthUsable::pickedUp(Pawn* pawn)
{
return this->addTo(pawn);
}
+
/**
- @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
- @param pawn Pawn which dropped the item.
+ @brief Called when the item is dropped, creates a DroppedItem behind the pawn.
+ @param pawn Pawn which dropped the item.
*/
bool HealthUsable::dropped(Pawn* pawn)
{
Modified: code/branches/pickup2/src/orxonox/pickup/items/Jump.h
===================================================================
--- code/branches/pickup2/src/orxonox/pickup/items/Jump.h 2009-10-14 11:17:34 UTC (rev 5946)
+++ code/branches/pickup2/src/orxonox/pickup/items/Jump.h 2009-10-14 11:44:19 UTC (rev 5947)
@@ -49,47 +49,48 @@
*/
class _OrxonoxExport Jump : public UsableItem
{
- public:
- Jump(BaseObject* creator); //!< Constructor
- virtual ~Jump(); //!< Deconstructor
+ public:
+ //TODO: Comment. a.s.o.
+ Jump(BaseObject* creator); //!< Constructor
+ virtual ~Jump(); //!< Deconstructor
- virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort
- virtual int getMaxCarryAmount() const
- { return INT_MAX; }
+ virtual int getMaxCarryAmount() const
+ { return INT_MAX; }
- virtual void used(Pawn* pawn); //!< Called when the item is used.
+ virtual void used(Pawn* pawn); //!< Called when the item is used.
- virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
- virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.
+ virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.
+ virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.
- /**
- @brief Get the velocity added when the item is used.
- @return Returns the added velocity (relative to the Pawn).
- */
- inline const Vector3& getVelocity() const
- { return this->velocity_; }
- /**
- @brief Set the velocity added when the item is used.
- @param velocity New added velocity (relative to Pawn).
- */
- inline void setVelocity(const Vector3& velocity)
- { this->velocity_ = velocity; }
- /**
- @brief Get the amount of jumps available.
- @return Returns how many times the item can be used.
- */
- inline int getJumpsAvailable() const
- { return this->jumpsAvailable_; }
- /**
- @brief Set the amount of jumps available.
- @param num New number of available jumps.
- */
- inline void setJumpsAvailable(int num)
- { this->jumpsAvailable_ = num; }
- private:
- Vector3 velocity_; //!< The velocity added when the item is used.
- int jumpsAvailable_; //!< Amount of jumps still available.
+ /**
+ @brief Get the velocity added when the item is used.
+ @return Returns the added velocity (relative to the Pawn).
+ */
+ inline const Vector3& getVelocity() const
+ { return this->velocity_; }
+ /**
+ @brief Set the velocity added when the item is used.
+ @param velocity New added velocity (relative to Pawn).
+ */
+ inline void setVelocity(const Vector3& velocity)
+ { this->velocity_ = velocity; }
+ /**
+ @brief Get the amount of jumps available.
+ @return Returns how many times the item can be used.
+ */
+ inline int getJumpsAvailable() const
+ { return this->jumpsAvailable_; }
+ /**
+ @brief Set the amount of jumps available.
+ @param num New number of available jumps.
+ */
+ inline void setJumpsAvailable(int num)
+ { this->jumpsAvailable_ = num; }
+ private:
+ Vector3 velocity_; //!< The velocity added when the item is used.
+ int jumpsAvailable_; //!< Amount of jumps still available.
};
}
More information about the Orxonox-commit
mailing list