Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 9, 2009, 3:18:11 AM (16 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/WeaponPack.cc

    r2893 r2912  
    2727
    2828#include "OrxonoxStableHeaders.h"
    29 
    30 #include <vector>
     29#include "WeaponPack.h"
    3130
    3231#include "core/CoreIncludes.h"
    3332#include "core/XMLPort.h"
    34 #include "util/Debug.h"
     33#include "objects/worldentities/pawns/Pawn.h"
    3534
    36 #include "WeaponPack.h"
    37 #include "objects/worldentities/pawns/Pawn.h"
     35#include "Weapon.h"
     36#include "WeaponSlot.h"
    3837
    3938namespace orxonox
     
    4544        RegisterObject(WeaponPack);
    4645
    47         this->parentWeaponSystem_ = 0;
     46        this->weaponSystem_ = 0;
    4847        this->firemode_ = 0;
    4948
     49COUT(0) << "+WeaponPack" << std::endl;
    5050    }
    5151
    5252    WeaponPack::~WeaponPack()
    5353    {
     54COUT(0) << "~WeaponPack" << std::endl;
    5455    }
    5556
    56     int WeaponPack::getSize()
     57    void WeaponPack::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     58    {
     59        SUPER(WeaponPack, XMLPort, xmlelement, mode);
     60
     61        XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode);
     62        XMLPortParam(WeaponPack, "firemode", setFireMode, getFireMode, xmlelement, mode);
     63    }
     64
     65    int WeaponPack::getSize() const
    5766    {
    5867        return this->weapons_.size();
     
    6776    }
    6877
    69     Weapon * WeaponPack::getWeaponPointer(unsigned int n)
     78    Weapon * WeaponPack::getWeaponPointer(unsigned int n) const
    7079    {
    7180        return this->weapons_[n];
    72     }
    73 
    74     void WeaponPack::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    75     {
    76         SUPER(WeaponPack, XMLPort, xmlelement, mode);
    77 
    78         XMLPortObject(WeaponPack, Weapon, "", addWeapon, getWeapon, xmlelement, mode);
    79         XMLPortParam(WeaponPack, "firemode", setFireMode, getFireMode, xmlelement, mode);
    8081    }
    8182
     
    8586    }
    8687
    87     unsigned int WeaponPack::getFireMode()
     88    unsigned int WeaponPack::getFireMode() const
    8889    {
    8990        return this->firemode_;
     
    9596    }
    9697
    97     const Weapon * WeaponPack::getWeapon(unsigned int index)
     98    const Weapon * WeaponPack::getWeapon(unsigned int index) const
    9899    {
    99100        return weapons_[index];
    100101    }
    101102
    102     void WeaponPack::setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
     103    void WeaponPack::setWeaponSystemToAllWeapons(WeaponSystem * weaponSystem)
    103104    {
    104         for (int i=0; i < (int) this->weapons_.size(); i++)
    105         {
    106             this->weapons_[i]->setParentWeaponSystem(weaponSystem);
    107         }
    108 
     105        for (size_t i = 0; i < this->weapons_.size(); i++)
     106            this->weapons_[i]->setWeaponSystem(weaponSystem);
    109107    }
    110108
    111109    void WeaponPack::attachNeededMunitionToAllWeapons()
    112110    {
    113         for (int i=0; i < (int) this->weapons_.size(); i++)
     111        for (size_t i = 0; i < this->weapons_.size(); i++)
    114112        {
    115113            this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType());
    116114            this->weapons_[i]->setWeapon();
    117115        }
    118 
    119116    }
    120 
    121117}
Note: See TracChangeset for help on using the changeset viewer.