- Timestamp:
- Mar 12, 2009, 5:05:18 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponsystem/src/orxonox/objects/weaponSystem/Weapon.cc
r2662 r2778 65 65 XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode); 66 66 XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode); 67 XMLPortParam(Weapon, "bSharedMunition", setSharedMunition, getSharedMunition, xmlelement, mode); 67 68 } 68 69 … … 97 98 { 98 99 //COUT(0) << "LaserGun::fire - no magazines" << std::endl; 99 // actions100 //no magazines 100 101 } 101 102 } … … 103 104 { 104 105 //COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl; 105 // actions106 //weapon not reloaded 106 107 } 107 108 … … 141 142 //COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl; 142 143 //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 144 //if the weapon shares one munitionType put it into sharedMunitionSet 145 //else to munitionSet 143 146 if (this->parentWeaponSystem_) 144 147 { 145 //COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 146 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 147 if ( munition ) 148 this->munition_ = munition; 149 else 150 { 151 //create new munition with identifier 152 //COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl; 148 if (this->bSharedMunition_ == false) 149 { 153 150 this->munitionIdentifier_ = ClassByString(munitionName); 154 151 this->munition_ = this->munitionIdentifier_.fabricate(this); 155 152 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 156 153 } 154 else 155 { 156 //COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 157 //getMunitionType returns 0 if there is no such munitionType 158 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 159 if ( munition ) 160 this->munition_ = munition; 161 else 162 { 163 //create new munition with identifier because there is no such munitionType 164 //COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl; 165 this->munitionIdentifier_ = ClassByString(munitionName); 166 this->munition_ = this->munitionIdentifier_.fabricate(this); 167 this->parentWeaponSystem_->setNewSharedMunition(munitionName, this->munition_); 168 } 169 } 157 170 } 158 171 } … … 180 193 const float Weapon::getMagazineLoadingTime() 181 194 { return this->magazineLoadingTime_; } 195 196 void Weapon::setSharedMunition(bool bSharedMunition) 197 { this->bSharedMunition_ = bSharedMunition; } 198 199 const bool Weapon::getSharedMunition() 200 { return this->bSharedMunition_; } 182 201 183 202
Note: See TracChangeset
for help on using the changeset viewer.