Changeset 9348 for code/trunk/src/modules/pickup/items
- Timestamp:
- Aug 30, 2012, 11:08:17 PM (12 years ago)
- Location:
- code/trunk
- Files:
-
- 16 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:ignore
-
old new 1 .project 1 2 build 2 3 codeblocks 4 dependencies 3 5 vs 4 dependencies
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
code/trunk/src/modules/pickup/items/CMakeLists.txt
r8706 r9348 7 7 ShieldPickup.cc 8 8 ShrinkPickup.cc 9 DamageBoostPickup.cc 9 10 ) -
code/trunk/src/modules/pickup/items/DronePickup.cc
r8858 r9348 39 39 40 40 #include "controllers/DroneController.h" 41 #include "pickup/PickupIdentifier.h"42 41 #include "worldentities/Drone.h" 43 42 #include "worldentities/pawns/Pawn.h" … … 75 74 { 76 75 this->addTarget(ClassIdentifier<Pawn>::getIdentifier()); 77 this->setDurationType Direct(pickupDurationType::once);76 this->setDurationType(pickupDurationType::once); 78 77 this->droneTemplate_ = ""; 79 }80 81 /**82 @brief83 Initializes the PickupIdentifier of this pickup.84 */85 void DronePickup::initializeIdentifier(void)86 {87 std::string val = this->getDroneTemplate();88 std::string type = "droneTemplate";89 this->pickupIdentifier_->addParameter(type, val);90 78 } 91 79 … … 98 86 SUPER(DronePickup, XMLPort, xmlelement, mode); 99 87 XMLPortParam(DronePickup, "droneTemplate", setDroneTemplate, getDroneTemplate, xmlelement, mode); 100 101 this->initializeIdentifier();102 88 } 103 89 … … 108 94 The name of the Template to e set. 109 95 */ 110 void DronePickup::setDroneTemplate( std::stringtemplatename){96 void DronePickup::setDroneTemplate(const std::string& templatename){ 111 97 droneTemplate_ = templatename; 112 98 } … … 144 130 145 131 Controller* controller = drone->getController(); 146 DroneController* droneController = dynamic_cast<DroneController*>(controller);132 DroneController* droneController = orxonox_cast<DroneController*>(controller); 147 133 if(droneController != NULL) 148 134 { … … 175 161 { 176 162 PickupCarrier* carrier = this->getCarrier(); 177 Pawn* pawn = dynamic_cast<Pawn*>(carrier);163 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 178 164 179 165 if(pawn == NULL) … … 184 170 return pawn; 185 171 } 186 187 /**188 @brief189 Creates a duplicate of the input OrxonoxClass.190 @param item191 A pointer to the Orxonox class.192 */193 void DronePickup::clone(OrxonoxClass*& item)194 {195 if(item == NULL)196 item = new DronePickup(this);197 198 SUPER(DronePickup, clone, item);199 200 DronePickup* pickup = dynamic_cast<DronePickup*>(item);201 pickup->setDroneTemplate(this->getDroneTemplate());202 203 pickup->initializeIdentifier();204 }205 172 } -
code/trunk/src/modules/pickup/items/DronePickup.h
r7547 r9348 70 70 71 71 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 72 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.73 72 74 73 const std::string& getDroneTemplate() const; //!< Get the name of the droneTemplate. 75 74 76 75 protected: 77 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup. 78 79 void setDroneTemplate(std::string templatename); //!< Set the droneTemplate. 76 void setDroneTemplate(const std::string& templatename); //!< Set the droneTemplate. 80 77 81 78 private: -
code/trunk/src/modules/pickup/items/HealthPickup.cc
r8864 r9348 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/Pawn.h" 42 41 … … 87 86 /** 88 87 @brief 89 Initializes the PickupIdentifier of this pickup.90 */91 void HealthPickup::initializeIdentifier(void)92 {93 std::stringstream stream;94 stream << this->getHealth();95 std::string type1 = "health";96 std::string val1 = stream.str();97 this->pickupIdentifier_->addParameter(type1, val1);98 99 std::string val2 = this->getHealthType();100 std::string type2 = "healthType";101 this->pickupIdentifier_->addParameter(type2, val2);102 103 stream.clear();104 stream << this->getHealthRate();105 std::string val3 = stream.str();106 std::string type3 = "healthRate";107 this->pickupIdentifier_->addParameter(type3, val3);108 }109 110 /**111 @brief112 88 Method for creating a HealthPickup object through XML. 113 89 */ … … 118 94 XMLPortParam(HealthPickup, "health", setHealth, getHealth, xmlelement, mode); 119 95 XMLPortParam(HealthPickup, "healthRate", setHealthRate, getHealthRate, xmlelement, mode); 120 XMLPortParam(HealthPickup, "healthType", setHealthType , getHealthType, xmlelement, mode);96 XMLPortParam(HealthPickup, "healthType", setHealthTypeAsString, getHealthTypeAsString, xmlelement, mode); 121 97 122 98 if(!this->isContinuous()) 123 this->healthRate_ = 0.0f; 124 125 this->initializeIdentifier(); 99 this->setHealthRate(0.0f); // TODO: this logic should be inside tick(), not in XMLPort 126 100 } 127 101 … … 151 125 this->setHealth(this->getHealth()-health); 152 126 153 switch(this->getHealthType Direct())127 switch(this->getHealthType()) 154 128 { 155 129 case pickupHealthType::permanent: … … 198 172 199 173 float health = 0.0f; 200 switch(this->getHealthType Direct())174 switch(this->getHealthType()) 201 175 { 202 176 case pickupHealthType::permanent: … … 227 201 else 228 202 { 229 if(this->getHealthType Direct() == pickupHealthType::temporary)203 if(this->getHealthType() == pickupHealthType::temporary) 230 204 { 231 205 PickupCarrier* carrier = this->getCarrier(); 232 Pawn* pawn = dynamic_cast<Pawn*>(carrier);206 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 233 207 234 208 if(pawn == NULL) … … 264 238 { 265 239 PickupCarrier* carrier = this->getCarrier(); 266 Pawn* pawn = dynamic_cast<Pawn*>(carrier);240 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 267 241 268 242 if(pawn == NULL) … … 270 244 271 245 return pawn; 272 }273 274 /**275 @brief276 Creates a duplicate of the input OrxonoxClass.277 @param item278 A pointer to the Orxonox class.279 */280 void HealthPickup::clone(OrxonoxClass*& item)281 {282 if(item == NULL)283 item = new HealthPickup(this);284 285 SUPER(HealthPickup, clone, item);286 287 HealthPickup* pickup = dynamic_cast<HealthPickup*>(item);288 pickup->setHealth(this->getHealth());289 pickup->setHealthRate(this->getHealthRate());290 pickup->setHealthTypeDirect(this->getHealthTypeDirect());291 292 pickup->initializeIdentifier();293 246 } 294 247 … … 299 252 Returns the health type as a string. 300 253 */ 301 const std::string& HealthPickup::getHealthType (void) const302 { 303 switch(this->getHealthType Direct())254 const std::string& HealthPickup::getHealthTypeAsString(void) const 255 { 256 switch(this->getHealthType()) 304 257 { 305 258 case pickupHealthType::limited: … … 352 305 The type as a string. 353 306 */ 354 void HealthPickup::setHealthType (std::stringtype)307 void HealthPickup::setHealthTypeAsString(const std::string& type) 355 308 { 356 309 if(type == HealthPickup::healthTypeLimited_s) 357 this->setHealthType Direct(pickupHealthType::limited);310 this->setHealthType(pickupHealthType::limited); 358 311 else if(type == HealthPickup::healthTypeTemporary_s) 359 this->setHealthType Direct(pickupHealthType::temporary);312 this->setHealthType(pickupHealthType::temporary); 360 313 else if(type == HealthPickup::healthTypePermanent_s) 361 this->setHealthType Direct(pickupHealthType::permanent);314 this->setHealthType(pickupHealthType::permanent); 362 315 else 363 316 orxout(internal_error, context::pickups) << "Invalid healthType '" << type << "' in HealthPickup." << endl; -
code/trunk/src/modules/pickup/items/HealthPickup.h
r7551 r9348 97 97 98 98 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 99 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.100 99 101 100 /** … … 116 115 @return Returns the health type as an enum. 117 116 */ 118 inline pickupHealthType::Value getHealthType Direct(void) const117 inline pickupHealthType::Value getHealthType(void) const 119 118 { return this->healthType_; } 120 const std::string& getHealthType (void) const; //!< Get the health type of this pickup.119 const std::string& getHealthTypeAsString(void) const; //!< Get the health type of this pickup. 121 120 122 121 protected: 123 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.124 125 122 void setHealth(float health); //!< Sets the health. 126 123 void setHealthRate(float speed); //!< Set the rate at which health is transferred if the pickup is continuous. … … 130 127 @param type The type of this pickup as an enum. 131 128 */ 132 inline void setHealthType Direct(pickupHealthType::Value type)129 inline void setHealthType(pickupHealthType::Value type) 133 130 { this->healthType_ = type; } 134 void setHealthType (std::stringtype); //!< Set the type of the HealthPickup.131 void setHealthTypeAsString(const std::string& type); //!< Set the type of the HealthPickup. 135 132 136 133 private: -
code/trunk/src/modules/pickup/items/InvisiblePickup.cc
r8858 r9348 40 40 #include "core/XMLPort.h" 41 41 42 #include "pickup/PickupIdentifier.h"43 42 #include "worldentities/pawns/Pawn.h" 44 43 … … 79 78 /** 80 79 @brief 81 Initializes the PickupIdentifier of this pickup.82 */83 void InvisiblePickup::initializeIdentifier(void)84 {85 std::stringstream stream;86 stream << this->getDuration();87 std::string type1 = "duration";88 std::string val1 = stream.str();89 this->pickupIdentifier_->addParameter(type1, val1);90 }91 92 /**93 @brief94 80 Method for creating a HealthPickup object through XML. 95 81 */ … … 98 84 SUPER(InvisiblePickup, XMLPort, xmlelement, mode); 99 85 XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode); 100 101 this->initializeIdentifier();102 86 } 103 87 … … 148 132 /** 149 133 @brief 150 Creates a duplicate of the input OrxonoxClass.151 @param item152 A pointer to the Orxonox class.153 */154 void InvisiblePickup::clone(OrxonoxClass*& item)155 {156 if(item == NULL)157 item = new InvisiblePickup(this);158 159 SUPER(InvisiblePickup, clone, item);160 161 InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);162 pickup->setDuration(this->getDuration());163 pickup->initializeIdentifier();164 }165 166 /**167 @brief168 134 Sets the invisibility. 169 135 @param invisibility … … 202 168 { 203 169 PickupCarrier* carrier = this->getCarrier(); 204 Pawn* pawn = dynamic_cast<Pawn*>(carrier);170 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 205 171 206 172 if(pawn == NULL) -
code/trunk/src/modules/pickup/items/InvisiblePickup.h
r7547 r9348 72 72 InvisiblePickup(BaseObject* creator); //!< Constructor. 73 73 virtual ~InvisiblePickup(); //!< Destructor. 74 74 75 75 virtual void XMLPort(Element& xmlelement, orxonox::XMLPort::Mode mode); //!< Method for creating a HealthPickup object through XML. 76 76 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 77 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.78 77 79 78 /** … … 91 90 92 91 protected: 93 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.94 95 92 bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again. 96 93 void setDuration(float duration); //!< Sets the time the InvisibilityPickup will last. -
code/trunk/src/modules/pickup/items/MetaPickup.cc
r8858 r9348 36 36 37 37 #include "interfaces/PickupCarrier.h" 38 #include "pickup/PickupIdentifier.h"39 38 #include "worldentities/pawns/Pawn.h" 40 39 … … 80 79 this->addTarget(ClassIdentifier<PickupCarrier>::getIdentifier()); 81 80 82 this->setDurationType Direct(pickupDurationType::once);81 this->setDurationType(pickupDurationType::once); 83 82 this->metaType_ = pickupMetaType::none; 84 83 } … … 86 85 /** 87 86 @brief 88 Helper method to initialize the PickupIdentifier.89 */90 void MetaPickup::initializeIdentifier(void)91 {92 std::string val = this->getMetaType();93 std::string type = "metaType";94 this->pickupIdentifier_->addParameter(type, val);95 }96 97 /**98 @brief99 87 Method for creating a MetaPickup object through XML. 100 88 */ … … 103 91 SUPER(MetaPickup, XMLPort, xmlelement, mode); 104 92 105 XMLPortParam(MetaPickup, "metaType", setMetaType, getMetaType, xmlelement, mode); 106 107 this->initializeIdentifier(); 93 XMLPortParam(MetaPickup, "metaType", setMetaTypeAsString, getMetaTypeAsString, xmlelement, mode); 108 94 } 109 95 … … 121 107 { 122 108 PickupCarrier* carrier = this->getCarrier(); 123 if(this->getMetaType Direct() != pickupMetaType::none && carrier != NULL)109 if(this->getMetaType() != pickupMetaType::none && carrier != NULL) 124 110 { 125 111 // If the metaType is destroyCarrier, then the PickupCarrier is destroyed. 126 if(this->getMetaType Direct() == pickupMetaType::destroyCarrier)112 if(this->getMetaType() == pickupMetaType::destroyCarrier) 127 113 { 128 114 Pawn* pawn = orxonox_cast<Pawn*>(carrier); … … 139 125 140 126 // If the metaType is use, then the Pickupable is set to used. 141 if(this->getMetaType Direct() == pickupMetaType::use && !pickup->isUsed())127 if(this->getMetaType() == pickupMetaType::use && !pickup->isUsed()) 142 128 { 143 129 pickup->setUsed(true); 144 130 } 145 131 // If the metaType is drop, then the Pickupable is dropped. 146 else if(this->getMetaType Direct() == pickupMetaType::drop)132 else if(this->getMetaType() == pickupMetaType::drop) 147 133 { 148 134 pickup->drop(); 149 135 } 150 136 // If the metaType is destroy, then the Pickupable is destroyed. 151 else if(this->getMetaType Direct() == pickupMetaType::destroy)137 else if(this->getMetaType() == pickupMetaType::destroy) 152 138 { 153 139 pickup->Pickupable::destroy(); … … 161 147 /** 162 148 @brief 163 Creates a duplicate of the input OrxonoxClass.164 @param item165 A pointer to the Orxonox class.166 */167 void MetaPickup::clone(OrxonoxClass*& item)168 {169 if(item == NULL)170 item = new MetaPickup(this);171 172 SUPER(MetaPickup, clone, item);173 174 MetaPickup* pickup = dynamic_cast<MetaPickup*>(item);175 pickup->setMetaTypeDirect(this->getMetaTypeDirect());176 177 pickup->initializeIdentifier();178 }179 180 /**181 @brief182 149 Get the meta type of this MetaPickup. 183 150 @return 184 151 Returns a string with the meta type of the MetaPickup. 185 152 */ 186 const std::string& MetaPickup::getMetaType (void) const187 { 188 switch(this->getMetaType Direct())153 const std::string& MetaPickup::getMetaTypeAsString(void) const 154 { 155 switch(this->getMetaType()) 189 156 { 190 157 case pickupMetaType::none: … … 209 176 A string with the type to be set. 210 177 */ 211 void MetaPickup::setMetaType (const std::string& type)178 void MetaPickup::setMetaTypeAsString(const std::string& type) 212 179 { 213 180 if(type == MetaPickup::metaTypeNone_s) 214 181 { 215 this->setMetaType Direct(pickupMetaType::none);182 this->setMetaType(pickupMetaType::none); 216 183 } 217 184 else if(type == MetaPickup::metaTypeUse_s) 218 185 { 219 this->setMetaType Direct(pickupMetaType::use);186 this->setMetaType(pickupMetaType::use); 220 187 } 221 188 else if(type == MetaPickup::metaTypeDrop_s) 222 189 { 223 this->setMetaType Direct(pickupMetaType::drop);190 this->setMetaType(pickupMetaType::drop); 224 191 } 225 192 else if(type == MetaPickup::metaTypeDestroy_s) 226 193 { 227 this->setMetaType Direct(pickupMetaType::destroy);194 this->setMetaType(pickupMetaType::destroy); 228 195 } 229 196 else if(type == MetaPickup::metaTypeDestroyCarrier_s) 230 197 { 231 this->setMetaType Direct(pickupMetaType::destroyCarrier);198 this->setMetaType(pickupMetaType::destroyCarrier); 232 199 } 233 200 else -
code/trunk/src/modules/pickup/items/MetaPickup.h
r7547 r9348 69 69 70 70 The default value is <em>none</em>, which basically does nothing. 71 71 72 72 The parameter <b>activation type</b> can be used to specify, whether the MetaPickup is used upon pickup (<em>immediate</em>) or not (<em>onUse</em>). With <em>immediate</em> being the default. 73 73 … … 95 95 96 96 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 97 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.98 97 99 98 /** … … 101 100 @return Returns an enum with the meta type of the MetaPickup. 102 101 */ 103 inline pickupMetaType::Value getMetaType Direct(void) const102 inline pickupMetaType::Value getMetaType(void) const 104 103 { return this->metaType_; } 105 const std::string& getMetaType (void) const; //!< Get the meta type of this MetaPickup.104 const std::string& getMetaTypeAsString(void) const; //!< Get the meta type of this MetaPickup. 106 105 107 106 protected: 108 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.109 110 107 /** 111 108 @brief Set the meta type of the MetaPickup. 112 109 @param type The meta type as an enum. 113 110 */ 114 inline void setMetaType Direct(pickupMetaType::Value type)111 inline void setMetaType(pickupMetaType::Value type) 115 112 { this->metaType_ = type; } 116 void setMetaType (const std::string& type); //!< Set the meta type of this MetaPickup.113 void setMetaTypeAsString(const std::string& type); //!< Set the meta type of this MetaPickup. 117 114 118 115 private: -
code/trunk/src/modules/pickup/items/ShieldPickup.cc
r8858 r9348 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/Pawn.h" 42 41 … … 80 79 /** 81 80 @brief 82 Initializes the PickupIdentifier of this pickup.83 */84 void ShieldPickup::initializeIdentifier(void)85 {86 std::stringstream stream;87 stream << this->getDuration();88 std::string type1 = "duration";89 std::string val1 = stream.str();90 this->pickupIdentifier_->addParameter(type1, val1);91 92 stream.clear();93 stream << this->getShieldHealth();94 std::string type2 = "ShieldHealth";95 std::string val2 = stream.str();96 this->pickupIdentifier_->addParameter(type2, val2);97 98 stream.clear();99 stream << this->getShieldAbsorption();100 std::string type3 = "ShieldAbsorption";101 std::string val3 = stream.str();102 this->pickupIdentifier_->addParameter(type3, val3);103 104 }105 106 /**107 @brief108 81 Method for creating a ShieldPickup object through XML. 109 82 */ … … 115 88 XMLPortParam(ShieldPickup, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode); 116 89 XMLPortParam(ShieldPickup, "duration", setDuration, getDuration, xmlelement, mode); 117 118 this->initializeIdentifier();119 90 } 120 91 … … 177 148 { 178 149 PickupCarrier* carrier = this->getCarrier(); 179 Pawn* pawn = dynamic_cast<Pawn*>(carrier);150 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 180 151 181 152 if(pawn == NULL) … … 184 155 } 185 156 return pawn; 186 }187 188 /**189 @brief190 Creates a duplicate of the input OrxonoxClass.191 @param item192 A pointer to the Orxonox class.193 */194 void ShieldPickup::clone(OrxonoxClass*& item)195 {196 if(item == NULL)197 item = new ShieldPickup(this);198 199 SUPER(ShieldPickup, clone, item);200 201 ShieldPickup* pickup = dynamic_cast<ShieldPickup*>(item);202 pickup->setDuration(this->getDuration());203 pickup->setShieldAbsorption(this->getShieldAbsorption());204 pickup->setShieldHealth(this->getShieldHealth());205 pickup->initializeIdentifier();206 157 } 207 158 -
code/trunk/src/modules/pickup/items/ShieldPickup.h
r7547 r9348 82 82 83 83 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 84 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.85 84 86 85 /** … … 104 103 105 104 protected: 106 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.107 105 void pickupTimerCallback(void); //!< Helper method. Is called by the Timer as soon as it expires. 108 106 -
code/trunk/src/modules/pickup/items/ShrinkPickup.cc
r8713 r9348 40 40 #include "core/XMLPort.h" 41 41 42 #include "pickup/PickupIdentifier.h"43 42 #include "worldentities/pawns/Pawn.h" 44 43 … … 81 80 } 82 81 83 void ShrinkPickup::initializeIdentifier(void)84 {85 std::stringstream stream;86 stream << this->getShrinkFactor();87 std::string type1 = "shrinkFactor";88 std::string val1 = stream.str();89 this->pickupIdentifier_->addParameter(type1, val1);90 91 stream.clear();92 stream << this->getDuration();93 std::string val2 = stream.str();94 std::string type2 = "duration";95 this->pickupIdentifier_->addParameter(type2, val2);96 97 stream.clear();98 stream << this->getShrinkDuration();99 std::string val3 = stream.str();100 std::string type3 = "shrinkDuration";101 this->pickupIdentifier_->addParameter(type3, val3);102 }103 104 82 /** 105 83 @brief … … 113 91 XMLPortParam(ShrinkPickup, "duration", setDuration, getDuration, xmlelement, mode); 114 92 XMLPortParam(ShrinkPickup, "shrinkDuration", setShrinkDuration, getShrinkDuration, xmlelement, mode); 115 116 this->initializeIdentifier(); 93 } 94 95 /** 96 @brief Sets the shrinking factor. 97 @param factor The factor, needs to greater than 1. 98 */ 99 void ShrinkPickup::setShrinkFactor(float factor) 100 { 101 if(factor <= 1.0f) 102 { 103 orxout(internal_warning, context::pickups) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl; 104 return; 105 } 106 this->shrinkFactor_ = factor; 107 } 108 109 /** 110 @brief Set the duration for which the ship remains shrunken. 111 @param duration The duration, needs to be non-negative. 112 */ 113 void ShrinkPickup::setDuration(float duration) 114 { 115 if(duration < 0.0f) 116 { 117 orxout(internal_warning, context::pickups) << "Invalid duration in ShrinkPickup. Ignoring.." << endl; 118 return; 119 } 120 this->duration_ = duration; 121 } 122 123 /** 124 @brief Set the shrink duration. 125 @param speed The shrink duration, needs to be positive. 126 */ 127 void ShrinkPickup::setShrinkDuration(float speed) 128 { 129 if(speed <= 0.0f) 130 { 131 orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; 132 return; 133 } 134 this->shrinkDuration_ = speed; 117 135 } 118 136 … … 148 166 { 149 167 SUPER(ShrinkPickup, changedPickedUp); 150 168 151 169 if(!this->isPickedUp() && this->isActive_) 152 170 { … … 271 289 272 290 bool destroy = false; 273 291 274 292 // Stop shrinking if the desired size is reached. 275 293 if(this->timeRemainig_ <= 0.0f) … … 314 332 { 315 333 PickupCarrier* carrier = this->getCarrier(); 316 Pawn* pawn = dynamic_cast<Pawn*>(carrier);334 Pawn* pawn = orxonox_cast<Pawn*>(carrier); 317 335 318 336 return pawn; 319 337 } 320 321 /**322 @brief323 Creates a duplicate of the input OrxonoxClass.324 @param item325 A pointer to the Orxonox class.326 */327 void ShrinkPickup::clone(OrxonoxClass*& item)328 {329 if(item == NULL)330 item = new ShrinkPickup(this);331 332 SUPER(ShrinkPickup, clone, item);333 ShrinkPickup* pickup = dynamic_cast<ShrinkPickup*>(item);334 pickup->setShrinkFactor(this->getShrinkFactor());335 pickup->setDuration(this->getDuration());336 pickup->setShrinkDuration(this->getShrinkDuration());337 338 pickup->initializeIdentifier();339 }340 338 } -
code/trunk/src/modules/pickup/items/ShrinkPickup.h
r8858 r9348 80 80 virtual void changedUsed(void); // Is called when the pickup has transited from used to unused or the other way around. 81 81 virtual void changedPickedUp(void); 82 virtual void clone(OrxonoxClass*& item); // Creates a duplicate of the input OrxonoxClass.83 82 84 83 /** … … 88 87 inline float getShrinkFactor(void) const 89 88 { return this->shrinkFactor_; } 90 /** 91 @brief Sets the shrinking factor. 92 @param factor The factor, needs to greater than 1. 93 */ 94 inline void setShrinkFactor(float factor) 95 { if(factor <= 1.0f) { orxout(internal_warning, context::pickups) << "Invalid shrinking factor in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkFactor_ = factor; } 89 void setShrinkFactor(float factor); 90 96 91 /** 97 92 @brief Get the duration for which the ship remains shrunken. … … 100 95 inline float getDuration(void) const 101 96 { return this->duration_; } 102 /** 103 @brief Set the duration for which the ship remains shrunken. 104 @param duration The duration, needs to be non-negative. 105 */ 106 inline void setDuration(float duration) 107 { if(duration < 0.0f) { orxout(internal_warning, context::pickups) << "Invalid duration in ShrinkPickup. Ignoring.." << endl; return; } this->duration_ = duration; } 97 void setDuration(float duration); 98 108 99 /** 109 100 @brief Get the shrink speed. … … 112 103 inline float getShrinkDuration(void) const 113 104 { return this->shrinkDuration_; } 114 /** 115 @brief Set the shrink duration. 116 @param speed The shrink duration, needs to be positive. 117 */ 118 inline void setShrinkDuration(float speed) 119 { if(speed <= 0.0f) { orxout(internal_warning, context::pickups) << "Invalid shrink duration in ShrinkPickup. Ignoring.." << endl; return; } this->shrinkDuration_ = speed; } 120 121 protected: 122 void initializeIdentifier(void); 105 void setShrinkDuration(float speed); 123 106 124 107 private: … … 135 118 float currentFactor_; //!< The shrink factor that is currently applied. 136 119 float timeRemainig_; //!< The remaining shrink time. 137 120 138 121 Pawn* carrierToPawnHelper(void); 139 122 Timer durationTimer_; -
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r8858 r9348 38 38 #include "core/XMLPort.h" 39 39 40 #include "pickup/PickupIdentifier.h"41 40 #include "worldentities/pawns/SpaceShip.h" 42 41 … … 80 79 /** 81 80 @brief 82 Initializes the PickupIdentifier of this pickup.83 */84 void SpeedPickup::initializeIdentifier(void)85 {86 std::stringstream stream;87 stream << this->getDuration();88 std::string type1 = "duration";89 std::string val1 = stream.str();90 this->pickupIdentifier_->addParameter(type1, val1);91 92 stream.clear();93 stream << this->getSpeedAdd();94 std::string type2 = "speedAdd";95 std::string val2 = stream.str();96 this->pickupIdentifier_->addParameter(type2, val2);97 98 stream.clear();99 stream << this->getSpeedMultiply();100 std::string type3 = "speedMultiply";101 std::string val3 = stream.str();102 this->pickupIdentifier_->addParameter(type3, val3);103 }104 105 /**106 @brief107 81 Method for creating a SpeedPickup object through XML. 108 82 */ … … 114 88 XMLPortParam(SpeedPickup, "speedAdd", setSpeedAdd, getSpeedAdd, xmlelement, mode); 115 89 XMLPortParam(SpeedPickup, "speedMultiply", setSpeedMultiply, getSpeedMultiply, xmlelement, mode); 116 117 this->initializeIdentifier();118 90 } 119 91 … … 176 148 { 177 149 PickupCarrier* carrier = this->getCarrier(); 178 SpaceShip* ship = dynamic_cast<SpaceShip*>(carrier);150 SpaceShip* ship = orxonox_cast<SpaceShip*>(carrier); 179 151 180 152 if(ship == NULL) … … 184 156 185 157 return ship; 186 }187 188 /**189 @brief190 Creates a duplicate of the input OrxonoxClass.191 @param item192 A pointer to the Orxonox class.193 */194 void SpeedPickup::clone(OrxonoxClass*& item)195 {196 if(item == NULL)197 item = new SpeedPickup(this);198 199 SUPER(SpeedPickup, clone, item);200 201 SpeedPickup* pickup = dynamic_cast<SpeedPickup*>(item);202 pickup->setDuration(this->getDuration());203 pickup->setSpeedAdd(this->getSpeedAdd());204 pickup->setSpeedMultiply(this->getSpeedMultiply());205 206 pickup->initializeIdentifier();207 158 } 208 159 -
code/trunk/src/modules/pickup/items/SpeedPickup.h
r8727 r9348 81 81 82 82 virtual void changedUsed(void); //!< Is called when the pickup has transited from used to unused or the other way around. 83 virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.84 83 85 84 /** … … 103 102 104 103 protected: 105 void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.106 104 void pickupTimerCallback(void); //!< Function that gets called when timer ends. 107 105 … … 112 110 private: 113 111 void initialize(void); //!< Initializes the member variables. 114 SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceS Hip, and throw an error message if the conversion fails.112 SpaceShip* carrierToSpaceShipHelper(void); //!< Helper to transform the PickupCarrier to a SpaceShip, and throw an error message if the conversion fails. 115 113 116 114 Timer durationTimer_; //!< Timer.
Note: See TracChangeset
for help on using the changeset viewer.