- 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/WeaponSet.cc
r2893 r2912 27 27 28 28 #include "OrxonoxStableHeaders.h" 29 30 #include <vector> 29 #include "WeaponSet.h" 31 30 32 31 #include "core/CoreIncludes.h" 33 32 #include "core/XMLPort.h" 34 #include "util/Debug.h"35 33 #include "objects/worldentities/pawns/Pawn.h" 36 34 37 #include "WeaponSet.h" 35 #include "Weapon.h" 36 #include "WeaponSlot.h" 38 37 #include "WeaponPack.h" 38 #include "WeaponSystem.h" 39 39 40 40 namespace orxonox … … 46 46 RegisterObject(WeaponSet); 47 47 48 this-> parentWeaponSystem_ = 0;48 this->weaponSystem_ = 0; 49 49 this->attachedWeaponPack_ = 0; 50 51 COUT(0) << "+WeaponSet" << std::endl; 50 52 } 51 53 52 54 WeaponSet::~WeaponSet() 53 55 { 56 COUT(0) << "~WeaponSet" << std::endl; 57 } 58 59 void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode) 60 { 61 SUPER(WeaponSet, XMLPort, xmlelement, mode); 62 63 XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode); 54 64 } 55 65 56 66 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 57 67 { 58 if ( this-> parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )68 if ( this->weaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->weaponSystem_->getWeaponSlotSize() ) ) 59 69 { 60 70 this->attachedWeaponPack_ = wPack; 61 71 int wPackWeapon = 0; //WeaponCounter for Attaching 62 72 63 73 //should be possible to choose which slot to use 64 74 //attach every weapon of the weaponPack to a weaponSlot … … 67 77 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 68 78 //it also takes the first free weaponSlot... 69 if ( this-> parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full79 if ( this->weaponSystem_->getWeaponSlot(i)->getAttachedWeapon() == 0 && this->weaponSystem_->getWeaponSlot(i) != 0) //if slot not full 70 80 { 71 this->setWeaponSlots_.push_back( this-> parentWeaponSystem_->getWeaponSlotPointer(i) );72 this-> parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );73 this-> parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );81 this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(i) ); 82 this->weaponSystem_->getWeaponSlot(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 83 this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) ); 74 84 wPackWeapon++; 75 85 } 76 86 else 77 87 { 78 for (int k=0; k < this-> parentWeaponSystem_->getWeaponSlotSize(); k++)88 for (int k=0; k < this->weaponSystem_->getWeaponSlotSize(); k++) 79 89 { 80 if ( this-> parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )90 if ( this->weaponSystem_->getWeaponSlot(k)->getAttachedWeapon() == 0 ) 81 91 { 82 this->setWeaponSlots_.push_back( this-> parentWeaponSystem_->getWeaponSlotPointer(k) );83 this-> parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );84 this-> parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );92 this->setWeaponSlots_.push_back( this->weaponSystem_->getWeaponSlot(k) ); 93 this->weaponSystem_->getWeaponSlot(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 94 this->weaponSystem_->getPawn()->attach( wPack->getWeaponPointer(wPackWeapon) ); 85 95 wPackWeapon++; 86 96 } … … 98 108 this->attachedWeaponPack_->fire(); 99 109 } 100 101 void WeaponSet::setFireMode(const unsigned int firemode)102 { this->firemode_ = firemode; }103 104 const unsigned int WeaponSet::getFireMode() const105 { return this->firemode_; }106 107 void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode)108 {109 SUPER(WeaponSet, XMLPort, xmlelement, mode);110 XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode);111 }112 113 110 }
Note: See TracChangeset
for help on using the changeset viewer.