Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 2:10:11 AM (16 years ago)
Author:
landauf
Message:

merged weapon2 branch to presentation

Location:
code/branches/presentation
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation

  • code/branches/presentation/src/orxonox/objects/worldentities/Backlight.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/Backlight.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/Camera.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/Camera.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.h

    r2485 r2493  
    3333
    3434#include "MobileEntity.h"
     35#include "objects/weaponSystem/WeaponSystem.h"
    3536
    3637namespace orxonox
     
    8182                { this->rotateRoll(Vector2(value, 0)); }
    8283
    83             virtual void fire() {}
    84             virtual void altFire() {}
     84            virtual void fire(WeaponMode::Enum fireMode) {}
     85            virtual void altFire(WeaponMode::Enum fireMode) {}
    8586
    8687            virtual void boost() {}
  • code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2485 r2493  
    3737#include "objects/infos/PlayerInfo.h"
    3838#include "objects/gametypes/Gametype.h"
    39 #include "objects/weaponSystem/WeaponSystem.h"
    4039#include "objects/worldentities/ParticleSpawner.h"
    4140#include "objects/worldentities/ExplosionChunk.h"
     
    5251
    5352        this->bAlive_ = true;
     53        this->fire_ = 0x0;
    5454
    5555        this->health_ = 0;
     
    5858
    5959        this->lastHitOriginator_ = 0;
    60         this->weaponSystem_ = 0;
    6160
    6261        this->spawnparticleduration_ = 3.0f;
    6362
    64         /*
    65         //WeaponSystem
    66         weaponSystem_ = new WeaponSystem();
    67         WeaponSet * weaponSet1 = new WeaponSet(1);
    68         this->weaponSystem_->attachWeaponSet(weaponSet1);
    69         this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true);
    70         */
     63        if (Core::isMaster())
     64        {
     65            this->weaponSystem_ = new WeaponSystem(this);
     66            this->weaponSystem_->setParentPawn(this);
     67        }
     68        else
     69            this->weaponSystem_ = 0;
    7170
    7271        this->setRadarObjectColour(ColourValue::Red);
     
    8281            for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
    8382                it->destroyedPawn(this);
     83
     84            if (this->weaponSystem_)
     85                delete this->weaponSystem_;
    8486        }
    8587    }
     
    9597        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
    9698        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
     99
     100        XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode);
     101        XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode);
     102        XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);
    97103    }
    98104
     
    102108        registerVariable(this->health_,        variableDirection::toclient);
    103109        registerVariable(this->initialHealth_, variableDirection::toclient);
     110        registerVariable(this->fire_,          variableDirection::toclient);
    104111    }
    105112
     
    107114    {
    108115        SUPER(Pawn, tick, dt);
     116
     117        if (this->weaponSystem_)
     118        {
     119            if (this->fire_ & WeaponMode::fire)
     120                this->weaponSystem_->fire(WeaponMode::fire);
     121            if (this->fire_ & WeaponMode::altFire)
     122                this->weaponSystem_->fire(WeaponMode::altFire);
     123            if (this->fire_ & WeaponMode::altFire2)
     124                this->weaponSystem_->fire(WeaponMode::altFire2);
     125        }
     126        this->fire_ = 0x0;
    109127
    110128        if (this->health_ <= 0)
     
    205223    }
    206224
    207     void Pawn::fire()
    208     {
    209         if (this->weaponSystem_)
    210             this->weaponSystem_->fire();
     225    void Pawn::fire(WeaponMode::Enum fireMode)
     226    {
     227        this->fire_ |= fireMode;
    211228    }
    212229
     
    217234            this->spawneffect();
    218235    }
     236
     237    void Pawn::setWeaponSlot(WeaponSlot * wSlot)
     238    {
     239        this->attach(wSlot);
     240        if (this->weaponSystem_)
     241            this->weaponSystem_->attachWeaponSlot(wSlot);
     242    }
     243
     244    WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
     245    {
     246        if (this->weaponSystem_)
     247            return this->weaponSystem_->getWeaponSlotPointer(index);
     248        else
     249            return 0;
     250    }
     251
     252    void Pawn::setWeaponPack(WeaponPack * wPack)
     253    {
     254        if (this->weaponSystem_)
     255        {
     256            wPack->setParentWeaponSystem(this->weaponSystem_);
     257            wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_);
     258            this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );
     259            wPack->attachNeededMunitionToAllWeapons();
     260        }
     261    }
     262
     263    WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const
     264    {
     265        if (this->weaponSystem_)
     266            return this->weaponSystem_->getWeaponPackPointer(firemode);
     267        else
     268            return 0;
     269    }
     270
     271    void Pawn::setWeaponSet(WeaponSet * wSet)
     272    {
     273        if (this->weaponSystem_)
     274            this->weaponSystem_->attachWeaponSet(wSet);
     275    }
     276
     277    WeaponSet * Pawn::getWeaponSet(unsigned int index) const
     278    {
     279        if (this->weaponSystem_)
     280            return this->weaponSystem_->getWeaponSetPointer(index);
     281        else
     282            return 0;
     283    }
     284
    219285
    220286    ///////////////////
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2485 r2493  
    3434#include "objects/worldentities/ControllableEntity.h"
    3535#include "objects/RadarViewable.h"
     36#include "objects/weaponSystem/WeaponSystem.h"
    3637
    3738namespace orxonox
     
    7576            virtual void kill();
    7677
    77             virtual void fire();
     78            virtual void fire(WeaponMode::Enum fireMode);
    7879
    7980            virtual void postSpawn();
     81
     82            void setWeaponSlot(WeaponSlot * wSlot);
     83            WeaponSlot * getWeaponSlot(unsigned int index) const;
     84            void setWeaponPack(WeaponPack * wPack);
     85            WeaponPack * getWeaponPack(unsigned int firemode) const;
     86            void setWeaponSet(WeaponSet * wSet);
     87            WeaponSet * getWeaponSet(unsigned int index) const;
    8088
    8189            inline const WorldEntity* getWorldEntity() const
     
    111119
    112120            WeaponSystem* weaponSystem_;
     121            unsigned int fire_;
    113122
    114123            std::string spawnparticlesource_;
     
    117126    };
    118127
    119     class _OrxonoxExport PawnListener : public OrxonoxClass
     128    class _OrxonoxExport PawnListener : virtual public OrxonoxClass
    120129    {
    121130        friend class Pawn;
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2485 r2493  
    196196    }
    197197
    198     void Spectator::fire()
     198    void Spectator::fire(WeaponMode::Enum fireMode)
    199199    {
    200200        if (this->getPlayer())
  • code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2485 r2493  
    5757            virtual void rotateRoll(const Vector2& value);
    5858
    59             virtual void fire();
     59            virtual void fire(WeaponMode::Enum fireMode);
    6060            virtual void greet();
    6161
  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset for help on using the changeset viewer.