- Timestamp:
- Apr 9, 2009, 3:18:11 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/Weapon.cc
r2893 r2912 28 28 29 29 #include "OrxonoxStableHeaders.h" 30 #include "Weapon.h" 30 31 31 32 #include "core/CoreIncludes.h" 32 33 #include "core/XMLPort.h" 33 #include "util/Debug.h" 34 35 #include "Weapon .h"34 35 #include "Munition.h" 36 #include "WeaponSystem.h" 36 37 37 38 namespace orxonox … … 45 46 this->bulletReadyToShoot_ = true; 46 47 this->magazineReadyToShoot_ = true; 47 this-> parentWeaponSystem_ = 0;48 this->weaponSystem_ = 0; 48 49 this->attachedToWeaponSlot_ = 0; 49 50 this->bulletLoadingTime_ = 0; … … 55 56 this->unlimitedMunition_ = false; 56 57 this->setObjectMode(0x0); 58 59 COUT(0) << "+Weapon" << std::endl; 57 60 } 58 61 59 62 Weapon::~Weapon() 60 63 { 61 } 62 64 COUT(0) << "~Weapon" << std::endl; 65 } 63 66 64 67 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) … … 152 155 153 156 154 void Weapon::attachNeededMunition( std::stringmunitionName)157 void Weapon::attachNeededMunition(const std::string& munitionName) 155 158 { 156 159 /* 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 157 160 */ 158 if (this-> parentWeaponSystem_)161 if (this->weaponSystem_) 159 162 { 160 163 //getMunitionType returns 0 if there is no such munitionType 161 Munition* munition = this-> parentWeaponSystem_->getMunitionType(munitionName);164 Munition* munition = this->weaponSystem_->getMunitionType(munitionName); 162 165 if ( munition ) 163 166 { … … 170 173 this->munitionIdentifier_ = ClassByString(munitionName); 171 174 this->munition_ = this->munitionIdentifier_.fabricate(this); 172 this-> parentWeaponSystem_->setNewMunition(munitionName, this->munition_);175 this->weaponSystem_->setNewMunition(munitionName, this->munition_); 173 176 this->setMunition(); 174 177 } … … 177 180 178 181 179 Munition * Weapon::getAttachedMunition( std::stringmunitionType)180 { 181 this->munition_ = this-> parentWeaponSystem_->getMunitionType(munitionType);182 Munition * Weapon::getAttachedMunition(const std::string& munitionType) 183 { 184 this->munition_ = this->weaponSystem_->getMunitionType(munitionType); 182 185 return this->munition_; 183 186 } … … 193 196 194 197 //get and set functions for XMLPort 195 void Weapon::setMunitionType( std::stringmunitionType)198 void Weapon::setMunitionType(const std::string& munitionType) 196 199 { this->munitionType_ = munitionType; } 197 200 198 const std::string Weapon::getMunitionType()201 const std::string& Weapon::getMunitionType() const 199 202 { return this->munitionType_; } 200 203 … … 202 205 { this->bulletLoadingTime_ = loadingTime; } 203 206 204 const float Weapon::getBulletLoadingTime() 207 const float Weapon::getBulletLoadingTime() const 205 208 { return this->bulletLoadingTime_; } 206 209 … … 208 211 { this->magazineLoadingTime_ = loadingTime; } 209 212 210 const float Weapon::getMagazineLoadingTime() 213 const float Weapon::getMagazineLoadingTime() const 211 214 { return this->magazineLoadingTime_; } 212 215 … … 214 217 { this->bulletAmount_ = amount; } 215 218 216 const unsigned int Weapon::getBulletAmount() 219 const unsigned int Weapon::getBulletAmount() const 217 220 { return this->bulletAmount_; } 218 221 … … 220 223 { this->magazineAmount_ = amount; } 221 224 222 const unsigned int Weapon::getMagazineAmount() 225 const unsigned int Weapon::getMagazineAmount() const 223 226 { return this->magazineAmount_; } 224 227 … … 226 229 { this->unlimitedMunition_ = unlimitedMunition; } 227 230 228 const bool Weapon::getUnlimitedMunition() 231 const bool Weapon::getUnlimitedMunition() const 229 232 { return this->unlimitedMunition_; } 230 233
Note: See TracChangeset
for help on using the changeset viewer.