- Timestamp:
- Jan 25, 2006, 9:28:18 PM (19 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/npcs/ground_turret.cc
r6512 r6736 115 115 if (likely(this->left != NULL)) 116 116 { 117 this->left->tickW(dt);117 // this->left->tickW(dt); 118 118 this->left->requestAction(WA_SHOOT); 119 119 } 120 120 if (likely(this->right != NULL)) 121 121 { 122 this->right->tickW(dt);122 // this->right->tickW(dt); 123 123 this->right->requestAction(WA_SHOOT); 124 124 } -
trunk/src/world_entities/weapons/weapon.cc
r6728 r6736 538 538 * tick signal for time dependent/driven stuff 539 539 */ 540 voidWeapon::tickW(float dt)540 bool Weapon::tickW(float dt) 541 541 { 542 542 //printf("%s ", stateToChar(this->currentState)); … … 550 550 { 551 551 this->currentState = WS_INACTIVE; 552 return ;552 return false; 553 553 } 554 554 else … … 561 561 } 562 562 } 563 tick(dt);563 return true; 564 564 } 565 565 -
trunk/src/world_entities/weapons/weapon.h
r6671 r6736 153 153 154 154 // FLOW 155 voidtickW(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within156 157 virtual void tick(float dt) { };155 bool tickW(float dt); //!< this is a function that must be called by the weaponManager, or any other weaponHandler, all other functions are handled from within 156 157 virtual void tick(float dt) { tickW(dt); }; 158 158 159 159 bool check() const; -
trunk/src/world_entities/weapons/weapon_manager.cc
r6728 r6736 121 121 122 122 LoadParam(root, "slot-count", this, WeaponManager, setSlotCount) 123 123 .describe("how many slots(cannons) the WeaponManager can handle"); 124 124 125 125 LOAD_PARAM_START_CYCLE(root, element); … … 127 127 // CHECK IF THIS WORKS.... 128 128 LoadParamXML_CYCLE(element, "weapons", this, WeaponManager, loadWeapons) 129 129 .describe("loads Weapons"); 130 130 } 131 131 LOAD_PARAM_END_CYCLE(element); … … 255 255 256 256 if (!(this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLKINDS) && 257 257 this->currentSlotConfig[slotID].capability & weapon->getCapability() & WTYPE_ALLDIRS) 258 258 { 259 259 PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n", … … 268 268 this->configs[configID][slotID] = weapon; 269 269 weapon->setAmmoContainer(this->getAmmoContainer(weapon->getProjectileType())); 270 if (this->parent != NULL)271 {272 this->parent->addChild(weapon);273 }274 270 if(configID == this->currentConfigID) 275 271 this->currentSlotConfig[slotID].nextWeapon = weapon; 272 if (this->parent != NULL) 273 { 274 this->parent->addChild(weapon); 275 if (this->parent->isA(CL_PLAYABLE)) 276 dynamic_cast<Playable*>(this->parent)->weaponConfigChanged(); 277 } 276 278 PRINTF(3)("Added a new Weapon (%s::%s) to the WeaponManager: config %i/ slot %i\n", weapon->getClassName(), weapon->getName(), configID, slotID); 277 279 return true; … … 350 352 PRINTF(4)("Changing weapon configuration: to %i\n", this->currentConfigID); 351 353 for (int i = 0; i < WM_MAX_SLOTS; i++) 352 {353 354 this->currentSlotConfig[i].nextWeapon = this->configs[currentConfigID][i]; 354 if (this->currentSlotConfig[i].currentWeapon != this->currentSlotConfig[i].nextWeapon)355 {356 if (this->currentSlotConfig[i].currentWeapon != NULL)357 (this->currentSlotConfig[i].currentWeapon->requestAction(WA_DEACTIVATE));358 if (this->currentSlotConfig[i].nextWeapon != NULL && this->currentSlotConfig[i].nextWeapon->isActive())359 this->currentSlotConfig[i].nextWeapon = NULL;360 }361 }362 355 } 363 356 … … 387 380 Weapon* tickWeapon; 388 381 389 // all weapons390 382 for(int i = 0; i < this->slotCount; i++) 391 383 { 392 384 /* 385 NICE LITTLE DEBUG FUNCTION 386 if (this->currentSlotConfig[i].currentWeapon != NULL || this->currentSlotConfig[i].nextWeapon != NULL) 387 printf("%p %p\n", this->currentSlotConfig[i].currentWeapon, this->currentSlotConfig[i].nextWeapon);*/ 388 389 // current Weapon in Slot i 393 390 tickWeapon = this->currentSlotConfig[i].currentWeapon; 394 if (tickWeapon != this->currentSlotConfig[i].nextWeapon) // if no change occures 395 { 396 if (tickWeapon != NULL && tickWeapon->isActive()) 391 // On A change (current != next) 392 if (tickWeapon != this->currentSlotConfig[i].nextWeapon) 393 { 394 // if a Weapon is Active in slot i, deactivate it. 395 if (tickWeapon != NULL ) 397 396 { 398 tickWeapon->requestAction(WA_DEACTIVATE); 397 if (tickWeapon->isActive()) 398 { 399 tickWeapon->requestAction(WA_DEACTIVATE); 400 continue; 401 } 402 else 403 { 404 tickWeapon->toList(OM_NULL); 405 this->currentSlotConfig[i].currentWeapon = NULL; 406 } 407 } 408 409 // switching to next Weapon 410 tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon; 411 if (tickWeapon != NULL) 412 { 413 if (this->parent != NULL) 414 tickWeapon->toList(this->parent->getOMListNumber()); 415 tickWeapon->requestAction(WA_ACTIVATE); 416 this->currentSlotConfig[i].position.activateNode(); 417 tickWeapon->setParent(&this->currentSlotConfig[i].position); 418 printf("ACTIVATE\n"); 399 419 } 400 420 else 401 { 402 if (this->currentSlotConfig[i].currentWeapon != NULL) 403 this->currentSlotConfig[i].currentWeapon->toList(OM_NULL); 404 tickWeapon = this->currentSlotConfig[i].currentWeapon = this->currentSlotConfig[i].nextWeapon; 405 if (tickWeapon != NULL) 406 { 407 tickWeapon->requestAction(WA_ACTIVATE); 408 tickWeapon->setParent(&this->currentSlotConfig[i].position); 409 tickWeapon->toList(this->parent->getOMListNumber()); 410 this->currentSlotConfig[i].position.activateNode(); 411 if (this->parent->isA(CL_PLAYABLE)) 412 { 413 dynamic_cast<Playable*>(this->parent)->weaponConfigChanged(); 414 } 415 } 416 else 417 this->currentSlotConfig[i].position.deactivateNode(); 418 } 419 } 420 421 if( tickWeapon != NULL && tickWeapon->isActive()) 422 tickWeapon->tickW(dt); 423 } 424 425 crosshair->setRotationSpeed(5); 421 this->currentSlotConfig[i].position.deactivateNode(); 422 if (this->parent != NULL && this->parent->isA(CL_PLAYABLE)) 423 dynamic_cast<Playable*>(this->parent)->weaponConfigChanged(); 424 } 425 } 426 426 } 427 427 … … 457 457 (this->currentSlotConfig[i].capability & capability & WTYPE_ALLDIRS)) 458 458 return i; 459 }459 } 460 460 } 461 461 else
Note: See TracChangeset
for help on using the changeset viewer.