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/Weapon.cc

    r2893 r2912  
    2828
    2929#include "OrxonoxStableHeaders.h"
     30#include "Weapon.h"
    3031
    3132#include "core/CoreIncludes.h"
    3233#include "core/XMLPort.h"
    33 #include "util/Debug.h"
    34 
    35 #include "Weapon.h"
     34
     35#include "Munition.h"
     36#include "WeaponSystem.h"
    3637
    3738namespace orxonox
     
    4546        this->bulletReadyToShoot_ = true;
    4647        this->magazineReadyToShoot_ = true;
    47         this->parentWeaponSystem_ = 0;
     48        this->weaponSystem_ = 0;
    4849        this->attachedToWeaponSlot_ = 0;
    4950        this->bulletLoadingTime_ = 0;
     
    5556        this->unlimitedMunition_ = false;
    5657        this->setObjectMode(0x0);
     58
     59COUT(0) << "+Weapon" << std::endl;
    5760    }
    5861
    5962    Weapon::~Weapon()
    6063    {
    61     }
    62 
     64COUT(0) << "~Weapon" << std::endl;
     65    }
    6366
    6467    void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     
    152155
    153156
    154     void Weapon::attachNeededMunition(std::string munitionName)
     157    void Weapon::attachNeededMunition(const std::string& munitionName)
    155158    {
    156159        /*  if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    157160        */
    158         if (this->parentWeaponSystem_)
     161        if (this->weaponSystem_)
    159162        {
    160163            //getMunitionType returns 0 if there is no such munitionType
    161             Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
     164            Munition* munition = this->weaponSystem_->getMunitionType(munitionName);
    162165            if ( munition )
    163166            {
     
    170173                this->munitionIdentifier_ = ClassByString(munitionName);
    171174                this->munition_ = this->munitionIdentifier_.fabricate(this);
    172                 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
     175                this->weaponSystem_->setNewMunition(munitionName, this->munition_);
    173176                this->setMunition();
    174177            }
     
    177180
    178181
    179     Munition * Weapon::getAttachedMunition(std::string munitionType)
    180     {
    181         this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
     182    Munition * Weapon::getAttachedMunition(const std::string& munitionType)
     183    {
     184        this->munition_ = this->weaponSystem_->getMunitionType(munitionType);
    182185        return this->munition_;
    183186    }
     
    193196
    194197    //get and set functions for XMLPort
    195     void Weapon::setMunitionType(std::string munitionType)
     198    void Weapon::setMunitionType(const std::string& munitionType)
    196199    {   this->munitionType_ = munitionType; }
    197200
    198     const std::string Weapon::getMunitionType()
     201    const std::string& Weapon::getMunitionType() const
    199202    {   return this->munitionType_;  }
    200203
     
    202205    {   this->bulletLoadingTime_ = loadingTime; }
    203206
    204     const float Weapon::getBulletLoadingTime()
     207    const float Weapon::getBulletLoadingTime() const
    205208    {   return this->bulletLoadingTime_;  }
    206209
     
    208211    {   this->magazineLoadingTime_ = loadingTime; }
    209212
    210     const float Weapon::getMagazineLoadingTime()
     213    const float Weapon::getMagazineLoadingTime() const
    211214    {   return this->magazineLoadingTime_;  }
    212215
     
    214217    {   this->bulletAmount_ = amount; }
    215218
    216     const unsigned int Weapon::getBulletAmount()
     219    const unsigned int Weapon::getBulletAmount() const
    217220    {   return this->bulletAmount_;  }
    218221
     
    220223    {   this->magazineAmount_ = amount; }
    221224
    222     const unsigned int Weapon::getMagazineAmount()
     225    const unsigned int Weapon::getMagazineAmount() const
    223226    {   return this->magazineAmount_;   }
    224227
     
    226229    {   this->unlimitedMunition_ = unlimitedMunition;   }
    227230
    228     const bool Weapon::getUnlimitedMunition()
     231    const bool Weapon::getUnlimitedMunition() const
    229232    {   return this->unlimitedMunition_;    }
    230233
Note: See TracChangeset for help on using the changeset viewer.