Changeset 3870 in orxonox.OLD for orxonox/trunk/src/world_entities/weapon.cc
- Timestamp:
- Apr 18, 2005, 3:37:42 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapon.cc
r3862 r3870 30 30 31 31 32 /** 33 \brief this initializes the weaponManager for a given nnumber of weapon slots 34 \param number of weapon slots of the model/ship <= 8 (limitied) 35 */ 32 36 WeaponManager::WeaponManager(int nrOfSlots) 33 37 { 34 38 this->nrOfSlots = nrOfSlots; 35 this->nrOfConfigs = 1; 36 37 for(int i = 0; i < W_MAX_CONFS; ++i) 38 this->configs[i] = NULL; 39 this->currentConfig = new weaponConfig; 40 this->configs[0] = this->currentConfig; 41 } 39 40 this->currConfID = W_CONFIG1; 41 this->configs[this->currConfID].bUsed = true; 42 } 43 42 44 43 45 WeaponManager::~WeaponManager() 44 46 { 45 46 } 47 48 void WeaponManager::addWeapon(Weapon* weapon, slotID slot, configID config) 49 { 50 if(this->configs[config] == NULL) 51 PRINTF(0)(""); 52 // this->configs[(int)config]-> 53 } 54 55 void WeaponManager::addWeaponConfig(weaponConfig* config) 56 {} 47 /* i dont have to delete the weapons itself, because they are 48 worldentities and therefore in the entities list of the world 49 */ 50 } 51 52 53 void WeaponManager::addWeapon(Weapon* weapon, int slotID, int configID) 54 { 55 if( slotID == W_FREE_SLOT) 56 { 57 int freeSlot = this->getNextFreeSlot(); 58 if( freeSlot < 0 || freeSlot >= this->nrOfSlots) 59 { 60 PRINTF(0)("There is no free slot in this WeaponConfig to dock this weapon at! Aborting\n"); 61 return; 62 } 63 this->configs[configID].slots[freeSlot] = weapon; 64 return; 65 } 66 this->configs[configID].slots[slotID] = weapon; 67 PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID); 68 } 69 57 70 58 71 void WeaponManager::nextWeaponConf() 59 {} 72 { 73 for(; this->currConfID < W_MAX_CONFIGS && !this->configs[this->currConfID].bUsed; this->currConfID+=1) 74 printf(""); 75 } 76 60 77 61 78 void WeaponManager::prevWeaponConf() … … 63 80 64 81 65 void WeaponManager::selectConfig(configID config) 66 { 67 if( this->configs[(int)config] != NULL) 68 this->currentConfig = this->configs[(int)config]; 69 else 70 PRINTF(0)("There is no weapon config defined with the number W_CONF%i", (int)config); 71 } 72 82 void WeaponManager::selectConfig(int confID) 83 { 84 PRINTF(0)("There is no weapon config defined with the number W_CONF%i", confID); 85 } 86 87 88 89 int WeaponManager::getNextFreeSlot() 90 { 91 for( int i = 0; i < W_MAX_SLOTS; ++i) 92 { 93 if( this->configs[this->currConfID].slots[i] == NULL) 94 return i; 95 } 96 return -1; 97 } 73 98 74 99
Note: See TracChangeset
for help on using the changeset viewer.