Changeset 6607 for code/branches/ppspickups1/src/modules/pickup/Pickup.cc
- Timestamp:
- Mar 22, 2010, 10:45:09 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ppspickups1/src/modules/pickup/Pickup.cc
r6540 r6607 39 39 #include "DroppedPickup.h" 40 40 41 #include "tools/Timer.h" 42 41 43 namespace orxonox 42 44 { 43 45 44 46 /*static*/ const std::string Pickup::activationTypeImmediate_s = "immediate"; 45 47 /*static*/ const std::string Pickup::activationTypeOnUse_s = "onUse"; 46 48 /*static*/ const std::string Pickup::durationTypeOnce_s = "once"; 47 49 /*static*/ const std::string Pickup::durationTypeContinuous_s = "continuous"; 48 50 49 51 Pickup::Pickup(BaseObject* creator) : BaseObject(creator) 50 52 { 51 53 RegisterObject(Pickup); 52 54 53 55 this->initialize(); 54 56 } 55 57 56 58 Pickup::~Pickup() 57 59 { 58 59 } 60 60 61 } 62 61 63 /** 62 64 @brief … … 68 70 this->durationType_ = pickupDurationType::once; 69 71 } 70 72 71 73 /** 72 74 @brief … … 74 76 */ 75 77 void Pickup::initializeIdentifier(void) 76 { 78 { 77 79 std::string val1 = this->getActivationType(); 78 80 std::string type1 = "activationType"; 79 81 this->pickupIdentifier_->addParameter(type1, val1); 80 82 81 83 std::string val2 = this->getDurationType(); 82 84 std::string type2 = "durationType"; 83 85 this->pickupIdentifier_->addParameter(type2, val2); 84 86 } 85 87 86 88 /** 87 89 @brief … … 94 96 XMLPortParam(Pickup, "activationType", setActivationType, getActivationType, xmlelement, mode); 95 97 XMLPortParam(Pickup, "durationType", setDurationType, getDurationType, xmlelement, mode); 96 98 97 99 this->initializeIdentifier(); 98 100 } 99 101 100 102 /** 101 103 @brief … … 116 118 } 117 119 } 118 120 119 121 /** 120 122 @brief … … 135 137 } 136 138 } 137 139 138 140 /** 139 141 @brief … … 157 159 } 158 160 } 159 161 160 162 /** 161 163 @brief … … 179 181 } 180 182 } 181 183 182 184 /** 183 185 @brief … … 188 190 { 189 191 SUPER(Pickup, changedPickedUp); 190 192 191 193 //! Sets the Pickup to used if the Pickup has activation type 'immediate' and gets picked up. 192 194 if(this->getCarrier() != NULL && this->isPickedUp() && this->isImmediate()) … … 195 197 } 196 198 } 197 199 198 200 /** 199 201 @brief … … 206 208 if(item == NULL) 207 209 item = new Pickup(this); 208 210 209 211 SUPER(Pickup, clone, item); 210 212 211 213 Pickup* pickup = dynamic_cast<Pickup*>(item); 212 214 pickup->setActivationTypeDirect(this->getActivationTypeDirect()); 213 215 pickup->setDurationTypeDirect(this->getDurationTypeDirect()); 214 216 215 217 pickup->initializeIdentifier(); 216 218 } 217 219 218 220 /** 219 221 @brief … … 231 233 return true; 232 234 } 233 235 236 /** 237 @brief 238 Starts the Pickup duration Timer. 239 */ 240 bool Pickup::startPickupTimer(float durationTime) 241 { 242 if (durationTime<=0) 243 { 244 COUT(1) << "Invalid durationTime in pickup." << std::endl; 245 return false; 246 } 247 if (false) /* How to check if Timer already running? */ 248 { 249 COUT(1) << "Pickup durationTimer already in use." << std::endl; 250 return false; 251 } 252 this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::PickupTimerCallBack, this))); 253 return true; 254 } 234 255 }
Note: See TracChangeset
for help on using the changeset viewer.