- 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/WeaponSet.cc
r2912 r2914 31 31 #include "core/CoreIncludes.h" 32 32 #include "core/XMLPort.h" 33 #include "objects/worldentities/pawns/Pawn.h"34 33 35 #include "Weapon.h" 36 #include "WeaponSlot.h" 34 #include "WeaponSystem.h" 37 35 #include "WeaponPack.h" 38 #include "WeaponSystem.h"39 36 40 37 namespace orxonox … … 42 39 CreateFactory(WeaponSet); 43 40 44 WeaponSet::WeaponSet(BaseObject* creator , int k) : BaseObject(creator)41 WeaponSet::WeaponSet(BaseObject* creator) : BaseObject(creator) 45 42 { 46 43 RegisterObject(WeaponSet); 47 44 48 45 this->weaponSystem_ = 0; 49 this-> attachedWeaponPack_ = 0;46 this->desiredFiremode_ = WeaponSystem::FIRE_MODE_UNASSIGNED; 50 47 51 48 COUT(0) << "+WeaponSet" << std::endl; … … 55 52 { 56 53 COUT(0) << "~WeaponSet" << std::endl; 54 55 if (this->isInitialized() && this->weaponSystem_) 56 this->weaponSystem_->removeWeaponSet(this); 57 57 } 58 58 … … 61 61 SUPER(WeaponSet, XMLPort, xmlelement, mode); 62 62 63 XMLPortParam(WeaponSet, "firemode", set FireMode, getFireMode, xmlelement, mode);63 XMLPortParam(WeaponSet, "firemode", setDesiredFiremode, getDesiredFiremode, xmlelement, mode); 64 64 } 65 65 /* 66 66 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 67 67 { … … 100 100 } 101 101 } 102 102 */ 103 103 104 104 void WeaponSet::fire() 105 105 { 106 //fires all WeaponSlots available for this weaponSet attached from the WeaponPack 107 if (this->attachedWeaponPack_) 108 this->attachedWeaponPack_->fire(); 106 // fire all WeaponPacks with their defined weaponmode 107 for (std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.begin(); it != this->weaponpacks_.end(); ++it) 108 if (it->second != WeaponSystem::WEAPON_MODE_UNASSIGNED) 109 it->first->fire(it->second); 110 } 111 112 void WeaponSet::setWeaponmodeLink(WeaponPack* weaponpack, unsigned int weaponmode) 113 { 114 this->weaponpacks_[weaponpack] = weaponmode; 115 } 116 117 void WeaponSet::removeWeaponmodeLink(WeaponPack* weaponpack) 118 { 119 this->weaponpacks_.erase(weaponpack); 120 } 121 122 unsigned int WeaponSet::getWeaponmodeLink(WeaponPack* weaponpack) 123 { 124 std::map<WeaponPack*, unsigned int>::iterator it = this->weaponpacks_.find(weaponpack); 125 if (it != this->weaponpacks_.end()) 126 return it->second; 127 else 128 return WeaponSystem::WEAPON_MODE_UNASSIGNED; 109 129 } 110 130 }
Note: See TracChangeset
for help on using the changeset viewer.