- Timestamp:
- Feb 14, 2009, 10:17:35 PM (15 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed
r2261 r2662 37 37 #include "WeaponSystem.h" 38 38 39 39 40 /* WEAPONSYSTEM 40 41 * creates the WeaponSystem and the ability to use weapons and munition … … 45 46 namespace orxonox 46 47 { 48 CreateFactory(WeaponSystem); 49 47 50 WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator) 48 51 { … … 50 53 51 54 this->activeWeaponSet_ = 0; 52 this->parent SpaceShip_ = 0;55 this->parentPawn_ = 0; 53 56 } 54 57 … … 57 60 } 58 61 59 //creates empty weaponSet 62 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode) 63 { 64 if (firemode < this->weaponSets_.size()) 65 this->weaponSets_[firemode]->attachWeaponPack(wPack); 66 this->weaponPacks_.push_back(wPack); 67 } 68 69 void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot) 70 { 71 wSlot->setParentWeaponSystem(this); 72 this->weaponSlots_.push_back(wSlot); 73 } 74 60 75 void WeaponSystem::attachWeaponSet(WeaponSet *wSet) 61 76 { 77 wSet->setParentWeaponSystem(this); 62 78 this->weaponSets_.push_back(wSet); 63 wSet->setParentWeaponSystem(this);64 79 } 65 80 81 void WeaponSystem::setNewMunition(std::string munitionType, Munition * munitionToAdd) 82 { 83 this->munitionSet_[munitionType] = munitionToAdd; 84 } 85 86 //returns the Pointer to the munitionType 87 Munition * WeaponSystem::getMunitionType(std::string munitionType) 88 { 89 //COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl; 90 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 91 if (it != this->munitionSet_.end()) 92 return it->second; 93 else 94 return 0; 95 } 96 97 98 /* 66 99 //the first weaponSet is at n=0 67 100 void WeaponSystem::setActiveWeaponSet(unsigned int n) … … 69 102 if (n < this->weaponSets_.size()) 70 103 this->activeWeaponSet_ = this->weaponSets_[n]; 104 else 105 this->activeWeaponSet_ = this->weaponSets_[0]; 106 } 107 */ 108 109 110 //n is the n'th weaponSet, starting with zero 111 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n 112 void WeaponSystem::fire(WeaponMode::Enum n) 113 { 114 int set = 0; 115 switch (n) 116 { 117 case WeaponMode::fire: 118 set = 0; 119 break; 120 case WeaponMode::altFire: 121 set = 1; 122 break; 123 case WeaponMode::altFire2: 124 set = 2; 125 break; 126 } 127 //COUT(0) << "WeaponSystem::fire" << std::endl; 128 if (set < (int)this->weaponSets_.size()) 129 //COUT(0) << "WeaponSystem::fire - after if" << std::endl; 130 this->weaponSets_[set]->fire(); 71 131 } 72 132 73 //n is the n'th weaponSet, starting with zero74 //Spaceship.cc only needs to have the keybinding to a specific Set-number n75 void WeaponSystem::fire(unsigned int n)76 {77 if (n < this->weaponSets_.size())78 this->weaponSets_[n]->fire();79 }80 81 void WeaponSystem::fire()82 {83 if (this->activeWeaponSet_)84 this->activeWeaponSet_->fire();85 }86 133 87 134 WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n) … … 93 140 } 94 141 142 WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n) 143 { 144 if (n < this->weaponSlots_.size()) 145 return this->weaponSlots_[n]; 146 else 147 return 0; 148 } 149 150 WeaponPack * WeaponSystem::getWeaponPackPointer(unsigned int n) 151 { 152 if (n < this->weaponPacks_.size()) 153 return this->weaponPacks_[n]; 154 else 155 return 0; 156 } 157 95 158 void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 96 159 { 97 160 SUPER(WeaponSystem, XMLPort, xmlelement, mode); 98 161 } 99 162
Note: See TracChangeset
for help on using the changeset viewer.