Changeset 3878 in orxonox.OLD for orxonox/trunk/src/world_entities/weapon.cc
- Timestamp:
- Apr 18, 2005, 6:12:16 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/world_entities/weapon.cc
r3877 r3878 56 56 57 57 58 void WeaponManager::addWeapon(Weapon* weapon, int slotID, int configID) 58 /** 59 \brief adds a weapon to the selected weaponconfiguration into the selected slot 60 \param the weapon to add 61 \param an identifier for the slot: number between 0..7 if not specified: slotID=next free slot 62 \param an identifier for the weapon configuration, number between 0..3 63 64 if you add explicitly a weapon at config:n, slot:m, the weapon placed at this location will be 65 replaced by the weapon specified. if you use the W_FREE_SLOT, the manager will look for a free 66 slot in this weaponconfiguration. if there is non, the weapon won't be added and there will be 67 a error message. 68 */ 69 void WeaponManager::addWeapon(Weapon* weapon, int configID, int slotID) 59 70 { 60 71 if( slotID == W_FREE_SLOT) 61 72 { 62 int freeSlot = this->getNextFreeSlot( );73 int freeSlot = this->getNextFreeSlot( configID); 63 74 if( freeSlot < 0 || freeSlot >= this->nrOfSlots) 64 75 { … … 67 78 } 68 79 PRINTF(3)("Added new Weapon to Config:%i/Slot:%i\n", configID, freeSlot); 80 this->configs[configID].bUsed = true; 69 81 this->configs[configID].slots[freeSlot] = weapon; 70 82 return; 71 83 } 84 this->configs[configID].bUsed = true; 72 85 this->configs[configID].slots[slotID] = weapon; 73 86 PRINTF(3)("Added a new Weapon to the WeaponManager: config %i/ slot %i\n", configID, slotID); … … 75 88 76 89 90 void WeaponManager::removeWeapon(Weapon* weapon, int configID) 91 { 92 /* empty */ 93 } 94 95 96 /** 97 \brief changes to the next weapon configuration 98 99 if there are multiple weapon configurations defined by the manager, use this to switch between them 100 */ 77 101 void WeaponManager::nextWeaponConf() 78 102 { 79 PRINTF(3)("Changing weapon configuration: from %i 103 PRINTF(3)("Changing weapon configuration: from %i\n", this->currConfID); 80 104 int i; 81 for(i = this->currConfID ; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i);105 for(i = this->currConfID + 1; i < W_MAX_CONFIGS && !this->configs[i].bUsed; ++i); 82 106 if( i == W_MAX_CONFIGS) this->currConfID = W_CONFIG0; 83 107 else this->currConfID = i; 84 PRINTF(3)("to %i\n", this->currConfID); 85 } 86 87 88 int WeaponManager::getNextFreeSlot() 89 { 90 for( int i = 0; i < W_MAX_SLOTS; ++i) 91 { 92 if( this->configs[this->currConfID].slots[i] == NULL) 93 return i; 94 } 95 return -1; 96 } 97 98 108 PRINTF(3)("\tto %i\n", this->currConfID); 109 } 110 111 112 113 /** 114 \brief triggers fire of all weapons in the current weaponconfig 115 */ 99 116 void WeaponManager::fire() 100 117 { … … 108 125 109 126 127 /** 128 \brief triggers tick of all weapons in the current weaponconfig 129 \param second passed since last tick 130 */ 110 131 void WeaponManager::tick(float sec) 111 132 { … … 119 140 120 141 142 /** 143 \brief triggers draw of all weapons in the current weaponconfig 144 */ 121 145 void WeaponManager::draw() 122 146 { … … 128 152 } 129 153 } 154 155 156 /** 157 \brief private gets the next free slot in a certain weaponconfig 158 \param the selected weaponconfig 159 */ 160 int WeaponManager::getNextFreeSlot(int configID) 161 { 162 for( int i = 0; i < W_MAX_SLOTS; ++i) 163 { 164 if( this->configs[configID].slots[i] == NULL) 165 return i; 166 } 167 return -1; 168 } 169 170 171 172 173 130 174 131 175 /**
Note: See TracChangeset
for help on using the changeset viewer.