Changeset 6728 for code/trunk/src/modules
- Timestamp:
- Apr 15, 2010, 1:15:11 PM (15 years ago)
- Location:
- code/trunk/src/modules/pickup
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/modules/pickup/Pickup.h
r6709 r6728 135 135 virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable. 136 136 137 bool startPickupTimer(float durationTime); 137 bool startPickupTimer(float durationTime); //!< Starts the pickup duration timer. 138 /** 139 @brief Get your Timer. 140 @return Returns a pointer to the Timer. 141 */ 142 inline Timer* getTimer(void) 143 { return &this->durationTimer_; } 138 144 145 /** 146 @brief The callback method for the Timer. 147 Can be overloaded to implement desired functionality. 148 */ 139 149 virtual void pickupTimerCallback(void) {} 140 150 … … 164 174 pickupDurationType::Value durationType_; //!< The duration type of the pickup. 165 175 176 //! Strings for the activation and duration types. 166 177 static const std::string activationTypeImmediate_s; 167 178 static const std::string activationTypeOnUse_s; -
code/trunk/src/modules/pickup/PickupManager.cc
r6725 r6728 198 198 { 199 199 Pickupable* pickup = carrier->getPickup(index); 200 carrier->drop(pickup); 200 if(pickup != NULL) 201 carrier->drop(pickup); 201 202 } 202 203 … … 204 205 { 205 206 Pickupable* pickup = carrier->getPickup(index); 206 pickup->setUsed(use); 207 if(pickup != NULL) 208 pickup->setUsed(use); 207 209 } 208 210 -
code/trunk/src/modules/pickup/items/SpeedPickup.cc
r6713 r6728 141 141 if(this->isUsed()) 142 142 { 143 this->startPickupTimer(this->getDuration()); 143 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f) 144 { 145 this->getTimer()->unpauseTimer(); 146 } 147 else 148 { 149 this->startPickupTimer(this->getDuration()); 150 } 144 151 engine->setSpeedAdd(this->getSpeedAdd()); 145 152 engine->setSpeedMultiply(this->getSpeedMultiply()); … … 152 159 if(this->isOnce()) 153 160 { 154 this->destroy(); 161 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration()) 162 { 163 //TODO: Potentially dangerous, not only for this pickup. Think long and hard about this!!! 164 this->destroy(); 165 } 166 else 167 { 168 this->getTimer()->pauseTimer(); 169 } 155 170 } 156 171 }
Note: See TracChangeset
for help on using the changeset viewer.