- Timestamp:
- Apr 18, 2009, 6:41:00 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponMode.cc
r2918 r2919 63 63 this->damage_ = 0; 64 64 this->muzzleOffset_ = Vector3::ZERO; 65 66 COUT(0) << "+WeaponMode" << std::endl;67 65 } 68 66 69 67 WeaponMode::~WeaponMode() 70 68 { 71 COUT(0) << "~WeaponMode" << std::endl;72 69 } 73 70 … … 221 218 return WorldEntity::FRONT; 222 219 } 223 224 /*225 WeaponMode::WeaponMode(BaseObject* creator) : StaticEntity(creator)226 {227 RegisterObject(WeaponMode);228 229 this->bulletReadyToShoot_ = true;230 this->magazineReadyToShoot_ = true;231 this->weaponSystem_ = 0;232 this->weaponPack_ = 0;233 this->weaponSlot_ = 0;234 this->bulletLoadingTime_ = 0;235 this->magazineLoadingTime_ = 0;236 this->bReloading_ = false;237 this->bulletAmount_= 0;238 this->magazineAmount_ = 0;239 this->munition_ = 0;240 this->unlimitedMunition_ = false;241 this->setObjectMode(0x0);242 COUT(0) << "+WeaponMode" << std::endl;243 }244 245 WeaponMode::~WeaponMode()246 {247 COUT(0) << "~WeaponMode" << std::endl;248 if (this->isInitialized() && this->weaponPack_)249 this->weaponPack_->removeWeapon(this);250 }251 252 void WeaponMode::XMLPort(Element& xmlelement, XMLPort::Mode mode)253 {254 SUPER(WeaponMode, XMLPort, xmlelement, mode);255 256 XMLPortParam(WeaponMode, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);257 XMLPortParam(WeaponMode, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);258 XMLPortParam(WeaponMode, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);259 XMLPortParam(WeaponMode, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);260 XMLPortParam(WeaponMode, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);261 XMLPortParam(WeaponMode, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);262 }263 264 void WeaponMode::setWeapon()265 {266 this->munition_->fillBullets();267 this->munition_->fillMagazines();268 }269 270 void WeaponMode::setMunition()271 {272 this->munition_->setMaxBullets(this->bulletAmount_);273 this->munition_->setMaxMagazines(this->magazineAmount_);274 }275 276 void WeaponMode::fire()277 {278 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)279 {280 this->bulletReadyToShoot_ = false;281 if ( this->unlimitedMunition_== true )282 {283 //shoot284 this->reloadBullet();285 this->createProjectile();286 }287 else288 {289 if ( this->munition_->bullets() > 0)290 {291 //shoot and reload292 this->takeBullets();293 this->reloadBullet();294 this->createProjectile();295 }296 //if there are no bullets, but magazines297 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )298 {299 //reload magazine300 this->takeMagazines();301 this->reloadMagazine();302 }303 else304 {305 //no magazines306 }307 }308 }309 else310 {311 //weapon not reloaded312 }313 }314 315 316 //weapon reloading317 void WeaponMode::bulletTimer(float bulletLoadingTime)318 {319 this->bReloading_ = true;320 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::bulletReloaded)));321 }322 void WeaponMode::magazineTimer(float magazineLoadingTime)323 {324 this->bReloading_ = true;325 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&WeaponMode::magazineReloaded)));326 }327 328 void WeaponMode::bulletReloaded()329 {330 this->bReloading_ = false;331 this->bulletReadyToShoot_ = true;332 }333 334 void WeaponMode::magazineReloaded()335 {336 this->bReloading_ = false;337 this->munition_->fillBullets();338 }339 340 341 342 void WeaponMode::attachNeededMunition(const std::string& munitionName)343 {344 // if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem345 if (this->weaponSystem_)346 {347 //getMunitionType returns 0 if there is no such munitionType348 Munition* munition = this->weaponSystem_->getMunitionType(munitionName);349 if ( munition )350 {351 this->munition_ = munition;352 this->setMunition();353 }354 else355 {356 //create new munition with identifier because there is no such munitionType357 this->munitionIdentifier_ = ClassByString(munitionName);358 this->munition_ = this->munitionIdentifier_.fabricate(this);359 this->weaponSystem_->setNewMunition(munitionName, this->munition_);360 this->setMunition();361 }362 }363 }364 365 366 Munition * WeaponMode::getAttachedMunition(const std::string& munitionType)367 {368 this->munition_ = this->weaponSystem_->getMunitionType(munitionType);369 return this->munition_;370 }371 */372 220 }
Note: See TracChangeset
for help on using the changeset viewer.