Changeset 2331 for code/branches/weapon2
- Timestamp:
- Dec 3, 2008, 5:13:34 PM (16 years ago)
- Location:
- code/branches/weapon2/src/orxonox/objects/weaponSystem
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.cc
r2327 r2331 54 54 { 55 55 SUPER(Weapon, XMLPort, xmlelement, mode); 56 XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode); 56 57 } 57 58 … … 81 82 { 82 83 //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem 83 if ( this->parentWeaponSystem_->getMunitionType(munitionName) ) 84 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionName); 85 else 84 if (this->parentWeaponSystem_) 86 85 { 87 //create new munition with identifier 88 this->munitionIdentifier_ = ClassByString(munitionName); 89 this->munition_ = this->munitionIdentifier_.fabricate(this); 90 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 86 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 87 if ( munition ) 88 this->munition_ = munition; 89 else 90 { 91 //create new munition with identifier 92 this->munitionIdentifier_ = ClassByString(munitionName); 93 this->munition_ = this->munitionIdentifier_.fabricate(this); 94 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 95 } 91 96 } 92 97 } … … 96 101 * 97 102 */ 103 104 void Weapon::setMunitionType(std::string munitionType) 105 { this->munitionType_ = munitionType; } 106 107 std::string Weapon::getMunitionType() 108 { return this->munitionType_; } 109 98 110 Munition * Weapon::getAttachedMunition() 99 111 { return this->munition_; } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/Weapon.h
r2327 r2331 70 70 Timer<Weapon> *getMagazineTimer(); 71 71 72 void setMunitionType(std::string munitionType); 73 std::string getMunitionType(); 74 72 75 inline void setParentWeaponSlot(WeaponSlot *parentWeaponSlot) 73 76 { this->parentWeaponSlot_=parentWeaponSlot; }; … … 85 88 float magazineLoadingTime_; 86 89 Munition *munition_; 90 std::string munitionType_; 87 91 88 92 WeaponSlot *parentWeaponSlot_; -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponPack.cc
r2327 r2331 46 46 47 47 this->parentWeaponSystem_ = 0; 48 this->firemode_ = 1;48 this->firemode_ = 0; 49 49 50 50 } … … 68 68 for (int i=0; i < (int) this->weapons_.size(); i++) 69 69 { 70 COUT(0) << "WeaponPack::fire (attached from WeaponSet) "<< i << std::endl;70 COUT(0) << "WeaponPack::fire (attached from WeaponSet) from Weapon: "<< i << std::endl; 71 71 this->weapons_[i]->fire(); 72 72 } -
code/branches/weapon2/src/orxonox/objects/weaponSystem/WeaponSystem.cc
r2327 r2331 63 63 { 64 64 wPack->setParentWeaponSystem(this); 65 this->weaponSets_[firemode]->attachWeaponPack(wPack); 66 this->weaponPacks_[firemode] = wPack; 65 if (firemode < this->weaponSets_.size()) 66 this->weaponSets_[firemode]->attachWeaponPack(wPack); 67 this->weaponPacks_.push_back(wPack); 67 68 } 68 69 … … 85 86 Munition * WeaponSystem::getMunitionType(std::string munitionType) 86 87 { 87 return this->munitionSet_[munitionType]; 88 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 89 if (it != this->munitionSet_.end()) 90 return it->second; 91 else 92 return 0; 88 93 } 89 94 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2327 r2331 49 49 50 50 //how could it be loaded by XML 51 this->attachNeededMunition( "LaserGunMunition");51 this->attachNeededMunition(this->getMunitionType()); 52 52 } 53 53 -
code/branches/weapon2/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2272 r2331 55 55 float speed_; 56 56 57 58 57 }; 59 58 }
Note: See TracChangeset
for help on using the changeset viewer.