Changeset 4906 in orxonox.OLD for orxonox/trunk/src/world_entities/weapons/weapon.cc
- Timestamp:
- Jul 20, 2005, 1:41:19 AM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapons/weapon.cc
r4895 r4906 81 81 this->emissionPoint.setParent(this); 82 82 83 this->active = true;84 83 this->projectile = NULL; 84 85 this->hideInactive = true; 85 86 86 87 this->minCharge = 1.0; … … 171 172 void Weapon::requestAction(WeaponAction action) 172 173 { 173 if ( this->requestedAction != WA_NONE)174 return;175 else176 {174 if (likely(this->isActive())) 175 { 176 if (this->requestedAction != WA_NONE) 177 return; 177 178 printf("next action will be %s in %f seconds\n", actionToChar(action), this->stateDuration); 178 179 this->requestedAction = action; 180 } 181 //else 182 else if (unlikely(action == WA_ACTIVATE)) 183 { 184 this->currentState = WS_ACTIVATING; 185 this->requestAction(WA_ACTIVATE); 179 186 } 180 187 } … … 215 222 bool Weapon::execute() 216 223 { 217 224 #if DEBUG > 4 218 225 PRINTF(4)("trying to execute action %s\n", actionToChar(this->requestedAction)); 219 226 this->debug(); 227 #endif 220 228 221 229 switch (this->requestedAction) … … 246 254 bool Weapon::activateW() 247 255 { 248 //if (this->currentState == WS_INACTIVE)256 if (this->currentState == WS_INACTIVE) 249 257 { 250 258 // play Sound … … 256 264 PRINTF(4)("Activating the Weapon %s\n", this->getName()); 257 265 this->activate(); 258 this->active = true;259 266 // setting up for next action 267 this->currentState = WS_ACTIVATING; 260 268 this->stateDuration = this->times[WA_ACTIVATE] + this->stateDuration; 261 269 } … … 280 288 // deactivate 281 289 this->deactivate(); 282 this->active = false;283 290 // setting up for next action 291 this->currentState = WS_DEACTIVATING; 284 292 this->stateDuration = this->times[WA_DEACTIVATE] + this->stateDuration; 285 293 } … … 305 313 // setting up for the next state 306 314 this->requestedAction = WA_NONE; 315 this->currentState = WS_CHARGING; 307 316 this->stateDuration = this->times[WA_CHARGE] + this->stateDuration; 308 317 } … … 334 343 // setting up for the next state 335 344 this->stateDuration = this->times[WA_SHOOT] + this->stateDuration; 345 this->currentState = WS_SHOOTING; 336 346 this->requestedAction = WA_NONE; 337 347 } … … 379 389 380 390 this->requestedAction = WA_NONE; 391 this->currentState = WS_RELOADING; 381 392 this->stateDuration = this->times[WA_RELOAD] + this->stateDuration; 382 393 … … 387 398 * tick signal for time dependent/driven stuff 388 399 */ 389 void Weapon::tick (float dt)400 void Weapon::tickW(float dt) 390 401 { 391 402 // setting up the timing properties … … 394 405 if (this->isActive()) 395 406 { 396 if (this->stateDuration <= 0.0 && this->requestedAction != WA_NONE) 397 { 398 this->stateDuration = -dt; 399 this->execute(); 400 } 401 } 402 else 403 if (this->requestedAction == WA_ACTIVATE) 404 this->activate(); 405 407 if (this->stateDuration <= 0.0) 408 { 409 if (unlikely (this->currentState != WS_DEACTIVATING)) 410 this->currentState = WS_IDLE; 411 else 412 this->currentState = WS_INACTIVE; 413 414 if (this->requestedAction != WA_NONE) 415 { 416 this->stateDuration = -dt; 417 this->execute(); 418 } 419 } 420 } 421 tick(dt); 406 422 } 407 423 … … 569 585 return "idle"; 570 586 break; 587 case WS_INACTIVE: 588 return "inactive"; 589 break; 571 590 default: 572 591 return "none";
Note: See TracChangeset
for help on using the changeset viewer.