Changeset 7547 for code/trunk/src/modules/pickup/items/SpeedPickup.cc
- Timestamp:
- Oct 16, 2010, 12:37:09 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r7401 r7547 34 34 #include "SpeedPickup.h" 35 35 36 #include <sstream> 36 37 #include "core/CoreIncludes.h" 37 38 #include "core/XMLPort.h" 38 #include "util/StringUtils.h" 39 40 #include "worldentities/pawns/SpaceShip.h" 39 41 40 #include "items/Engine.h" 42 41 #include "pickup/PickupIdentifier.h" 43 44 #include <sstream> 45 42 #include "worldentities/pawns/SpaceShip.h" 46 43 47 44 namespace orxonox … … 130 127 SUPER(SpeedPickup, changedUsed); 131 128 132 // !If the pickup is not picked up nothing must be done.129 // If the pickup is not picked up nothing must be done. 133 130 if(!this->isPickedUp()) 134 131 return; 135 132 136 133 Engine* engine = this->carrierToEngineHelper(); 137 if(engine == NULL) // !<If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.134 if(engine == NULL) // If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed. 138 135 this->Pickupable::destroy(); 139 136 140 // !If the pickup has transited to used.137 // If the pickup has transited to used. 141 138 if(this->isUsed()) 142 139 { 143 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f) 140 // If its durationType is continuous, we set a Timer to be reminded, when the time has run out. 141 if(this->isContinuous()) 144 142 { 145 this->durationTimer_.unpauseTimer(); 146 } 147 else 148 { 149 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this))); 150 } 151 engine->setSpeedAdd(this->getSpeedAdd()); 152 engine->setSpeedMultiply(this->getSpeedMultiply()); 153 } 154 else 155 { 156 engine->setSpeedAdd(0.0f); 157 engine->setSpeedMultiply(1.0f); 158 159 if(this->isOnce()) 160 { 161 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()) 143 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f) 162 144 { 163 this-> Pickupable::destroy();145 this->durationTimer_.unpauseTimer(); 164 146 } 165 147 else 166 148 { 167 this->durationTimer_. pauseTimer();149 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this))); 168 150 } 151 } 152 153 engine->setSpeedAdd(this->getSpeedAdd()); 154 engine->setSpeedMultiply(this->getSpeedMultiply()); 155 } 156 else 157 { 158 engine->setSpeedAdd(0.0f); 159 engine->setSpeedMultiply(1.0f); 160 161 // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded. 162 if((!this->isContinuous() && this->isImmediate()) || (this->isContinuous() && !this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())) 163 { 164 this->Pickupable::destroy(); 165 } 166 // We pause the Timer if the pickup is continuous and the duration is not yet exceeded, 167 else if(this->isContinuous() && this->durationTimer_.isActive()) 168 { 169 this->durationTimer_.pauseTimer(); 169 170 } 170 171 } … … 213 214 /** 214 215 @brief 215 Sets the duration .216 Sets the duration for which the SpeedPickup stays active. 216 217 @param duration 217 The duration 218 The duration in seconds. 218 219 */ 219 220 void SpeedPickup::setDuration(float duration) … … 232 233 /** 233 234 @brief 234 Sets the SpeedAdd235 Sets the speedAdd, the value that is added to the speed of the Pawn. 235 236 @param speedAdd 236 The added Speed237 The added speed. 237 238 */ 238 239 void SpeedPickup::setSpeedAdd(float speedAdd) … … 251 252 /** 252 253 @brief 253 Sets the SpeedMultiply254 Sets the speedMultiply, the factor by which the speed of the Pawn is multiplied. 254 255 @param speedMultiply 255 The multiplied Speed256 The factor by which the speed is mutiplied. 256 257 */ 257 258 void SpeedPickup::setSpeedMultiply(float speedMultiply)
Note: See TracChangeset
for help on using the changeset viewer.