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/WeaponSystem.h

    r2896 r2912  
    3333#include "OrxonoxPrereqs.h"
    3434
     35#include <set>
     36#include <map>
     37
    3538#include "core/BaseObject.h"
    36 
    37 #include "WeaponSet.h"
    38 #include "WeaponPack.h"
    3939
    4040namespace orxonox
    4141{
     42    const unsigned int MAX_FIRE_MODES = 8;
    4243
    4344    class _OrxonoxExport WeaponSystem : public BaseObject
     
    4748            virtual ~WeaponSystem();
    4849
    49             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     50            void attachWeaponSlot(WeaponSlot * wSlot);
     51            WeaponSlot * getWeaponSlot(unsigned int index) const;
    5052
    51             void attachWeaponSlot(WeaponSlot *wSlot);
    52             void attachWeaponSet(WeaponSet *wSet);
    53             //void fire();
    54             void fire(WeaponMode::Enum fireMode);
    55             void attachWeaponPack(WeaponPack * wPack, unsigned int firemode);
    56             WeaponSet * getWeaponSetPointer(unsigned int n);
    57             WeaponSlot * getWeaponSlotPointer(unsigned int n);
    58             WeaponPack * getWeaponPackPointer(unsigned int n);
    59             void setNewMunition(std::string munitionType, Munition * munitionToAdd);
    60             void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);
    61             Munition * getMunitionType(std::string munitionType);
     53            void attachWeaponSet(WeaponSet * wSet);
     54            WeaponSet * getWeaponSet(unsigned int index) const;
    6255
    63             inline void setParentPawn(Pawn *parentPawn)
    64                 { parentPawn_=parentPawn; }
    65             inline Pawn * getParentPawn()
    66                 { return parentPawn_; }
     56            void attachWeaponPack(WeaponPack * wPack, unsigned int wSetNumber);
     57            WeaponPack * getWeaponPack(unsigned int index) const;
    6758
    68             inline int getWeaponSlotSize()
     59            void fire(unsigned int firemode);
     60
     61            void setNewMunition(const std::string& munitionType, Munition * munitionToAdd);
     62            void setNewSharedMunition(const std::string& munitionType, Munition * munitionToAdd);
     63            Munition * getMunitionType(const std::string& munitionType) const;
     64
     65            inline void setPawn(Pawn * pawn)
     66                { this->pawn_ = pawn; }
     67            inline Pawn * getPawn() const
     68                { return this->pawn_; }
     69
     70            inline int getWeaponSlotSize() const
    6971                { return this->weaponSlots_.size(); }
    7072
     73            static inline unsigned int getMaxFireModes()
     74                { return MAX_FIRE_MODES; }
     75            static inline unsigned int getFireModeMask(unsigned int firemode)
     76                { return (0x1 << firemode); }
     77
    7178        private:
    72             std::vector<WeaponSet *> weaponSets_;
    73             std::vector<WeaponSlot *> weaponSlots_;
    74             std::vector<WeaponPack *> weaponPacks_;
     79            std::map<unsigned int, WeaponSet *> weaponSets_;
     80            std::set<WeaponSlot *> weaponSlots_;
     81            std::set<WeaponPack *> weaponPacks_;
    7582            std::map<std::string, Munition *> munitionSet_;
    76             Pawn *parentPawn_;
     83            Pawn * pawn_;
    7784    };
    7885}
Note: See TracChangeset for help on using the changeset viewer.