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"

Location:
code/branches/weapons/src/orxonox/objects/worldentities
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/weapons/src/orxonox/objects/worldentities/ControllableEntity.h

    r2851 r2912  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
    3433#include "MobileEntity.h"
    35 #include "objects/weaponSystem/WeaponSystem.h"
    3634
    3735namespace orxonox
     
    8381                { this->rotateRoll(Vector2(value, 0)); }
    8482
    85             virtual void fire(WeaponMode::Enum fireMode) {}
    86             virtual void altFire(WeaponMode::Enum fireMode) {}
     83            virtual void fire(unsigned int firemode) {}
    8784
    8885            virtual void boost() {}
  • code/branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2896 r2912  
    3939#include "objects/worldentities/ParticleSpawner.h"
    4040#include "objects/worldentities/ExplosionChunk.h"
     41#include "objects/weaponSystem/WeaponSystem.h"
     42#include "objects/weaponSystem/WeaponSlot.h"
     43#include "objects/weaponSystem/WeaponPack.h"
     44#include "objects/weaponSystem/WeaponSet.h"
    4145
    4246namespace orxonox
     
    6670        {
    6771            this->weaponSystem_ = new WeaponSystem(this);
    68             this->weaponSystem_->setParentPawn(this);
     72            this->weaponSystem_->setPawn(this);
    6973        }
    7074        else
     
    100104        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
    101105
    102         XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode);
    103         XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode);
    104         XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);
     106        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
     107        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
     108        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPack, getWeaponPack, xmlelement, mode);
    105109    }
    106110
     
    119123        if (this->weaponSystem_)
    120124        {
    121             if (this->fire_ & WeaponMode::fire)
    122                 this->weaponSystem_->fire(WeaponMode::fire);
    123             if (this->fire_ & WeaponMode::altFire)
    124                 this->weaponSystem_->fire(WeaponMode::altFire);
    125             if (this->fire_ & WeaponMode::altFire2)
    126                 this->weaponSystem_->fire(WeaponMode::altFire2);
     125            for (unsigned int firemode = 0; firemode < WeaponSystem::getMaxFireModes(); firemode++)
     126                if (this->fire_ & WeaponSystem::getFireModeMask(firemode))
     127                    this->weaponSystem_->fire(firemode);
    127128        }
    128129        this->fire_ = this->firehack_;
     
    252253    }
    253254
    254     void Pawn::fire(WeaponMode::Enum fireMode)
    255     {
    256         this->firehack_ |= fireMode;
     255    void Pawn::fire(unsigned int firemode)
     256    {
     257        this->firehack_ |= WeaponSystem::getFireModeMask(firemode);
    257258    }
    258259
     
    275276    *       --> e.g. Pickup-Items
    276277    */
    277     void Pawn::setWeaponSlot(WeaponSlot * wSlot)
     278    void Pawn::addWeaponSlot(WeaponSlot * wSlot)
    278279    {
    279280        this->attach(wSlot);
     
    285286    {
    286287        if (this->weaponSystem_)
    287             return this->weaponSystem_->getWeaponSlotPointer(index);
     288            return this->weaponSystem_->getWeaponSlot(index);
    288289        else
    289290            return 0;
    290291    }
    291292
    292     void Pawn::setWeaponPack(WeaponPack * wPack)
    293     {
    294         if (this->weaponSystem_)
    295         {
    296             wPack->setParentWeaponSystem(this->weaponSystem_);
    297             wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_);
    298             this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );
    299             wPack->attachNeededMunitionToAllWeapons();
    300         }
     293    void Pawn::addWeaponPack(WeaponPack * wPack)
     294    {
     295        if (this->weaponSystem_)
     296            this->weaponSystem_->attachWeaponPack(wPack, wPack->getFireMode());
    301297    }
    302298
     
    304300    {
    305301        if (this->weaponSystem_)
    306             return this->weaponSystem_->getWeaponPackPointer(firemode);
     302            return this->weaponSystem_->getWeaponPack(firemode);
    307303        else
    308304            return 0;
    309305    }
    310306
    311     void Pawn::setWeaponSet(WeaponSet * wSet)
     307    void Pawn::addWeaponSet(WeaponSet * wSet)
    312308    {
    313309        if (this->weaponSystem_)
     
    318314    {
    319315        if (this->weaponSystem_)
    320             return this->weaponSystem_->getWeaponSetPointer(index);
     316            return this->weaponSystem_->getWeaponSet(index);
    321317        else
    322318            return 0;
  • code/branches/weapons/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2826 r2912  
    3434#include "objects/worldentities/ControllableEntity.h"
    3535#include "objects/RadarViewable.h"
    36 #include "objects/weaponSystem/WeaponSystem.h"
    3736
    3837namespace orxonox
     
    4039    class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable
    4140    {
     41        friend class WeaponSystem;
     42
    4243        public:
    4344            Pawn(BaseObject* creator);
     
    7980            virtual void kill();
    8081
    81             virtual void fire(WeaponMode::Enum fireMode);
     82            virtual void fire(unsigned int firemode);
    8283            virtual void postSpawn();
    8384
    84             void setWeaponSlot(WeaponSlot * wSlot);
     85            void addWeaponSlot(WeaponSlot * wSlot);
    8586            WeaponSlot * getWeaponSlot(unsigned int index) const;
    86             void setWeaponPack(WeaponPack * wPack);
     87            void addWeaponPack(WeaponPack * wPack);
    8788            WeaponPack * getWeaponPack(unsigned int firemode) const;
    88             void setWeaponSet(WeaponSet * wSet);
     89            void addWeaponSet(WeaponSet * wSet);
    8990            WeaponSet * getWeaponSet(unsigned int index) const;
    9091
     
    134135            float spawnparticleduration_;
    135136            unsigned int numexplosionchunks_;
     137
     138        private:
     139            inline void setWeaponSystem(WeaponSystem* weaponsystem)
     140                { this->weaponSystem_ = weaponsystem; }
    136141    };
    137142
  • code/branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2896 r2912  
    196196    }
    197197
    198     void Spectator::fire(WeaponMode::Enum fireMode)
     198    void Spectator::fire(unsigned int firemode)
    199199    {
    200200        if (this->getPlayer())
  • code/branches/weapons/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2662 r2912  
    5757            virtual void rotateRoll(const Vector2& value);
    5858
    59             virtual void fire(WeaponMode::Enum fireMode);
     59            virtual void fire(unsigned int firemode);
    6060            virtual void greet();
    6161
Note: See TracChangeset for help on using the changeset viewer.