- Timestamp:
- Mar 6, 2010, 7:44:04 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/pickup3/src/modules/pickup/items/HealthPickup.h
r6474 r6477 32 32 #include "pickup/PickupPrereqs.h" 33 33 34 #include <string> 35 #include <worldentities/pawns/Pawn.h> 36 #include "worldentities/StaticEntity.h" 37 34 38 #include "pickup/Pickup.h" 35 39 #include "tools/interfaces/Tickable.h" 36 #include "worldentities/StaticEntity.h"37 38 #include <string>39 40 40 41 namespace orxonox { … … 51 52 } 52 53 54 /** 55 @brief 56 A pickup that can do (dependent upon the parameters) lots of different things to the health of a Pawn. 57 There are 4 parameters that can be choosen: 58 1) The health. The amount of health that (in a way dependent on the other parameters) is transfered to the Pawn. 59 2) The activation type: It can be chosen to be either 'immediate' or 'onUse'. The activation type essentially (as indicated by the name) defines when the health is transfered, either immediately after being picked up or only after the player uses it. 60 3) The duration type: It can be chosen to be either 'once' or 'continuous'. For 'once' the specified health is transfered once to the Pawn, for 'continuous' the set health is transfered over a span of time at a rate defined by the health rate parameter. 61 4) The health type: The health type can be choosen to be 'limited', 'temporary' or 'permanent'. 'limited' means that the health is increased only to the maximum health of the Pawn. 'temporary' means that the maximum health is temporarily elevated but will be set back as soon as the pickup is no longer in use. 'permanent' means that the maximum health of the Pawn is increased such that the health provided by the pickup will fit in and the maximum health stays that way. 62 @author 63 Damian 'Mozork' Frick 64 */ 53 65 class _PickupExport HealthPickup : public Pickup, public Tickable 54 66 { 55 67 public: 56 68 57 HealthPickup(BaseObject* creator); 58 virtual ~HealthPickup(); 69 HealthPickup(BaseObject* creator); //!< Constructor. 70 virtual ~HealthPickup(); //!< Destructor. 59 71 60 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); 61 virtual void tick(float dt); 72 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML. 73 virtual void tick(float dt); //!< Is called every tick. 62 74 63 virtual void clone(OrxonoxClass* item); 64 65 virtual void changedUsed(void); 75 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 76 virtual void clone(OrxonoxClass* item); //!< Creates a duplicate of the input OrxonoxClass. 77 78 /** 79 @brief Get the health that is transfered to the Pawn upon usage of this pickup. 80 @return Returns the health. 81 */ 82 inline float getHealth(void) 83 { return this->health_; } 84 /** 85 @brief Get the rate at which the health is transferred to the Pawn, if this pickup has duration type 'continuous'. 86 @return Returns the rate. 87 */ 88 inline float getHealthRate(void) 89 { return this->healthRate_; } 90 91 /** 92 @brief Get the type of HealthPickup, this pickup is. 93 @return Returns the health type as an enum. 94 */ 95 inline pickupHealthType::Value getHealthTypeDirect(void) 96 { return this->healthType_; } 97 const std::string& getHealthType(void); //!< Get the health type of this pickup. 66 98 67 99 protected: 68 void initializeIdentifier(void); 100 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 69 101 70 void setHealth(float health); 71 void setHealthSpeed(float speed); 72 void setHealthType(std::string type); 102 void setHealth(float health); //!< Sets the health. 103 void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous. 104 105 /** 106 @brief Set the health type of this pickup. 107 @param type The type of this pickup as an enum. 108 */ 73 109 inline void setHealthTypeDirect(pickupHealthType::Value type) 74 110 { this->healthType_ = type; } 75 76 inline float getHealth(void) 77 { return this->health_; } 78 inline float getHealthSpeed(void) 79 { return this->healthSpeed_; } 80 const std::string& getHealthType(void); 81 inline pickupHealthType::Value getHealthTypeDirect(void) 82 { return this->healthType_; } 111 void setHealthType(std::string type); //!< Set the type of the HealthPickup. 83 112 84 113 private: 85 void initialize(void); 114 void initialize(void); //!< Initializes the member variables. 115 Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails. 86 116 87 float health_; 88 float healthSpeed_; 89 pickupHealthType::Value healthType_; 117 float health_; //!< The health that is transferred to the Pawn. 118 float healthRate_; //!< The rate at which the health is transferred. 119 float maxHealthSave_; //!< Helper to remember what the actual maxHealth of the Pawn was before we changed it. 120 float maxHealthOverwrite_; //!< Helper to remember with which value we overwrote the maxHealh, to detect if someone else changed it as well. 121 pickupHealthType::Value healthType_; //!< The type of the HealthPickup. 90 122 123 //! Strings for the health types. 91 124 static const std::string healthTypeLimited_s; 92 125 static const std::string healthTypeTemporary_s; 93 126 static const std::string healthTypePermanent_s; 94 static const std::string blankString_s; //TODO: Maybe already implemented somewhere?95 127 96 128 };
Note: See TracChangeset
for help on using the changeset viewer.