Changeset 3870 in orxonox.OLD for orxonox/trunk/src/world_entities
- Timestamp:
- Apr 18, 2005, 3:37:42 PM (20 years ago)
- Location:
- orxonox/trunk/src/world_entities
- Files:
-
- 2 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 -
orxonox/trunk/src/world_entities/weapon.h
r3862 r3870 34 34 35 35 #define W_MAX_SLOTS 8 36 #define W_MAX_CONF S 436 #define W_MAX_CONFIGS 4 37 37 38 38 class Projectile; … … 48 48 } weaponSoundType; 49 49 50 50 51 //! this is an identifier for the slot. there are up to 8 weapon slots -> this means there can't be more than 8 weapons at the same time 51 typedef enum slotID {W_SLOT0=0, W_SLOT1, W_SLOT2, W_SLOT3, 52 W_SLOT4, W_SLOT5, W_SLOT6, W_SLOT7}; 52 #define W_SLOT0 0 53 #define W_SLOT1 1 54 #define W_SLOT2 2 55 #define W_SLOT3 3 56 #define W_SLOT4 4 57 #define W_SLOT5 5 58 #define W_SLOT6 6 59 #define W_SLOT7 7 60 #define W_FREE_SLOT 99 61 53 62 54 63 //! this is an identifier for the weapon config 55 typedef enum configID {W_CONFIG0=0, W_CONFIG1, 56 W_CONFIG2, W_CONFIG3}; 64 #define W_CONFIG0 0 65 #define W_CONFIG1 1 66 #define W_CONFIG2 2 67 #define W_CONFIG3 3 57 68 58 69 //! this is a weapon Configuration: it has up to 8 slots 59 70 typedef struct weaponConfig { 60 Weapon* slot1; //<! standard right side weapon 61 Weapon* slot2; //<! standard left side weapon 62 Weapon* slot3; //<! custom 63 Weapon* slot4; //<! custom 64 Weapon* slot5; //<! custom 65 Weapon* slot6; //<! custom 66 Weapon* slot7; //<! custom 67 Weapon* slot8; //<! custom 71 bool bUsed; //<! is set to true, if this configuration is 72 Weapon* slots[8]; 68 73 }; 69 74 … … 74 79 ~WeaponManager(); 75 80 76 void addWeapon(Weapon* weapon, slotID slot, configID config = W_CONFIG0); 77 void addWeaponConfig(weaponConfig* config); 81 void addWeapon(Weapon* weapon, int slotID = W_FREE_SLOT, int configID = W_CONFIG1); 78 82 79 83 void nextWeaponConf(); 80 84 void prevWeaponConf(); 81 void selectConfig( configID config);85 void selectConfig(int configID); 82 86 83 87 private: 84 88 int nrOfConfigs; //<! number of configurations defined 85 89 int nrOfSlots; //<! number of weapon slots a ship has 86 weaponConfig* currentConfig; //<! the currently selected config 87 weaponConfig* configs[4]; //<! a list of four configurations 90 int currConfID; //<! the currently selected config 91 weaponConfig configs[4]; //<! a list of four configurations 92 93 int getNextFreeSlot(); 88 94 }; 89 95
Note: See TracChangeset
for help on using the changeset viewer.