- Timestamp:
- Jan 28, 2007, 1:30:45 PM (18 years ago)
- Location:
- trunk/src/world_entities
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/world_entities/Makefile.am
r10405 r10437 12 12 npcs/npc.cc\ 13 13 weapons/weapon_manager.cc\ 14 weapons/weapon_slot.cc \ 14 15 weapons/crosshair.cc \ 15 16 weapons/weapon.cc\ … … 36 37 npcs/npc.h\ 37 38 weapons/weapon_manager.h\ 39 weapons/weapon_slot.cc \ 38 40 weapons/crosshair.h \ 39 41 weapons/weapon.h\ -
trunk/src/world_entities/WorldEntities.am
r10433 r10437 35 35 world_entities/questGUI/quest.cc \ 36 36 \ 37 world_entities/weapons/weapon_slot.cc \ 37 38 world_entities/weapons/test_gun.cc \ 38 39 world_entities/weapons/laser_cannon.cc \ … … 166 167 questGUI/quest.h \ 167 168 \ 169 weapons/weapon_slot.h \ 168 170 weapons/test_gun.h \ 169 171 weapons/laser_cannon.cc \ -
trunk/src/world_entities/mount_point.cc
r10314 r10437 37 37 { 38 38 PRINTF(5)("Created mount point %s\n", name.c_str()); 39 this->registerObject(this, MountPoint::_objectList); 39 40 40 41 this->_name = name; -
trunk/src/world_entities/weapons/weapon_manager.cc
r10368 r10437 15 15 16 16 2005-07-24: Benjamin Grauer: restructurate, so it can handle the new Weapons. 17 2007-01-28: Patrick Boenzli: loadable slots 17 18 */ 18 19 … … 21 22 #include "weapon_manager.h" 22 23 #include "weapon.h" 24 #include "weapon_slot.h" 23 25 #include "crosshair.h" 24 26 … … 77 79 for (int i = 0; i < WM_MAX_SLOTS; i++) 78 80 { 79 this->currentSlotConfig[i].capability = WTYPE_ALL; 80 this->currentSlotConfig[i].currentWeapon = NULL; 81 this->currentSlotConfig[i].nextWeapon = NULL; 81 this->currentSlotConfig[i] = new WeaponSlot(); 82 this->currentSlotConfig[i]->setCapability(WTYPE_ALL); 83 this->currentSlotConfig[i]->setCurrentWeapon(NULL); 84 this->currentSlotConfig[i]->setNextWeapon(NULL); 82 85 83 86 // NAMING … … 93 96 sprintf(tmpName, "WeaponMan_slot%d", i); 94 97 } 95 this->currentSlotConfig[i] .position.setName(tmpName);96 this->currentSlotConfig[i] .position.deactivateNode();98 this->currentSlotConfig[i]->setName(tmpName); 99 this->currentSlotConfig[i]->deactivateNode(); 97 100 delete[] tmpName; 98 101 } … … 199 202 { 200 203 for (int i = 0; i < WM_MAX_SLOTS; i++) 201 this->parentNode->addChild( &this->currentSlotConfig[i].position);204 this->parentNode->addChild(this->currentSlotConfig[i]); 202 205 } 203 206 … … 227 230 if (slot < this->slotCount) 228 231 { 229 this->currentSlotConfig[slot] .position.setRelCoor(position);232 this->currentSlotConfig[slot]->setRelCoor(position); 230 233 231 234 if (parent != NULL) 232 this->currentSlotConfig[slot] .position.setParent(parent);235 this->currentSlotConfig[slot]->setParent(parent); 233 236 } 234 237 } … … 243 246 { 244 247 if (slot < this->slotCount) 245 this->currentSlotConfig[slot] .position.setRelDir(rotation);248 this->currentSlotConfig[slot]->setRelDir(rotation); 246 249 } 247 250 … … 298 301 } 299 302 300 if (!(this->currentSlotConfig[slotID] .capability& weapon->getCapability() & WTYPE_ALLKINDS) &&301 this->currentSlotConfig[slotID] .capability& weapon->getCapability() & WTYPE_ALLDIRS)303 if (!(this->currentSlotConfig[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLKINDS) && 304 this->currentSlotConfig[slotID]->getCapability() & weapon->getCapability() & WTYPE_ALLDIRS) 302 305 { 303 306 PRINTF(2)("Unable to add Weapon with wrong capatibility to Slot %d (W:%d M:%d)\n", 304 slotID, weapon->getCapability(), this->currentSlotConfig[slotID] .capability);307 slotID, weapon->getCapability(), this->currentSlotConfig[slotID]->getCapability()); 305 308 return false; 306 309 } … … 313 316 weapon->setAmmoContainer(this->getAmmoContainer(weapon->getProjectileType())); 314 317 if(configID == this->currentConfigID) 315 this->currentSlotConfig[slotID] .nextWeapon = weapon;318 this->currentSlotConfig[slotID]->nextWeapon = weapon; 316 319 //if (this->parent != NULL) 317 320 { … … 319 322 if (this->parentEntity->isA(Playable::staticClassID())) 320 323 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 321 324 322 325 weapon->setDefaultTarget(this->crosshair); 323 326 } … … 352 355 * sets the capabilities of a Slot 353 356 * @param slot the slot to set the capability 354 * @param slotCapability the capability @see W M_SlotCapability357 * @param slotCapability the capability @see WeaponSlotCapability 355 358 */ 356 359 void WeaponManager::setSlotCapability(int slot, long slotCapability) … … 358 361 if (slot > slotCount) 359 362 return; 360 this->currentSlotConfig[slot] .capability = slotCapability;363 this->currentSlotConfig[slot]->setCapability(slotCapability); 361 364 } 362 365 … … 381 384 this->configs[i][j] = NULL; 382 385 } 383 if (this->currentSlotConfig[j] .currentWeapon== weapon)386 if (this->currentSlotConfig[j]->getCurrentWeapon() == weapon) 384 387 { 385 this->currentSlotConfig[j] .nextWeapon = NULL;388 this->currentSlotConfig[j]->setNextWeapon(NULL); 386 389 } 387 390 } … … 422 425 423 426 for (int i = 0; i < WM_MAX_SLOTS; i++) 424 this->currentSlotConfig[i] .nextWeapon = this->configs[currentConfigID][i];427 this->currentSlotConfig[i]->nextWeapon = this->configs[currentConfigID][i]; 425 428 } 426 429 … … 436 439 { 437 440 // printf("%i ", i); 438 firingWeapon = this->currentSlotConfig[i] .currentWeapon;441 firingWeapon = this->currentSlotConfig[i]->getCurrentWeapon(); 439 442 if( firingWeapon != NULL && firingWeapon->getCurrentState() == WS_SHOOTING) continue; 440 443 if( firingWeapon != NULL) firingWeapon->requestAction(WA_SHOOT); … … 455 458 for(int i = 0; i < this->slotCount; i++) 456 459 { 457 firingWeapon = this->currentSlotConfig[i] .currentWeapon;460 firingWeapon = this->currentSlotConfig[i]->currentWeapon; 458 461 if( firingWeapon != NULL) firingWeapon->requestAction(WA_NONE); 459 462 } … … 478 481 479 482 //NICE LITTLE DEBUG FUNCTION 480 /* if (this->currentSlotConfig[i] .currentWeapon != NULL || this->currentSlotConfig[i].nextWeapon != NULL)481 printf("%p %p\n", this->currentSlotConfig[i] .currentWeapon, this->currentSlotConfig[i].nextWeapon);*/483 /* if (this->currentSlotConfig[i]->currentWeapon != NULL || this->currentSlotConfig[i]->nextWeapon != NULL) 484 printf("%p %p\n", this->currentSlotConfig[i]->currentWeapon, this->currentSlotConfig[i]->nextWeapon);*/ 482 485 483 486 // current Weapon in Slot i 484 tickWeapon = this->currentSlotConfig[i] .currentWeapon;487 tickWeapon = this->currentSlotConfig[i]->currentWeapon; 485 488 // On A change (current != next) 486 if (tickWeapon != this->currentSlotConfig[i] .nextWeapon)489 if (tickWeapon != this->currentSlotConfig[i]->nextWeapon) 487 490 { 488 491 // if a Weapon is Active in slot i, deactivate it. … … 497 500 { 498 501 tickWeapon->toList(OM_NULL); 499 this->currentSlotConfig[i] .currentWeapon = NULL;502 this->currentSlotConfig[i]->currentWeapon = NULL; 500 503 } 501 504 } 502 505 // switching to next Weapon 503 tickWeapon = this->currentSlotConfig[i] .currentWeapon = this->currentSlotConfig[i].nextWeapon;504 506 tickWeapon = this->currentSlotConfig[i]->currentWeapon = this->currentSlotConfig[i]->nextWeapon; 507 505 508 if (tickWeapon != NULL) 506 509 { … … 508 511 tickWeapon->toList(this->parentEntity->getOMListNumber()); 509 512 tickWeapon->requestAction(WA_ACTIVATE); 510 this->currentSlotConfig[i] .position.activateNode();511 tickWeapon->setParent( &this->currentSlotConfig[i].position);513 this->currentSlotConfig[i]->activateNode(); 514 tickWeapon->setParent(this->currentSlotConfig[i]); 512 515 } 513 516 else 514 this->currentSlotConfig[i] .position.deactivateNode();517 this->currentSlotConfig[i]->deactivateNode(); 515 518 if (this->parentEntity != NULL && this->parentEntity->isA(Playable::staticClassID())) 516 519 dynamic_cast<Playable*>(this->parentEntity)->weaponConfigChanged(); 517 520 } 518 521 else if (unlikely(tickWeapon != NULL && tickWeapon->getCurrentState() == WS_DEACTIVATING)) 519 this->currentSlotConfig[i] .nextWeapon = NULL;522 this->currentSlotConfig[i]->nextWeapon = NULL; 520 523 } 521 524 } … … 531 534 for (int i = 0; i < this->slotCount; i++) 532 535 { 533 drawWeapon = this->currentSlotConfig[i] .currentWeapon;536 drawWeapon = this->currentSlotConfig[i]->currentWeapon; 534 537 if( drawWeapon != NULL && drawWeapon->isVisible()) 535 538 drawWeapon->draw(); … … 550 553 { 551 554 if( this->configs[configID][i] == NULL && 552 (this->currentSlotConfig[i] .capability& capability & WTYPE_ALLKINDS) &&553 (this->currentSlotConfig[i] .capability& capability & WTYPE_ALLDIRS))555 (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLKINDS) && 556 (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLDIRS)) 554 557 return i; 555 558 } … … 560 563 { 561 564 if( this->configs[configID][i] == NULL && 562 (this->currentSlotConfig[i] .capability& capability & WTYPE_ALLKINDS) &&563 (this->currentSlotConfig[i] .capability& capability & WTYPE_ALLDIRS))565 (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLKINDS) && 566 (this->currentSlotConfig[i]->getCapability() & capability & WTYPE_ALLDIRS)) 564 567 return i; 565 568 } … … 604 607 } 605 608 } 609 610 611 long WeaponManager::getSlotCapability(int slot) const 612 { 613 return this->currentSlotConfig[slot]->getCapability(); 614 } 615 616 const Vector& WeaponManager::getSlotPosition(int slot) const 617 { 618 return this->currentSlotConfig[slot]->getRelCoor(); 619 } 620 621 Weapon* WeaponManager::getWeapon(int slotID) const 622 { 623 return (slotID >= 0 && slotID < this->slotCount)? this->currentSlotConfig[slotID]->getNextWeapon(): NULL; 624 } 625 626 -
trunk/src/world_entities/weapons/weapon_manager.h
r10368 r10437 21 21 #include "ammo_container.h" 22 22 23 23 24 // FORWARD DECLARATION 24 25 template <class T> class tAnimation; 26 class WeaponSlot; 25 27 26 28 #define WM_MAX_SLOTS 10 //!< How many slots the WeaponManager has at its max … … 40 42 class WeaponManager : public BaseObject { 41 43 ObjectListDeclaration(WeaponManager); 42 43 //! an enumerator defining a Slot, where a Weapon can be stored inside.44 typedef struct45 {46 PNode position; //!< the relative Position to the position of the carrying entity. (const PNode* parent; of WeaponManager)47 long capability; //!< the capabilities of the Slot @see WM_SlotCapability.48 49 Weapon* currentWeapon; //!< The current weapon this slot is carrying.50 Weapon* nextWeapon; //!< either NULL or the next weapon that will be set (require currentWeapon to deactivate)51 } WM_Slot;52 44 53 45 public: … … 70 62 void setSlotDirection(int slot, const Quaternion& rotation); 71 63 /** @param slot the slot to get the relative position from @returns the relative position of the Carrier to the Slot */ 72 const Vector& getSlotPosition(int slot) const { return this->currentSlotConfig[slot].position.getRelCoor(); };64 const Vector& getSlotPosition(int slot) const; 73 65 void setSlotCapability(int slot, long slotCapability); 74 66 /** @param slot the slot to get the capabilities from @returns the capabilies */ 75 long getSlotCapability(int slot) const { return this->currentSlotConfig[slot].capability; };67 long getSlotCapability(int slot) const; 76 68 77 69 void setParentEntity(WorldEntity* parent); … … 85 77 void removeWeapon(Weapon* weapon, int configID = -1); 86 78 87 Weapon* getWeapon(int slotID) const { return (slotID >= 0 && slotID < this->slotCount)? this->currentSlotConfig[slotID].nextWeapon: NULL; };79 Weapon* getWeapon(int slotID) const; 88 80 89 81 // FIXME :: … … 122 114 int currentConfigID; //!< the currently selected config. 123 115 Weapon* configs[WM_MAX_CONFIGS][WM_MAX_SLOTS]; //!< An array of predefined configurations and assigned weapon. 124 W M_SlotcurrentSlotConfig[WM_MAX_SLOTS]; //!< The currentConfigureation.116 WeaponSlot* currentSlotConfig[WM_MAX_SLOTS]; //!< The currentConfigureation. 125 117 126 118 Weapon* availiableWeapons[WM_MAX_LOADED_WEAPONS]; //!< The availiable Weapons of this WeaponManager
Note: See TracChangeset
for help on using the changeset viewer.