Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 9, 2009, 3:18:11 AM (15 years ago)
Author:
landauf
Message:

Several small adjustments in the weaponsystem (like additional const keyword, includes moved from .h to .cc where possible, …)

Firemode is now an unsigned int instead of an Enum. Instead of "fire" and "altFire" use "fire 0" and "fire 1"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapons/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2893 r2912  
    2727
    2828#include "OrxonoxStableHeaders.h"
    29 
    30 #include <vector>
     29#include "WeaponSet.h"
    3130
    3231#include "core/CoreIncludes.h"
    3332#include "core/XMLPort.h"
    34 #include "util/Debug.h"
    3533#include "objects/worldentities/pawns/Pawn.h"
    3634
    37 #include "WeaponSet.h"
     35#include "Weapon.h"
     36#include "WeaponSlot.h"
    3837#include "WeaponPack.h"
     38#include "WeaponSystem.h"
    3939
    4040namespace orxonox
     
    4646        RegisterObject(WeaponSet);
    4747
    48         this->parentWeaponSystem_ = 0;
     48        this->weaponSystem_ = 0;
    4949        this->attachedWeaponPack_ = 0;
     50
     51COUT(0) << "+WeaponSet" << std::endl;
    5052    }
    5153
    5254    WeaponSet::~WeaponSet()
    5355    {
     56COUT(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);
    5464    }
    5565
    5666    void WeaponSet::attachWeaponPack(WeaponPack *wPack)
    5767    {
    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() ) )
    5969        {
    6070            this->attachedWeaponPack_ = wPack;
    6171            int wPackWeapon = 0;    //WeaponCounter for Attaching
    62            
     72
    6373            //should be possible to choose which slot to use
    6474            //attach every weapon of the weaponPack to a weaponSlot
     
    6777                //at the moment this function only works for one weaponPack in the entire WeaponSystem...
    6878                //it also takes the first free weaponSlot...
    69                 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full
     79                if ( this->weaponSystem_->getWeaponSlot(i)->getAttachedWeapon() == 0 && this->weaponSystem_->getWeaponSlot(i) != 0) //if slot not full
    7080                {
    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) );
    7484                    wPackWeapon++;
    7585                }
    7686                else
    7787                {
    78                     for (int k=0; k < this->parentWeaponSystem_->getWeaponSlotSize(); k++)
     88                    for (int k=0; k < this->weaponSystem_->getWeaponSlotSize(); k++)
    7989                    {
    80                         if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )
     90                        if ( this->weaponSystem_->getWeaponSlot(k)->getAttachedWeapon() == 0 )
    8191                        {
    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) );
    8595                            wPackWeapon++;
    8696                        }
     
    98108            this->attachedWeaponPack_->fire();
    99109    }
    100 
    101     void WeaponSet::setFireMode(const unsigned int firemode)
    102     {   this->firemode_ = firemode; }
    103 
    104     const unsigned int WeaponSet::getFireMode() const
    105     {   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 
    113110}
Note: See TracChangeset for help on using the changeset viewer.