- Timestamp:
- Apr 18, 2009, 6:14:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2915 r2918 37 37 #include "WeaponSet.h" 38 38 #include "Weapon.h" 39 #include "Munition.h" 39 40 40 41 /* WeaponSystem … … 63 64 this->pawn_->setWeaponSystem(0); 64 65 65 // for (std::map<unsigned int, WeaponSet*>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); )66 // delete (it++)->second;67 66 while (!this->weaponSets_.empty()) 68 67 delete (this->weaponSets_.begin()->second); 69 68 70 // for (std::set<WeaponPack*>::iterator it = this->weaponPacks_.begin(); it != this->weaponPacks_.end(); )71 // delete (*(it++));72 69 while (!this->weaponPacks_.empty()) 73 70 delete (*this->weaponPacks_.begin()); 74 71 75 // for (std::vector<WeaponSlot*>::iterator it = this->weaponSlots_.begin(); it != this->weaponSlots_.end(); )76 // delete (*(it++));77 72 while (!this->weaponSlots_.empty()) 78 73 delete (*this->weaponSlots_.begin()); 74 75 while (!this->munitions_.empty()) 76 { delete (this->munitions_.begin()->second); this->munitions_.erase(this->munitions_.begin()); } 79 77 } 80 78 } … … 284 282 } 285 283 286 void WeaponSystem::setNewMunition(const std::string& munitionType, Munition * munitionToAdd)287 {288 this->munitionSet_[munitionType] = munitionToAdd;289 }290 291 292 //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition293 Munition * WeaponSystem::getMunitionType(const std::string& munitionType) const294 {295 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);296 if (it != this->munitionSet_.end())297 return it->second;298 else299 return 0;300 }301 302 284 void WeaponSystem::fire(unsigned int firemode) 303 285 { … … 306 288 it->second->fire(); 307 289 } 290 291 void WeaponSystem::reload() 292 { 293 for (std::map<unsigned int, WeaponSet *>::iterator it = this->weaponSets_.begin(); it != this->weaponSets_.end(); ++it) 294 it->second->reload(); 295 } 296 297 Munition * WeaponSystem::getMunition(SubclassIdentifier<Munition> * identifier) 298 { 299 if (!identifier || !identifier->getIdentifier()) 300 return 0; 301 302 std::map<Identifier *, Munition *>::iterator it = this->munitions_.find(identifier->getIdentifier()); 303 if (it != this->munitions_.end()) 304 { 305 return it->second; 306 } 307 else if (identifier->getIdentifier()->isA(Class(Munition))) 308 { 309 Munition* munition = identifier->fabricate(this); 310 this->munitions_[identifier->getIdentifier()] = munition; 311 return munition; 312 } 313 else 314 { 315 return 0; 316 } 317 } 308 318 }
Note: See TracChangeset
for help on using the changeset viewer.