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/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;
Note: See TracChangeset for help on using the changeset viewer.