Changeset 5902 for code/branches/pickup/src/orxonox
- Timestamp:
- Oct 7, 2009, 2:20:43 PM (15 years ago)
- Location:
- code/branches/pickup/src/orxonox/pickup
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup/src/orxonox/pickup/BaseItem.cc
r5781 r5902 41 41 { 42 42 /** 43 44 43 @brief Constructor. Registers the BaseItem. 44 @param creator Pointer to the object which created this item. 45 45 */ 46 46 BaseItem::BaseItem(BaseObject* creator) : BaseObject(creator) … … 59 59 60 60 /** 61 62 63 61 @brief XMLPort for BaseItem. 62 @param xmlelement Element of the XML-file. 63 @param mode XMLPort mode to use. 64 64 */ 65 65 void BaseItem::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 72 72 73 73 /** 74 75 76 74 @brief Method to add the item to a pawn. 75 @param pawn Pawn to which the item should get added. 76 @return Returns whether the pawn's PickupCollection accepted the item. 77 77 */ 78 78 bool BaseItem::addTo(Pawn* pawn) … … 80 80 this->setOwner(pawn); 81 81 82 if (pawn->getPickups().add(this)) 82 if (pawn->getPickups().add(this)) //TODO: Does the pawn store his pickups? 83 83 { 84 84 COUT(3) << "Added '" << this->getPickupIdentifier() << "' item." << std::endl; -
code/branches/pickup/src/orxonox/pickup/BaseItem.h
r5781 r5902 44 44 { 45 45 /** 46 47 46 @brief 47 Base class for all items/pickups. 48 48 49 50 51 49 Provides common methods to be used in derived classes. 50 @author 51 Daniel 'Huty' Haggenmueller 52 52 */ 53 53 class _OrxonoxExport BaseItem : public BaseObject 54 54 { 55 55 // tolua_end 56 public:57 BaseItem(BaseObject* creator);58 virtual ~BaseItem();56 public: 57 BaseItem(BaseObject* creator); 58 virtual ~BaseItem(); 59 59 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort 61 61 62 /**62 /** 63 63 @brief Checks how many instances of this item can be carried at a time. 64 64 @return How many of this item can be carried. 65 */66 virtual int getMaxCarryAmount() const67 { return 1; }65 */ 66 virtual int getMaxCarryAmount() const //TODO: Maybe, better to just be virtual. 67 { return BaseItem::MAX_CARRY_AMOUNT; } 68 68 69 bool addTo(Pawn* pawn); //!< Add the item to a pawn. 70 bool removeFrom(Pawn* pawn); //!< Removes the item from a pawn. 71 /** 69 //TODO: Need to be public? 70 bool addTo(Pawn* pawn); //!< Add the item to a pawn. 71 bool removeFrom(Pawn* pawn); //!< Removes the item from a pawn. 72 /** 72 73 @brief 73 74 Method invoked when the item gets picked up. … … 78 79 @param pawn Pawn who picks up the item. 79 80 @return Returns whether the pawn was able to pick up the item. 80 */81 virtual bool pickedUp(Pawn* pawn)82 { return false; }83 /**81 */ 82 virtual bool pickedUp(Pawn* pawn) //TODO: Maybe better to be just virtual. 83 { return false; } 84 /** 84 85 @brief 85 86 Method invoked when the item is dropped from a player. … … 90 91 @param pawn Pawn which dropped the item. 91 92 @return Returns whether the item was able to get dropped by the pawn. 92 */93 virtual bool dropped(Pawn* pawn)94 { return false; }93 */ 94 virtual bool dropped(Pawn* pawn) 95 { return false; } 95 96 96 /**97 /** 97 98 @brief Gets the current owner of the pickup. 98 99 @return Returns the current owner. 99 */100 inline Pawn* getOwner() const101 { return this->owner_; }102 /**100 */ 101 inline Pawn* getOwner() const 102 { return this->owner_; } 103 /** 103 104 @brief Sets the owner of the pickup. 104 105 @param owner New owner for the pickup. 105 */106 inline void setOwner(Pawn* owner)107 { this->owner_ = owner; }106 */ 107 inline void setOwner(Pawn* owner) 108 { this->owner_ = owner; } 108 109 109 /**110 /** 110 111 @brief Gets the pickupIdentifier of the item. 111 112 @return Returns the pickupIdentifier of the item. 112 113 @see pickupIdentifier_ 113 */114 inline const std::string& getPickupIdentifier() const115 { return this->pickupIdentifier_; }116 /**114 */ 115 inline const std::string& getPickupIdentifier() const 116 { return this->pickupIdentifier_; } 117 /** 117 118 @brief Sets the pickupIdentifier for the item. 118 119 @param identifier New pickupIdentifier for the item. 119 120 @see pickupIdentifier_ 120 */ 121 inline void setPickupIdentifier(const std::string& identifier) 122 { this->pickupIdentifier_ = identifier; } 121 */ 122 //TODO: Needs to be public? 123 inline void setPickupIdentifier(const std::string& identifier) 124 { this->pickupIdentifier_ = identifier; } 123 125 124 // GUI stuff 125 virtual const std::string& getGUIText() const; // tolua_export 126 inline void setGUIText(const std::string& text) 127 { this->guiText_ = text; } 126 // GUI stuff 127 //TODO: Comment. Maybe seperate GUI from Pickup, e.g. ItemDescription... 128 virtual const std::string& getGUIText() const; // tolua_export 129 inline void setGUIText(const std::string& text) 130 { this->guiText_ = text; } 128 131 129 virtual const std::string& getGUIImage() const130 { return this->guiImage_; }131 inline void setGUIImage(const std::string& image)132 { this->guiImage_ = image; }133 private:134 Pawn* owner_; //!< The current owner of the item.132 virtual const std::string& getGUIImage() const 133 { return this->guiImage_; } 134 inline void setGUIImage(const std::string& image) 135 { this->guiImage_ = image; } 136 private: 137 static const int MAX_CARRY_AMOUNT = 1; 135 138 136 /** 139 Pawn* owner_; //!< The current owner of the item. 140 141 /** 137 142 @brief 138 143 The pickupIdentifier of the item.. … … 140 145 Usually set to the template name used by a PickupSpawner, 141 146 used to index items in the PickupCollection. 142 */143 std::string pickupIdentifier_;147 */ 148 std::string pickupIdentifier_; //TODO: Remove, when always just this->getName(). 144 149 145 std::string guiText_; 146 std::string guiImage_; 150 //TODO: Comment. 151 std::string guiText_; 152 std::string guiImage_; 147 153 }; // tolua_export 148 154 } // tolua_export -
code/branches/pickup/src/orxonox/pickup/DroppedItem.cc
r5781 r5902 41 41 CreateFactory(DroppedItem); 42 42 43 /** 44 @brief 45 Constructor. Registers object and sets default values. 46 */ 43 47 DroppedItem::DroppedItem(BaseObject* creator) : StaticEntity(creator) 44 48 { … … 47 51 this->triggerDistance_ = 20.0f; 48 52 this->timeToLive_ = 0; 49 this->item_ = 0;53 this->item_ = NULL; 50 54 } 55 56 /** 57 @brief 58 Default destructor. 59 */ 60 //TODO: Destroy something? 51 61 DroppedItem::~DroppedItem() 52 62 { 63 53 64 } 65 66 /** 67 @brief 68 Checks whether any pawn is in triggerDistance of the Item and calls this->trigger if so. 69 @param dt 70 The duration of the last time interval. 71 */ 72 //TODO: Replace this with a DistanceTrigger! 54 73 void DroppedItem::tick(float dt) 55 74 { 56 75 if (this->item_) 57 76 { 58 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++) 77 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it != ObjectList<Pawn>::end(); it++) //!< Iterate through all Pawns. 59 78 { 60 79 Vector3 distance = it->getWorldPosition() - this->getWorldPosition(); … … 64 83 } 65 84 } 85 86 /** 87 @brief 88 Called when the DroppedItem is triggered. Adds the item to the triggering pawn. 89 */ 66 90 void DroppedItem::trigger(Pawn* pawn) 67 91 { 68 if (this->item_->pickedUp(pawn)) 92 if (this->item_->pickedUp(pawn)) //If pickup was successful. 69 93 { 70 94 COUT(3) << "DroppedItem '" << this->item_->getPickupIdentifier() << "' picked up." << std::endl; … … 72 96 } 73 97 } 98 99 /** 100 @brief 101 Creates a timer to call this->timerCallback() at expiration of timeToLive. 102 */ 103 //TODO: Better Comments. 74 104 void DroppedItem::createTimer() 75 105 { … … 80 110 } 81 111 } 112 113 /** 114 @brief 115 Destroys the item. Called by the set timer upon its expiration. 116 */ 117 //TODO: Choose better function name if this doesn't create dependency inconsistencies. e.g. this->destroy() or this->timeOut() 118 //Make certain that only one pawn has the same item, because if not, deliting the item would lead to a possible segfault. 119 //If the item is destroyed here, shouldn't it be destroyed in the destructor as well? 82 120 void DroppedItem::timerCallback() 83 121 { … … 91 129 } 92 130 93 DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive) 131 /** 132 @brief 133 134 */ 135 //TODO: Comment. 136 //This is for pawns dropping items they have... 137 //Probably better to create a spawner with only 1 item in it. 138 //Various different thigs are done here, which in my opinion should eighter be done in XML or some where else, preferably in XML. 139 //Each pickup should have a XML template where the Model and Billboard, and so on, is specified. 140 //The position, item and timetoLive should be specified by this Classes XMLPort function. 141 //These adjustments above, will very likely create inkonsistencies in the level files, possibly templates. 142 /*static*/ DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, const Vector3& position, const ColourValue& flareColour, float timeToLive) 94 143 { 95 144 DroppedItem* drop = new DroppedItem(item); … … 117 166 return drop; 118 167 } 168 169 /** 170 @brief 171 172 */ 173 //TODO: See one function above. 119 174 DroppedItem* DroppedItem::createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour, float timeToLive) 120 175 { -
code/branches/pickup/src/orxonox/pickup/DroppedItem.h
r5781 r5902 49 49 virtual ~DroppedItem(); 50 50 51 //TODO: Comment. 52 //DroppedItem -> Item with no owner, alone in space? 53 //Would be much nicer if it would be triggered by a standard issue DistanceTrigger. 54 //Where is this created? I see no XMLPort. 55 //Where is the item for this created? What happens if more than one pawn triggers this? 56 //Add more than just one items, or even better create the ability to add a Collection.? Rename to ...? 57 51 58 void tick(float dt); 52 59 void trigger(Pawn* pawn); … … 55 62 static DroppedItem* createDefaultDrop(BaseItem* item, Pawn* pawn, const ColourValue& flareColour = ColourValue(0.5f, 1.0f, 0.3f), float timeToLive = 0); 56 63 57 void createTimer(); 58 void timerCallback(); 64 void createTimer(); //TODO: Can this be made private, too? 65 void timerCallback(); //TODO: This should really be private. 59 66 60 67 inline float getTriggerDistance() const … … 65 72 inline BaseItem* getItem() const 66 73 { return this->item_; } 74 //TODO: Needs to be public? 67 75 inline void setItem(BaseItem* item) 68 76 { this->item_ = item; } … … 70 78 inline float getTimeToLive() const 71 79 { return this->timeToLive_; } 80 //TODO: Needs to be public? 72 81 inline void setTimeToLive(float time) 73 82 { this->timeToLive_ = time; } -
code/branches/pickup/src/orxonox/pickup/EquipmentItem.cc
r5781 r5902 38 38 { 39 39 /** 40 41 40 @brief Constructor. Registers the EquipmentItem. 41 @param creator Pointer to the object which created this item. 42 42 */ 43 43 EquipmentItem::EquipmentItem(BaseObject* creator) : BaseItem(creator) -
code/branches/pickup/src/orxonox/pickup/EquipmentItem.h
r5781 r5902 41 41 { 42 42 /** 43 44 43 @brief Base class for all equipment-type items. 44 @author Daniel 'Huty' Haggenmueller 45 45 */ 46 46 class _OrxonoxExport EquipmentItem : public BaseItem 47 47 { 48 public: 49 EquipmentItem(BaseObject* creator); 50 virtual ~EquipmentItem() {} 48 //TODO: What is this class for? 49 //Probably falls under UsableItem or PassiveItem 50 public: 51 EquipmentItem(BaseObject* creator); 52 virtual ~EquipmentItem() {} 53 54 55 51 56 }; 52 57 } -
code/branches/pickup/src/orxonox/pickup/ModifierPickup.cc
r5781 r5902 43 43 44 44 /** 45 @brief Constructor. Registers the ModifierPickup. 46 @param creator Pointer to the object which created this item. 45 @brief 46 Constructor. Registers the ModifierPickup. 47 @param creator 48 Pointer to the object which created this item. 47 49 */ 48 50 ModifierPickup::ModifierPickup(BaseObject* creator) : PassiveItem(creator) … … 52 54 this->duration_ = 0.0f; 53 55 } 54 //! Deconstructor. 56 57 /** 58 @brief 59 Destructor. 60 */ 55 61 ModifierPickup::~ModifierPickup() 56 62 { 57 } 58 /** 59 @brief Method for loading information from a level file. 60 @param element XMLElement from which to read the data. 61 @param mode XMLPort mode to use. 62 */ 63 64 } 65 66 /** 67 @brief 68 Method for loading information from a level file. 69 @param element 70 XMLElement from which to read the data. 71 @param mode 72 XMLPort mode to use. 73 */ 74 //TODO: Comments: params can probably be ommitted. 63 75 void ModifierPickup::XMLPort(Element& element, XMLPort::Mode mode) 64 76 { … … 73 85 XMLPortParamTemplate(ModifierPickup, "accelerationMulti", setMultiplicativeAcceleration, getMultiplicativeAcceleration, element, mode, float); 74 86 } 75 /** 76 @brief 77 Invoked when a pawn picks up the pickup. 78 79 Adds the modifiers to the pawn and sets a timer (if effect is limited) 80 if the pickup could be added to the pawn's PickupCollection. 81 82 @param pawn Pawn which picked up the pickup. 83 @return Returns whether the pickup was able to be added to the pawn. 87 88 /** 89 @brief 90 Invoked when a pawn picks up the pickup. 91 92 Adds the modifiers to the pawn and sets a timer (if effect is limited) 93 if the pickup could be added to the pawn's PickupCollection. 94 95 @param pawn 96 Pawn which picked up the pickup. 97 @return 98 Returns whether the pickup was able to be added to the pawn. 84 99 */ 85 100 bool ModifierPickup::pickedUp(Pawn* pawn) … … 110 125 return false; 111 126 } 112 /** 113 @brief 114 Invoked when a pawn drops the pickup. 115 116 Removes the modifiers from the pawn if the pickup 117 was successfully removed from it's PickupCollection. 118 119 @param pawn Pawn which dropped the pickup. 120 @return Returns whether the pickup could be removed. 127 128 /** 129 @brief 130 Invoked when a pawn drops the pickup. 131 132 Removes the modifiers from the pawn if the pickup 133 was successfully removed from it's PickupCollection. 134 135 @param pawn 136 Pawn which dropped the pickup. 137 @return 138 Returns whether the pickup could be removed. 121 139 */ 122 140 bool ModifierPickup::dropped(Pawn* pawn) … … 145 163 return false; 146 164 } 147 /** 148 @brief Invoked when the timer finished, calls dropped(). 149 */ 165 166 /** 167 @brief Invoked when the timer finished, calls dropped(). 168 */ 169 //TODO: Other name for function? 150 170 void ModifierPickup::timerCallback(Pawn* pawn) 151 171 { … … 153 173 COUT(2) << "Failed to remove modifier pickup after the timer ran out!" << std::endl; 154 174 } 155 /** 156 @brief Gets the additive modifier of a given type. 157 @param type ModifierType for which to return the modifier. 158 @return Returns the additive modifier for type (or 0 if not exists). 175 176 /** 177 @brief 178 Gets the additive modifier of a given type. 179 @param type 180 ModifierType for which to return the modifier. 181 @return 182 Returns the additive modifier for type (or 0 if not exists). 159 183 */ 160 184 float ModifierPickup::getAdditiveModifier(ModifierType::Value type) const … … 166 190 return 0.0f; 167 191 } 168 /** 169 @brief Gets the multiplicative modifier of a given type. 170 @param type ModifierType for which to return the modifier. 171 @return Returns the multiplicative modifier for type (or 1 if not exists). 192 193 /** 194 @brief 195 Gets the multiplicative modifier of a given type. 196 @param type 197 ModifierType for which to return the modifier. 198 @return 199 Returns the multiplicative modifier for type (or 1 if not exists). 172 200 */ 173 201 float ModifierPickup::getMultiplicativeModifier(ModifierType::Value type) const … … 179 207 return 1.0f; 180 208 } 181 /** 182 @brief Gets the additive modifier of a given type. 183 @param type ModifierType for which to return the modifier. 184 @param value The new additive modifier for type. 209 210 /** 211 @brief 212 Gets the additive modifier of a given type. 213 @param type 214 ModifierType for which to return the modifier. 215 @param value 216 The new additive modifier for type. 185 217 */ 186 218 void ModifierPickup::setAdditiveModifier(ModifierType::Value type, float value) … … 191 223 this->additiveModifiers_[type] = value; 192 224 } 193 /** 194 @brief Gets the multiplicative modifier of a given type. 195 @param type ModifierType for which to return the modifier. 196 @param value The new multiplicative modifier for type. 225 226 /** 227 @brief 228 Gets the multiplicative modifier of a given type. 229 @param type 230 ModifierType for which to return the modifier. 231 @param value 232 The new multiplicative modifier for type. 197 233 */ 198 234 void ModifierPickup::setMultiplicativeModifier(ModifierType::Value type, float value) … … 203 239 this->multiplicativeModifiers_[type] = value; 204 240 } 241 205 242 } -
code/branches/pickup/src/orxonox/pickup/ModifierPickup.h
r5781 r5902 47 47 { 48 48 /** 49 50 49 @brief Class for a (temporary) modifier effect. 50 @author Daniel 'Huty' Haggenmueller 51 51 */ 52 //TODO: More elaborate comments. 52 53 class _OrxonoxExport ModifierPickup : public PassiveItem 53 54 { 54 public: 55 ModifierPickup(BaseObject* creator); 56 virtual ~ModifierPickup(); 55 //TODO: What does being derived from PassiveItem add exactly? Probably better to kill PassiveItem and just derive from BaseItem. 56 //Include ModifierType here, no additional header file needed for that, imo. 57 public: 58 ModifierPickup(BaseObject* creator); 59 virtual ~ModifierPickup(); 57 60 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);//!< To create a ModifierPickup through the level file.61 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< To create a ModifierPickup through the level file. 59 62 60 virtual bool pickedUp(Pawn* pawn);//!< Override of the BaseItem::pickedUp() method.61 virtual bool dropped(Pawn* pawn);//!< Override of the BaseItem::dropped() method63 virtual bool pickedUp(Pawn* pawn); //!< Override of the BaseItem::pickedUp() method. 64 virtual bool dropped(Pawn* pawn); //!< Override of the BaseItem::dropped() method 62 65 63 virtual int getMaxCarryAmount(){ return INT_MAX; } //!< Allow the player to carry infinite ModPickups 66 //TODO: Where does this INT_MAX come from? Comment. 67 virtual int getMaxCarryAmount() //!< Allow the player to carry infinite ModPickups 68 { return INT_MAX; } 64 69 65 /**70 /** 66 71 @brief Get the duration of this pickup. 67 72 @return Returns how long the effect holds on. 68 */69 inline float getDuration() const70 { return this->duration_; }71 /**73 */ 74 inline float getDuration() const 75 { return this->duration_; } 76 /** 72 77 @brief Set the duration of this pickup. 73 78 @param duration How long the effect should hold. 74 */ 75 inline void setDuration(float duration) 76 { this->duration_ = duration; } 79 */ 80 //TODO: Better be private? 81 inline void setDuration(float duration) 82 { this->duration_ = duration; } 77 83 78 /** 84 //TODO: Shouldn't these all be seperate pickup items? But, then, would this class really be needed? What does it actually add? 85 //Duration! Thus create two virtual functions addEffect() and removeEffect(). 86 //Export the ideas here into seperate, individual subclasses. 87 //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? 88 //Specify what ModifierItem should do exactly. If the limited duration is the core functionality, another name would probably more fitting. 89 //Perhaps, limited effect duration could also just be another feature of BaseItem... 90 /** 79 91 @brief Get the amount of damage this pickup adds. 80 92 @return Returns how much damage this pickup adds. 81 */82 inline float getAdditiveDamage() const83 { return this->getAdditiveModifier(ModifierType::Damage); }84 /**93 */ 94 inline float getAdditiveDamage() const 95 { return this->getAdditiveModifier(ModifierType::Damage); } 96 /** 85 97 @brief Get the factor by which this pickup multiplies the damage. 86 98 @return Returns the factor by which to multiply damage. 87 */88 inline float getMultiplicativeDamage() const89 { return this->getMultiplicativeModifier(ModifierType::Damage); }99 */ 100 inline float getMultiplicativeDamage() const 101 { return this->getMultiplicativeModifier(ModifierType::Damage); } 90 102 91 /**103 /** 92 104 @brief Set the amount of damage this pickup adds. 93 105 @param value How much damage this pickup adds. 94 */95 inline void setAdditiveDamage(float value)96 { this->setAdditiveModifier(ModifierType::Damage, value); }97 /**106 */ 107 inline void setAdditiveDamage(float value) 108 { this->setAdditiveModifier(ModifierType::Damage, value); } 109 /** 98 110 @brief Set the factor by which this pickup multiplies the damage. 99 111 @param value Factor by which to multiply damage. 100 */101 inline void setMultiplicativeDamage(float value)102 { this->setMultiplicativeModifier(ModifierType::Damage, value); }112 */ 113 inline void setMultiplicativeDamage(float value) 114 { this->setMultiplicativeModifier(ModifierType::Damage, value); } 103 115 104 /**116 /** 105 117 @brief Get the amount of acceleration this pickup adds. 106 118 @return Returns how much acceleration this pickup adds. 107 */108 inline float getAdditiveAcceleration() const109 { return this->getAdditiveModifier(ModifierType::Acceleration); }110 /**119 */ 120 inline float getAdditiveAcceleration() const 121 { return this->getAdditiveModifier(ModifierType::Acceleration); } 122 /** 111 123 @brief Get the factor by which this pickup multiplies the acceleration. 112 124 @return Returns the factor by which to multiply acceleration. 113 */114 inline float getMultiplicativeAcceleration() const115 { return this->getMultiplicativeModifier(ModifierType::Acceleration); }125 */ 126 inline float getMultiplicativeAcceleration() const 127 { return this->getMultiplicativeModifier(ModifierType::Acceleration); } 116 128 117 /**129 /** 118 130 @brief Set the amount of acceleration this pickup adds. 119 131 @param value How much acceleration this pickup adds. 120 */121 inline void setAdditiveAcceleration(float value)122 { this->setAdditiveModifier(ModifierType::Acceleration, value); }123 /**132 */ 133 inline void setAdditiveAcceleration(float value) 134 { this->setAdditiveModifier(ModifierType::Acceleration, value); } 135 /** 124 136 @brief Set the factor by which this pickup multiplies the acceleration. 125 137 @param value Factor by which to multiply acceleration. 126 */127 inline void setMultiplicativeAcceleration(float value)128 { this->setMultiplicativeModifier(ModifierType::Acceleration, value); }138 */ 139 inline void setMultiplicativeAcceleration(float value) 140 { this->setMultiplicativeModifier(ModifierType::Acceleration, value); } 129 141 130 void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. 131 private: 132 float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType. 133 float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType. 134 void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType. 135 void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType 142 //TODO: Make private? 143 void timerCallback(Pawn* pawn); //!< Method called when the timer runs out. 144 private: 145 float getAdditiveModifier(ModifierType::Value type) const; //!< Get the additive modifier for a given ModifierType. 146 float getMultiplicativeModifier(ModifierType::Value type) const; //!< Get the multiplicative modifier for a given ModifierType. 147 void setAdditiveModifier(ModifierType::Value type, float value); //!< Set the additive modifier for a given ModifierType. 148 void setMultiplicativeModifier(ModifierType::Value type, float value); //!< Set the multiplicative modifier for a given ModifierType 136 149 137 std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType.138 std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType.150 std::map<ModifierType::Value, float> additiveModifiers_; //!< Map of additive modifiers, indexed by ModifierType. 151 std::map<ModifierType::Value, float> multiplicativeModifiers_; //!< Map of multiplicative modifiers, indexed by ModifierType. 139 152 140 float duration_; //!< Duration of this pickup's effect (0 for unlimited).141 Timer<ModifierPickup> timer_; //!< Timer used if the pickup's effect has a time limit.153 float duration_; //!< Duration of this pickup's effect (0 for unlimited). 154 Timer<ModifierPickup> timer_; //!< Timer used if the pickup's effect has a time limit. 142 155 }; 143 156 } -
code/branches/pickup/src/orxonox/pickup/ModifierType.h
r5781 r5902 39 39 namespace orxonox 40 40 { 41 //TODO: Merge with ModifierPickup. 41 42 namespace ModifierType 42 43 { -
code/branches/pickup/src/orxonox/pickup/PassiveItem.cc
r5781 r5902 33 33 { 34 34 /** 35 36 35 @brief Constructor. Registers the PassiveItem. 36 @param creator Pointer to the object which created this item. 37 37 */ 38 38 PassiveItem::PassiveItem(BaseObject* creator) : BaseItem(creator) -
code/branches/pickup/src/orxonox/pickup/PassiveItem.h
r5781 r5902 41 41 { 42 42 /** 43 44 43 @brief Base class for all passive items. 44 @author Daniel 'Huty' Haggenmueller 45 45 */ 46 46 class _OrxonoxExport PassiveItem : public BaseItem 47 47 { 48 public: 49 PassiveItem(BaseObject* creator); 50 virtual ~PassiveItem() {} 48 //TODO: What is this Class for. Where is ActiveItem? 49 //Rename it InstantItem? 50 public: 51 PassiveItem(BaseObject* creator); 52 virtual ~PassiveItem() {} 53 51 54 }; 52 55 } -
code/branches/pickup/src/orxonox/pickup/PickupCollection.h
r5781 r5902 47 47 { 48 48 /** 49 50 49 @brief PickupCollection for organising items. 50 @author Daniel 'Huty' Haggenmueller 51 51 */ 52 52 class _OrxonoxExport PickupCollection 53 53 { 54 public: 55 PickupCollection(); 54 public: 55 //TODO: Should probably be derived from OrxonoxClass??? 56 PickupCollection(); 56 57 57 bool add(BaseItem* item); //!< Add an item to the collection.58 bool add(BaseItem* item); //!< Add an item to the collection. 58 59 59 bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item.60 bool checkSlot(BaseItem* item); //!< Check if there's a free slot in the collection for an item. 60 61 61 void clear(); //!< Empty the collection62 bool contains(BaseItem* item, bool anyOfType = false); //!< Check if the collection contains an item.62 void clear(); //!< Empty the collection 63 bool contains(BaseItem* item, bool anyOfType = false); //!< Check if the collection contains an item. 63 64 64 void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection.65 void remove(BaseItem* item, bool removeAllOfType = false); //!< Remove an item from the collection. 65 66 66 void useItem(); //!< Use the first usable item. 67 void useItem(UsableItem* item); //!< Use a usable item. 67 //TODO: What's up with that? 68 void useItem(); //!< Use the first usable item. 69 void useItem(UsableItem* item); //!< Use a usable item. 68 70 69 void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier. 70 void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier. 71 //TODO: This really shouldn't be here. It's nbot the Collections business to know about stuff like that. 72 void addAdditiveModifier(ModifierType::Value type, float value); //!< Add an additive modifier. 73 void addMultiplicativeModifier(ModifierType::Value type, float value); //!< Add a multiplicative modifier. 71 74 72 float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier.73 float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier.75 float getAdditiveModifier(ModifierType::Value type); //!< Get total additive modifier. 76 float getMultiplicativeModifier(ModifierType::Value type); //!< Get total multiplicative modifier. 74 77 75 void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier.76 void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier.78 void removeAdditiveModifier(ModifierType::Value type, float value); //!< Remove an additive modifier. 79 void removeMultiplicativeModifier(ModifierType::Value type, float value); //!< Remove a multiplicative modifier. 77 80 78 float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float.79 Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3.81 float processModifiers(ModifierType::Value type, float inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a float. 82 Vector3 processModifiers(ModifierType::Value type, Vector3 inputValue, bool addBeforeMultiplication = false); //!< Apply the modifiers to a Vector3. 80 83 81 /**82 @brief Get the map of contained items.83 @return The map of items.84 */85 std::multimap<std::string, BaseItem*> getItems() const86 { return this->items_; }84 /** 85 @brief Get the map of contained items. 86 @return The map of items. 87 */ 88 std::multimap<std::string, BaseItem*> getItems() const 89 { return this->items_; } 87 90 88 /**89 @brief Get the owner of the PickupCollection.90 @return Returns the pawn which owns the PickupCollection.91 */92 inline Pawn* getOwner() const93 { return this->owner_; }94 /**95 @brief Set the owner of the PickupCollection.96 @param owner The new Pawn which owns the PickupCollection.97 */98 inline void setOwner(Pawn* owner)99 { this->owner_ = owner; }91 /** 92 @brief Get the owner of the PickupCollection. 93 @return Returns the pawn which owns the PickupCollection. 94 */ 95 inline Pawn* getOwner() const 96 { return this->owner_; } 97 /** 98 @brief Set the owner of the PickupCollection. 99 @param owner The new Pawn which owns the PickupCollection. 100 */ 101 inline void setOwner(Pawn* owner) 102 { this->owner_ = owner; } 100 103 101 inline UsableItem* getCurrentUsable()102 { return this->currentUsable_; };103 inline void setCurrentUsable(UsableItem* usable)104 { this->currentUsable_ = usable; }104 inline UsableItem* getCurrentUsable() 105 { return this->currentUsable_; }; 106 inline void setCurrentUsable(UsableItem* usable) 107 { this->currentUsable_ = usable; } 105 108 106 std::deque<EquipmentItem*> getEquipmentItems(); //!< Get a list of equipment-type items.107 std::deque<PassiveItem*> getPassiveItems(); //!< Get a list of passive items.108 std::deque<UsableItem*> getUsableItems(); //!< Get a list of usable items.109 private:110 Pawn* owner_; //!< The owner of the PickupCollection.111 UsableItem* currentUsable_;109 std::deque<EquipmentItem*> getEquipmentItems(); //!< Get a list of equipment-type items. 110 std::deque<PassiveItem*> getPassiveItems(); //!< Get a list of passive items. 111 std::deque<UsableItem*> getUsableItems(); //!< Get a list of usable items. 112 private: 113 Pawn* owner_; //!< The owner of the PickupCollection. 114 UsableItem* currentUsable_; 112 115 113 bool bBlockRemovals_; //!< Whether to block direct removals through remove().116 bool bBlockRemovals_; //!< Whether to block direct removals through remove(). 114 117 115 std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType).116 std::multimap<ModifierType::Value, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType).118 std::multimap<ModifierType::Value, float> additiveModifiers_; //!< Contains additive modifiers (indexed by ModifierType). 119 std::multimap<ModifierType::Value, float> multiplicativeModifiers_; //!< Contains multiplicative modifiers (indexed by ModifierType). 117 120 118 std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items).121 std::multimap<std::string, BaseItem*> items_; //!< Map of items in the collection (indexed by pickupIdentifier of the items). 119 122 }; 120 123 } -
code/branches/pickup/src/orxonox/pickup/PickupInventory.cc
r5781 r5902 52 52 53 53 PickupInventory* PickupInventory::pickupInventory_s = NULL; 54 55 //TODO: Comment. 56 57 /** 58 @brief 59 Get a Pointer to the PickupInventory Singleton. 60 @return 61 A Pointer to the PickupInventory. 62 */ 63 //TODO: Make SingeltonPtr? 54 64 PickupInventory* PickupInventory::getSingleton() 55 65 { … … 60 70 } 61 71 72 /** 73 @brief 74 Constructor. 75 */ 62 76 PickupInventory::PickupInventory() 63 77 { 64 this->bInventoryVisible_ = false; 65 this->visibleEquipmentWindows_ = this->visibleUsableWIndows_ = 0; 78 //TODO: Maybe some abstraction for the usableWindows, e.g. push and pop... 79 //RegisterObject() ? In some other Class, too. Which? 80 this->bInventoryVisible_ = false; //TODO: If OrxonoxClass, this should already be there... 81 this->visibleEquipmentWindows_ = this->visibleUsableWindows_ = 0; 66 82 67 83 // Create some windows to avoid creating them while playing … … 77 93 this->createdEquipmentWindows_ = this->createdUsableWindows_ = 10; 78 94 } 95 96 /** 97 @brief 98 Destructor. 99 */ 100 //TODO: Destroy something? 79 101 PickupInventory::~PickupInventory() 80 102 { 81 103 } 82 104 83 84 85 void PickupInventory::toggleInventory() 105 /** 106 @brief 107 Toggles the visibility of the inventory. 108 */ 109 /*static*/ void PickupInventory::toggleInventory() 86 110 { 87 111 if(PickupInventory::getSingleton()->isVisible()) { … … 99 123 } 100 124 125 /** 126 @brief 127 128 */ 101 129 unsigned int PickupInventory::getCurrentUsableIndex() 102 130 { … … 115 143 return 0; 116 144 } 145 117 146 bool PickupInventory::isCurrentUsable(const BaseItem* item) 118 147 { … … 123 152 return false; 124 153 } 154 125 155 void PickupInventory::selectUsable(unsigned int i) 126 156 { … … 142 172 return 0; 143 173 } 174 144 175 unsigned int PickupInventory::getUsableCount() 145 176 { … … 150 181 return 0; 151 182 } 183 152 184 unsigned int PickupInventory::getPassiveCount() 153 185 { … … 158 190 return 0; 159 191 } 192 160 193 BaseItem* PickupInventory::getEquipmentItem(unsigned int i) 161 194 { … … 170 203 return NULL; 171 204 } 205 172 206 BaseItem* PickupInventory::getUsableItem(unsigned int i) 173 207 { … … 182 216 return NULL; 183 217 } 218 184 219 BaseItem* PickupInventory::getPassiveItem(unsigned int i) 185 220 { … … 225 260 equipPane->removeChildWindow("orxonox/Inventory/Items/equ/" + id.str());*/ 226 261 } 227 for(unsigned int i = 0; i < this->visibleUsableW Indows_; i++)262 for(unsigned int i = 0; i < this->visibleUsableWindows_; i++) 228 263 { 229 264 std::ostringstream id; … … 239 274 } 240 275 } 276 241 277 void PickupInventory::updateTabs(CEGUI::WindowManager *winMgr, CEGUI::Window *equipWindow, CEGUI::Window *usableWindow) 242 278 { … … 269 305 } 270 306 } 307 271 308 void PickupInventory::updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target) 272 309 { … … 296 333 PickupInventory::setWindowProperties(winMgr, target, id.str(), item, colour); 297 334 } 298 this->visibleUsableW Indows_ = items.size();335 this->visibleUsableWindows_ = items.size(); 299 336 } 300 337 } … … 326 363 btn->setVisible(false); 327 364 } 365 328 366 void PickupInventory::setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour) 329 367 { … … 350 388 target->addChildWindow(btn); 351 389 } 390 352 391 } -
code/branches/pickup/src/orxonox/pickup/PickupInventory.h
r5781 r5902 44 44 { 45 45 /** 46 47 46 @brief Static class for the inventory GUI window. 47 @author Daniel 'Huty' Haggenmueller 48 48 */ 49 49 class _OrxonoxExport PickupInventory 50 50 { 51 51 // tolua_end 52 public: 53 PickupInventory(); 54 virtual ~PickupInventory(); 52 public: 53 //TODO: Be derived from OrxonoxClass and ScopedSingleton. 54 //Make some methods private? 55 PickupInventory(); 56 virtual ~PickupInventory(); 55 57 56 static PickupInventory* getSingleton(); // tolua_export58 static PickupInventory* getSingleton(); // tolua_export 57 59 58 static void toggleInventory(); // tolua_export60 static void toggleInventory(); // tolua_export 59 61 60 static unsigned int getEquipmentCount(); // tolua_export61 static unsigned int getUsableCount(); // tolua_export62 static unsigned int getPassiveCount(); // tolua_export62 static unsigned int getEquipmentCount(); // tolua_export 63 static unsigned int getUsableCount(); // tolua_export 64 static unsigned int getPassiveCount(); // tolua_export 63 65 64 static unsigned int getCurrentUsableIndex(); // tolua_export65 static bool isCurrentUsable(const BaseItem* item); // tolua_export66 static void selectUsable(unsigned int i); // tolua_export66 static unsigned int getCurrentUsableIndex(); // tolua_export 67 static bool isCurrentUsable(const BaseItem* item); // tolua_export 68 static void selectUsable(unsigned int i); // tolua_export 67 69 68 static BaseItem* getEquipmentItem(unsigned int i); // tolua_export69 static BaseItem* getUsableItem(unsigned int i); // tolua_export70 static BaseItem* getPassiveItem(unsigned int i); // tolua_export70 static BaseItem* getEquipmentItem(unsigned int i); // tolua_export 71 static BaseItem* getUsableItem(unsigned int i); // tolua_export 72 static BaseItem* getPassiveItem(unsigned int i); // tolua_export 71 73 72 static std::string getImageForItem(const BaseItem* item); // tolua_export74 static std::string getImageForItem(const BaseItem* item); // tolua_export 73 75 74 void clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane); // tolua_export75 void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export76 void clearInventory(CEGUI::WindowManager* winMgr, CEGUI::Window* equipPane, CEGUI::Window* usablePane); // tolua_export 77 void updateTabs(CEGUI::WindowManager* winMgr, CEGUI::Window* equipWindow, CEGUI::Window* usableWindow); // tolua_export 76 78 77 void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target);78 void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target);79 void updateEquipment(CEGUI::WindowManager* winMgr, CEGUI::Window* target); 80 void updateUsable(CEGUI::WindowManager* winMgr, CEGUI::Window* target); 79 81 80 static void createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y);81 static void setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour);82 static void createItemWindows(CEGUI::WindowManager* winMgr, const std::string& id, int x, int y); 83 static void setWindowProperties(CEGUI::WindowManager* winMgr, CEGUI::Window* target, const std::string& id, const BaseItem* item, const std::string& textColour); 82 84 83 const bool isVisible() const84 { return this->bInventoryVisible_; }85 void setVisible(bool visible)86 { this->bInventoryVisible_ = visible; }87 private:88 bool bInventoryVisible_;89 unsigned int createdEquipmentWindows_;90 unsigned int createdUsableWindows_;91 unsigned int visibleEquipmentWindows_;92 unsigned int visibleUsableWIndows_;85 const bool isVisible() const 86 { return this->bInventoryVisible_; } 87 void setVisible(bool visible) 88 { this->bInventoryVisible_ = visible; } 89 private: 90 bool bInventoryVisible_; 91 unsigned int createdEquipmentWindows_; 92 unsigned int createdUsableWindows_; 93 unsigned int visibleEquipmentWindows_; 94 unsigned int visibleUsableWindows_; 93 95 94 static PickupInventory* pickupInventory_s;96 static PickupInventory* pickupInventory_s; 95 97 }; // tolua_export 96 98 } // tolua_export -
code/branches/pickup/src/orxonox/pickup/PickupSpawner.cc
r5781 r5902 53 53 54 54 /** 55 @brief Constructor. Registers the PickupSpawner. 56 @param creator Pointer to the object which created this item. 55 @brief 56 Constructor. Registers the PickupSpawner. 57 @param creator 58 Pointer to the object which created this item. 57 59 */ 58 60 PickupSpawner::PickupSpawner(BaseObject* creator) : StaticEntity(creator) … … 65 67 this->tickSum_ = 0.0f; 66 68 } 67 //! Deconstructor. 69 70 /** 71 @brief 72 Destructor. 73 */ 68 74 PickupSpawner::~PickupSpawner() 69 75 { 70 } 71 /** 72 @brief Method for creating a PickupSpawner through XML. 73 @param xmlelement XML element which contains the PickupSpawner. 74 @param mode XMLPort mode. 76 77 } 78 79 /** 80 @brief 81 Method for creating a PickupSpawner through XML. 82 @param xmlelement 83 XML element which contains the PickupSpawner. 84 @param mode 85 XMLPort mode. 75 86 */ 76 87 void PickupSpawner::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 82 93 XMLPortParam(PickupSpawner, "respawnTime", setRespawnTime, getRespawnTime, xmlelement, mode); 83 94 95 //TODO: Kill hack. 84 96 // HACKs 85 97 // Load the GUI image as soon as the PickupSpawner gets loaded … … 100 112 PickupInventory::getSingleton(); 101 113 } 102 /** 103 @brief Invoked when the activity has changed. Sets visibility of attached objects. 114 115 /** 116 @brief 117 Invoked when the activity has changed. Sets visibility of attached objects. 104 118 */ 105 119 void PickupSpawner::changedActivity() … … 110 124 (*it)->setVisible(this->isActive()); 111 125 } 112 /** 113 @brief Set the template name of the item to spawn, also loads the template. 114 @param name Name of the new template. 126 127 /** 128 @brief 129 Set the template name of the item to spawn, also loads the template. 130 @param name 131 Name of the new template. 115 132 */ 116 133 void PickupSpawner::setItemTemplateName(const std::string& name) … … 119 136 this->itemTemplate_ = Template::getTemplate(name); 120 137 } 121 /** 122 @brief Tick, checks if any Pawn is close enough to trigger. 123 @param dt Time since last tick. 124 */ 138 139 /** 140 @brief 141 Tick, checks if any Pawn is close enough to trigger. 142 @param dt 143 Time since last tick. 144 */ 145 //TODO: Replace this with a real DistanceTrigger. 125 146 void PickupSpawner::tick(float dt) 126 147 { … … 140 161 } 141 162 } 142 /** 143 @brief 144 Trigger the PickupSpawner. 145 146 Adds the pickup to the Pawn that triggered, 147 sets the timer to re-activate and deactives the PickupSpawner. 148 149 @param pawn Pawn which triggered the PickupSpawner. 163 164 /** 165 @brief 166 Trigger the PickupSpawner. 167 168 Adds the pickup to the Pawn that triggered, 169 sets the timer to re-activate and deactives the PickupSpawner. 170 171 @param pawn 172 Pawn which triggered the PickupSpawner. 150 173 */ 151 174 void PickupSpawner::trigger(Pawn* pawn) … … 178 201 } 179 202 } 180 /** 181 @brief Invoked by the timer, re-activates the PickupSpawner. 203 204 /** 205 @brief 206 Invoked by the timer, re-activates the PickupSpawner. 182 207 */ 183 208 void PickupSpawner::respawnTimerCallback() -
code/branches/pickup/src/orxonox/pickup/PickupSpawner.h
r5781 r5902 50 50 class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable 51 51 { 52 public: 53 PickupSpawner(BaseObject* creator); 54 virtual ~PickupSpawner(); 52 public: 53 //TODO: Add limit of items spawned here. Also possibility to spawn collections? 54 PickupSpawner(BaseObject* creator); 55 virtual ~PickupSpawner(); 55 56 56 virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).57 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML.58 virtual void tick(float dt);57 virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty). 58 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PickupSpawner through XML. 59 virtual void tick(float dt); 59 60 60 void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.61 void respawnTimerCallback(); //!< Method called when the timer runs out.61 void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough. 62 void respawnTimerCallback(); //!< Method called when the timer runs out. 62 63 63 /**64 /** 64 65 @brief Get the template name for the item to spawn. 65 66 @return Returns the name of the template of the item to spawn. 66 */67 inline const std::string& getItemTemplateName() const68 { return this->itemTemplateName_; }69 void setItemTemplateName(const std::string& name); //!< Set the template name of the item to spawn.67 */ 68 inline const std::string& getItemTemplateName() const 69 { return this->itemTemplateName_; } 70 void setItemTemplateName(const std::string& name); //!< Set the template name of the item to spawn. 70 71 71 /**72 @brief Get the template for the item to spawn.73 @return Returns the template of the item to spawn.74 */75 inline Template* getItemTemplate() const76 { return this->itemTemplate_; }72 /** 73 @brief Get the template for the item to spawn. 74 @return Returns the template of the item to spawn. 75 */ 76 inline Template* getItemTemplate() const 77 { return this->itemTemplate_; } 77 78 78 /**79 @brief Get the distance in which to trigger.80 @return Returns the distance in which this gets triggered.81 */82 inline float getTriggerDistance() const83 { return this->triggerDistance_; }84 /**85 @brief Set the distance in which to trigger.86 @param value The new distance in which to trigger.87 */88 inline void setTriggerDistance(float value)89 { this->triggerDistance_ = value; }79 /** 80 @brief Get the distance in which to trigger. 81 @return Returns the distance in which this gets triggered. 82 */ 83 inline float getTriggerDistance() const 84 { return this->triggerDistance_; } 85 /** 86 @brief Set the distance in which to trigger. 87 @param value The new distance in which to trigger. 88 */ 89 inline void setTriggerDistance(float value) 90 { this->triggerDistance_ = value; } 90 91 91 /**92 @brief Get the time to respawn.93 @returns Returns the time after which this gets re-actived.94 */95 inline float getRespawnTime() const96 { return this->respawnTime_; }97 /**98 @brief Set the time to respawn.99 @param time New time after which this gets re-actived.100 */101 inline void setRespawnTime(float time)102 { this->respawnTime_ = time; }103 private:104 std::string itemTemplateName_; //!< Template name of the item to spawn.105 Template* itemTemplate_; //!< Template of the item to spawn.92 /** 93 @brief Get the time to respawn. 94 @returns Returns the time after which this gets re-actived. 95 */ 96 inline float getRespawnTime() const 97 { return this->respawnTime_; } 98 /** 99 @brief Set the time to respawn. 100 @param time New time after which this gets re-actived. 101 */ 102 inline void setRespawnTime(float time) 103 { this->respawnTime_ = time; } 104 private: 105 std::string itemTemplateName_; //!< Template name of the item to spawn. 106 Template* itemTemplate_; //!< Template of the item to spawn. 106 107 107 float triggerDistance_; //!< Distance in which this gets triggered.108 float triggerDistance_; //!< Distance in which this gets triggered. 108 109 109 /* Pickup animation */110 float tickSum_; //!< Adds up tick to use in sine movement111 static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down112 static const float bounceDistance_s; //!< Distance the pickup bounces up and down113 static const float rotationSpeed_s; //!< Rotation speed of pickup110 /* Pickup animation */ 111 float tickSum_; //!< Adds up tick to use in sine movement 112 static const float bounceSpeed_s; //!< Speed of pickup to bounce up and down 113 static const float bounceDistance_s; //!< Distance the pickup bounces up and down 114 static const float rotationSpeed_s; //!< Rotation speed of pickup 114 115 115 float respawnTime_; //!< Time after which this gets re-actived.116 Timer<PickupSpawner> respawnTimer_; //!< Timer used for re-activating.116 float respawnTime_; //!< Time after which this gets re-actived. 117 Timer<PickupSpawner> respawnTimer_; //!< Timer used for re-activating. 117 118 }; 118 119 } -
code/branches/pickup/src/orxonox/pickup/UsableItem.cc
r5781 r5902 38 38 { 39 39 /** 40 41 40 @brief Constructor. Registers the UsableItem. 41 @param creator Pointer to the object which created this item. 42 42 */ 43 43 UsableItem::UsableItem(BaseObject* creator) : BaseItem(creator) -
code/branches/pickup/src/orxonox/pickup/UsableItem.h
r5781 r5902 46 46 class _OrxonoxExport UsableItem : public BaseItem 47 47 { 48 public: 49 UsableItem(BaseObject* creator); 50 virtual ~UsableItem() { } 48 //TODO: What is this exactly? 49 public: 50 UsableItem(BaseObject* creator); 51 virtual ~UsableItem() { } 51 52 52 /**53 @brief Method invoked when the item is being used.54 @param pawn Pawn which is using the item.55 */56 virtual void used(Pawn* pawn) { }53 /** 54 @brief Method invoked when the item is being used. 55 @param pawn Pawn which is using the item. 56 */ 57 virtual void used(Pawn* pawn) { } 57 58 }; 58 59 } -
code/branches/pickup/src/orxonox/pickup/items/HealthImmediate.cc
r5781 r5902 59 59 } 60 60 61 //TODO: Should be destroyed anyways... 61 62 bool HealthImmediate::pickedUp(Pawn* pawn) 62 63 { -
code/branches/pickup/src/orxonox/pickup/items/HealthImmediate.h
r5781 r5902 45 45 class _OrxonoxExport HealthImmediate : public PassiveItem 46 46 { 47 public: 48 HealthImmediate(BaseObject* creator); 49 virtual ~HealthImmediate(); 47 //TODO: Comment. 48 //Does this get destroyed, when the healt is delivered? It seems to me it doesn't. 49 public: 50 HealthImmediate(BaseObject* creator); 51 virtual ~HealthImmediate(); 50 52 51 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);53 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 54 53 virtual bool pickedUp(Pawn* pawn);55 virtual bool pickedUp(Pawn* pawn); 54 56 55 inline float getRecoveredHealth() const56 { return this->recoveredHealth_; }57 inline void setRecoveredHealth(float recovery)58 { this->recoveredHealth_ = recovery; }57 inline float getRecoveredHealth() const 58 { return this->recoveredHealth_; } 59 inline void setRecoveredHealth(float recovery) 60 { this->recoveredHealth_ = recovery; } 59 61 60 private:61 float recoveredHealth_;62 private: 63 float recoveredHealth_; 62 64 }; 63 65 } -
code/branches/pickup/src/orxonox/pickup/items/HealthUsable.cc
r5781 r5902 45 45 46 46 /** 47 48 47 @brief Constructor 48 @param creator Object that created this item. 49 49 */ 50 50 HealthUsable::HealthUsable(BaseObject* creator) : UsableItem(creator) … … 54 54 this->recoveredHealth_ = 0; 55 55 } 56 56 57 //! Deconstructor 57 58 HealthUsable::~HealthUsable() 58 59 { 59 60 } 61 60 62 /** 61 62 63 63 @brief XMLPort for Jump. 64 @param xmlelement Element of the XML-file. 65 @param mode XMLPort mode to use. 64 66 */ 65 67 void HealthUsable::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 69 71 XMLPortParam(HealthUsable, "recoveredHealth", setRecoveredHealth, getRecoveredHealth, xmlelement, mode); 70 72 } 73 71 74 /** 72 73 75 @brief Called when the item is used, makes the user "jump". 76 @param pawn Pawn which used te item. 74 77 */ 78 //TODO: Jump? Nope! => Comment. 79 //Should be destroyed anyways. 75 80 void HealthUsable::used(Pawn* pawn) 76 81 { … … 85 90 } 86 91 } 92 87 93 /** 88 89 94 @brief Called when the item is picked up. 95 @param pawn Pawn which picked up the item. 90 96 */ 91 97 bool HealthUsable::pickedUp(Pawn* pawn) … … 93 99 return this->addTo(pawn); 94 100 } 101 95 102 /** 96 97 103 @brief Called when the item is dropped, creates a DroppedItem behind the pawn. 104 @param pawn Pawn which dropped the item. 98 105 */ 99 106 bool HealthUsable::dropped(Pawn* pawn) -
code/branches/pickup/src/orxonox/pickup/items/Jump.h
r5781 r5902 50 50 class _OrxonoxExport Jump : public UsableItem 51 51 { 52 public: 53 Jump(BaseObject* creator); //!< Constructor 54 virtual ~Jump(); //!< Deconstructor 52 public: 53 //TODO: Comment. a.s.o. 54 Jump(BaseObject* creator); //!< Constructor 55 virtual ~Jump(); //!< Deconstructor 55 56 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort57 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< XMLPort 57 58 58 virtual int getMaxCarryAmount() const59 { return INT_MAX; }59 virtual int getMaxCarryAmount() const 60 { return INT_MAX; } 60 61 61 virtual void used(Pawn* pawn); //!< Called when the item is used.62 virtual void used(Pawn* pawn); //!< Called when the item is used. 62 63 63 virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up.64 virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped.64 virtual bool pickedUp(Pawn* pawn); //!< Called when the item is picked up. 65 virtual bool dropped(Pawn* pawn); //!< Called when the item is dropped. 65 66 66 /**67 @brief Get the velocity added when the item is used.68 @return Returns the added velocity (relative to the Pawn).69 */70 inline const Vector3& getVelocity() const71 { return this->velocity_; }72 /**73 @brief Set the velocity added when the item is used.74 @param velocity New added velocity (relative to Pawn).75 */76 inline void setVelocity(const Vector3& velocity)77 { this->velocity_ = velocity; }78 /**79 @brief Get the amount of jumps available.80 @return Returns how many times the item can be used.81 */82 inline int getJumpsAvailable() const83 { return this->jumpsAvailable_; }84 /**85 @brief Set the amount of jumps available.86 @param num New number of available jumps.87 */88 inline void setJumpsAvailable(int num)89 { this->jumpsAvailable_ = num; }90 private:91 Vector3 velocity_; //!< The velocity added when the item is used.92 int jumpsAvailable_; //!< Amount of jumps still available.67 /** 68 @brief Get the velocity added when the item is used. 69 @return Returns the added velocity (relative to the Pawn). 70 */ 71 inline const Vector3& getVelocity() const 72 { return this->velocity_; } 73 /** 74 @brief Set the velocity added when the item is used. 75 @param velocity New added velocity (relative to Pawn). 76 */ 77 inline void setVelocity(const Vector3& velocity) 78 { this->velocity_ = velocity; } 79 /** 80 @brief Get the amount of jumps available. 81 @return Returns how many times the item can be used. 82 */ 83 inline int getJumpsAvailable() const 84 { return this->jumpsAvailable_; } 85 /** 86 @brief Set the amount of jumps available. 87 @param num New number of available jumps. 88 */ 89 inline void setJumpsAvailable(int num) 90 { this->jumpsAvailable_ = num; } 91 private: 92 Vector3 velocity_; //!< The velocity added when the item is used. 93 int jumpsAvailable_; //!< Amount of jumps still available. 93 94 }; 94 95 }
Note: See TracChangeset
for help on using the changeset viewer.