- Timestamp:
- Apr 10, 2009, 12:05:01 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2912 r2914 34 34 35 35 #include "Weapon.h" 36 #include "WeaponSystem.h" 36 37 37 38 namespace orxonox … … 43 44 RegisterObject(WeaponSlot); 44 45 45 this->unlimitedAmmo_ = false; 46 this->attachedWeapon_ = 0; 46 this->weaponSystem_ = 0; 47 this->weapon_ = 0; 48 47 49 this->setObjectMode(0x0); 48 50 … … 53 55 { 54 56 COUT(0) << "~WeaponSlot" << std::endl; 57 58 if (this->isInitialized() && this->weaponSystem_) 59 this->weaponSystem_->removeWeaponSlot(this); 55 60 } 56 61 … … 58 63 { 59 64 SUPER(WeaponSlot, XMLPort, xmlelement, mode); 60 }61 65 62 /*sets the munition type 63 *unlimited: true 64 *limited: false (in this case there will be munition) 65 */ 66 void WeaponSlot::setAmmoType(bool isUnlimited) 67 { 68 unlimitedAmmo_ = isUnlimited; 69 } 70 71 72 void WeaponSlot::fire() 73 { 74 if ( this->attachedWeapon_ ) 75 //COUT(0) << "WeaponSlot::fire" << std::endl; 76 this->attachedWeapon_->fire(); 66 // ... 77 67 } 78 68 79 69 void WeaponSlot::attachWeapon(Weapon *weapon) 80 70 { 81 this->attachedWeapon_ = weapon; 82 weapon->setAttachedToWeaponSlot(this); 83 //COUT(0) << "WeaponSlot::attachWeapon position=" << this->getWorldPosition() << std::endl; 84 weapon->setPosition(this->getPosition()); 71 if (this->weapon_) 72 this->removeWeapon(); 73 74 this->weapon_ = weapon; 75 76 if (this->weapon_) 77 { 78 this->weapon_->setWeaponSlot(this); 79 this->weapon_->setPosition(this->getPosition()); 80 } 85 81 } 86 82 87 Weapon * WeaponSlot::getAttachedWeapon() const83 void WeaponSlot::removeWeapon() 88 84 { 89 return this->attachedWeapon_; 85 if (this->weapon_) 86 { 87 this->weapon_->setWeaponSlot(0); 88 this->weapon_ = 0; 89 } 90 90 } 91 91 }
Note: See TracChangeset
for help on using the changeset viewer.