Changeset 6538 for code/trunk/src/modules/pickup/items
- Timestamp:
- Mar 16, 2010, 6:15:45 PM (15 years ago)
- Location:
- code/trunk/src/modules/pickup/items
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/items/MetaPickup.cc
r6524 r6538 28 28 29 29 /** 30 @file 30 @file MetaPickup.cc 31 31 @brief Implementation of the MetaPickup class. 32 32 */ … … 43 43 CreateFactory(MetaPickup); 44 44 45 //! Setting the static variables to their values. 45 46 /*static*/ const std::string MetaPickup::metaTypeNone_s = "none"; 46 47 /*static*/ const std::string MetaPickup::metaTypeUse_s = "use"; … … 49 50 /** 50 51 @brief 51 Constructor. 52 Constructor. Registers and initializes the object. 52 53 */ 53 54 MetaPickup::MetaPickup(BaseObject* creator) : Pickup(creator) … … 55 56 RegisterObject(MetaPickup); 56 57 58 this->initialize(); 59 } 60 61 /** 62 @brief 63 Destructor. 64 */ 65 MetaPickup::~MetaPickup() 66 { 67 68 } 69 70 /** 71 @brief 72 Initializes the object. 73 */ 74 void MetaPickup::initialize(void) 75 { 57 76 this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier()); 77 58 78 this->setActivationTypeDirect(pickupActivationType::immediate); 59 79 this->setDurationTypeDirect(pickupDurationType::once); … … 61 81 } 62 82 63 MetaPickup::~MetaPickup() 64 { 65 66 } 67 83 /** 84 @brief 85 Helper method to initialize the PickupIdentifier. 86 */ 68 87 void MetaPickup::initializeIdentifier(void) 69 88 { … … 73 92 } 74 93 94 /** 95 @brief 96 Method for creating a MetaPickup object through XML. 97 */ 75 98 void MetaPickup::XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode) 76 99 { … … 82 105 } 83 106 107 /** 108 @brief 109 Is called when the pickup has transited from used to unused or the other way around. 110 Any Class overwriting this method must call its SUPER function by adding SUPER(Classname, changedUsed); to their changdeUsed method. 111 */ 84 112 void MetaPickup::changedUsed(void) 85 113 { 86 114 SUPER(MetaPickup, changedUsed); 87 115 116 //! If the MetaPickup transited to used. 88 117 if(this->isUsed()) 89 118 { … … 92 121 { 93 122 std::set<Pickupable*> pickups = carrier->getPickups(); 123 //! Set all Pickupables carried by the PickupCarrier either to used or drop them, depending o the meta type. 94 124 for(std::set<Pickupable*>::iterator it = pickups.begin(); it != pickups.end(); it++) 95 125 { … … 114 144 } 115 145 } 116 146 147 /** 148 @brief 149 Creates a duplicate of the input OrxonoxClass. 150 @param item 151 A pointer to the Orxonox class. 152 */ 153 void MetaPickup::clone(OrxonoxClass*& item) 154 { 155 if(item == NULL) 156 item = new MetaPickup(this); 157 158 SUPER(MetaPickup, clone, item); 159 160 MetaPickup* pickup = dynamic_cast<MetaPickup*>(item); 161 pickup->setMetaTypeDirect(this->getMetaTypeDirect()); 162 163 pickup->initializeIdentifier(); 164 } 165 166 /** 167 @brief 168 Get the meta type of this MetaPickup. 169 @return 170 Returns a string with the meta type of the MetaPickup. 171 */ 117 172 const std::string& MetaPickup::getMetaType(void) 118 173 { … … 130 185 } 131 186 187 /** 188 @brief 189 Set the meta type of this MetaPickup. 190 @param type 191 A string with the type to be set. 192 */ 132 193 void MetaPickup::setMetaType(const std::string& type) 133 194 { … … 146 207 } 147 208 148 void MetaPickup::clone(OrxonoxClass*& item)149 {150 if(item == NULL)151 item = new MetaPickup(this);152 153 SUPER(MetaPickup, clone, item);154 155 MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);156 pickup->setMetaTypeDirect(this->getMetaTypeDirect());157 158 pickup->initializeIdentifier();159 }160 161 209 } -
code/trunk/src/modules/pickup/items/MetaPickup.h
r6524 r6538 28 28 29 29 /** 30 @file 30 @file MetaPickup.h 31 31 @brief Definition of the MetaPickup class. 32 32 */ … … 62 62 63 63 public: 64 MetaPickup(BaseObject* creator); 65 virtual ~MetaPickup(); 64 MetaPickup(BaseObject* creator); //!< Constructor. Registers and initializes the object. 65 virtual ~MetaPickup(); //!< Destructor. 66 66 67 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML.67 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a MetaPickup object through XML. 68 68 69 69 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 70 70 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass. 71 71 72 /** 73 @brief Returns the meta type of the MetaPickup. 74 @return Returns an enum with the meta type of the MetaPickup. 75 */ 72 76 inline pickupMetaType::Value getMetaTypeDirect(void) 73 77 { return this->metaType_; } 74 const std::string& getMetaType(void); 78 const std::string& getMetaType(void); //!< Get the meta type of this MetaPickup. 75 79 76 80 protected: 81 void initialize(void); //!< Initializes the object. 77 82 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 78 83 84 /** 85 @brief Set the meta type of the MetaPickup. 86 @param type The meta type as an enum. 87 */ 79 88 inline void setMetaTypeDirect(pickupMetaType::Value type) 80 89 { this->metaType_ = type; } 81 void setMetaType(const std::string& type); 90 void setMetaType(const std::string& type); //!< Set the meta type of this MetaPickup. 82 91 83 92 private: 84 93 void initialize(void); //!< Initializes the member variables. 85 94 86 pickupMetaType::Value metaType_; 95 pickupMetaType::Value metaType_; //!< The meta type of the MetaPickup, determines which actions are taken. 96 97 //! Static strings for the meta types. 87 98 static const std::string metaTypeNone_s; 88 99 static const std::string metaTypeUse_s;
Note: See TracChangeset
for help on using the changeset viewer.