Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 12:58:47 AM (15 years ago)
Author:
dafrick
Message:

Reverted to revision 2906 (because I'm too stupid to merge correctly, 2nd try will follow shortly. ;))

Location:
code/branches/questsystem5
Files:
2 deleted
16 edited

Legend:

Unmodified
Added
Removed
  • code/branches/questsystem5

  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/Munition.cc

    r2907 r2908  
    105105    void Munition::fillBullets()
    106106    {
     107//COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl;
    107108        this->bullets_ = this->maxBullets_;
    108109    }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.cc

    r2907 r2908  
    4242    {
    4343        RegisterObject(Weapon);
    44 
    4544        this->bulletReadyToShoot_ = true;
    4645        this->magazineReadyToShoot_ = true;
    4746        this->parentWeaponSystem_ = 0;
    4847        this->attachedToWeaponSlot_ = 0;
     48        this->munition_ = 0;
    4949        this->bulletLoadingTime_ = 0;
    5050        this->magazineLoadingTime_ = 0;
    5151        this->bReloading_ = false;
    52         this->bulletAmount_= 0;
    53         this->magazineAmount_ = 0;
    54         this->munition_ = 0;
    55         this->unlimitedMunition_ = false;
     52
    5653        this->setObjectMode(0x0);
    5754    }
     
    6865        XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
    6966        XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
    70         XMLPortParam(Weapon, "bullets", setBulletAmount, getBulletAmount, xmlelement, mode);
    71         XMLPortParam(Weapon, "magazines", setMagazineAmount, getMagazineAmount, xmlelement, mode);
    72         XMLPortParam(Weapon, "unlimitedMunition", setUnlimitedMunition, getUnlimitedMunition, xmlelement, mode);
    7367    }
    7468
     
    7973    }
    8074
    81     void Weapon::setMunition()
    82     {
    83         this->munition_->setMaxBullets(this->bulletAmount_);
    84         this->munition_->setMaxMagazines(this->magazineAmount_);
    85     }
    8675
    8776    void Weapon::fire()
    8877    {
     78//COUT(0) << "LaserGun::fire, this=" << this << std::endl;
    8979        if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
    9080        {
     81//COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;
     82//COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl;
    9183            this->bulletReadyToShoot_ = false;
    92             if ( this->unlimitedMunition_== true )
     84            if ( this->munition_->bullets() > 0)
    9385            {
    9486                //shoot
    95                 this->reloadBullet();
     87                this->takeBullets();
    9688                this->createProjectile();
     89            }
     90            //if there are no bullets, but magazines
     91            else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
     92            {
     93//COUT(0) << "LaserGun::fire - no bullets" << std::endl;
     94                this->takeMagazines();
    9795            }
    9896            else
    9997            {
    100                 if ( this->munition_->bullets() > 0)
    101                 {
    102                     //shoot and reload
    103                     this->takeBullets();
    104                     this->reloadBullet();
    105                     this->createProjectile();
    106                 }
    107                 //if there are no bullets, but magazines
    108                 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
    109                 {
    110                     //reload magazine
    111                     this->takeMagazines();
    112                     this->reloadMagazine();
    113                 }
    114                 else
    115                 {
    116                     //no magazines
    117                 }
     98//COUT(0) << "LaserGun::fire - no magazines" << std::endl;
     99                //actions
    118100            }
    119101        }
    120102        else
    121103        {
    122             //weapon not reloaded
     104//COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl;
     105            //actions
    123106        }
    124107
     
    126109
    127110
    128     //weapon reloading
    129111    void Weapon::bulletTimer(float bulletLoadingTime)
    130112    {
     113//COUT(0) << "Weapon::bulletTimer started" << std::endl;
    131114        this->bReloading_ = true;
    132115        this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
     
    134117    void Weapon::magazineTimer(float magazineLoadingTime)
    135118    {
     119//COUT(0) << "Weapon::magazineTimer started" << std::endl;
    136120        this->bReloading_ = true;
    137121        this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
     
    148132        this->bReloading_ = false;
    149133        this->munition_->fillBullets();
     134        this->magazineReadyToShoot_ = true;
     135        this->bulletReadyToShoot_ = true;
    150136    }
    151 
    152137
    153138
    154139    void Weapon::attachNeededMunition(std::string munitionName)
    155140    {
    156         /*  if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    157         */
     141//COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl;
     142        //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
    158143        if (this->parentWeaponSystem_)
    159144        {
    160             //getMunitionType returns 0 if there is no such munitionType
     145//COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl;
    161146            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
    162147            if ( munition )
    163             {
    164148                this->munition_ = munition;
    165                 this->setMunition();
    166             }
    167149            else
    168150            {
    169                 //create new munition with identifier because there is no such munitionType
     151                //create new munition with identifier
     152//COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl;
    170153                this->munitionIdentifier_ = ClassByString(munitionName);
    171154                this->munition_ = this->munitionIdentifier_.fabricate(this);
    172155                this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
    173                 this->setMunition();
    174156            }
    175157        }
     
    177159
    178160
    179     Munition * Weapon::getAttachedMunition(std::string munitionType)
    180     {
    181         this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
    182         return this->munition_;
    183     }
     161     /*get and set functions
     162     *
     163     */
    184164
    185 
    186     //these function are defined in the weapon classes
    187     void Weapon::takeBullets() { };
    188     void Weapon::createProjectile() { };
    189     void Weapon::takeMagazines() { };
    190     void Weapon::reloadBullet() { };
    191     void Weapon::reloadMagazine() { };
    192 
    193 
    194     //get and set functions for XMLPort
    195165    void Weapon::setMunitionType(std::string munitionType)
    196166    {   this->munitionType_ = munitionType; }
     
    211181    {   return this->magazineLoadingTime_;  }
    212182
    213     void Weapon::setBulletAmount(unsigned int amount)
    214     {   this->bulletAmount_ = amount; }
    215183
    216     const unsigned int Weapon::getBulletAmount()
    217     {   return this->bulletAmount_;  }
     184    Munition * Weapon::getAttachedMunition(std::string munitionType)
     185    {
     186//COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl;
     187        this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
     188//COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl;
     189        return this->munition_;
     190    }
    218191
    219     void Weapon::setMagazineAmount(unsigned int amount)
    220     {   this->magazineAmount_ = amount; }
    221 
    222     const unsigned int Weapon::getMagazineAmount()
    223     {   return this->magazineAmount_;   }
    224 
    225     void Weapon::setUnlimitedMunition(bool unlimitedMunition)
    226     {   this->unlimitedMunition_ = unlimitedMunition;   }
    227 
    228     const bool Weapon::getUnlimitedMunition()
    229     {   return this->unlimitedMunition_;    }
     192    void Weapon::takeBullets() { };
     193    void Weapon::createProjectile() { };
     194    void Weapon::takeMagazines() { };
    230195
    231196}
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/Weapon.h

    r2907 r2908  
    6262            void magazineReloaded();
    6363
    64             //XMLPort functions
    6564            virtual void setMunitionType(std::string munitionType);
    6665            virtual const std::string getMunitionType();
     
    6968            virtual void setMagazineLoadingTime(float loadingTime);
    7069            virtual const float getMagazineLoadingTime();
    71             virtual void setBulletAmount(unsigned int amount);
    72             virtual const unsigned int getBulletAmount();
    73             virtual void setMagazineAmount(unsigned int amount);
    74             virtual const unsigned int getMagazineAmount();
    75             virtual void setUnlimitedMunition(bool unlimitedMunition);
    76             virtual const bool getUnlimitedMunition();
    7770
    78             //weapon actions
    7971            virtual void takeBullets();
    8072            virtual void takeMagazines();
    8173            virtual void createProjectile();
    82             virtual void reloadBullet();
    83             virtual void reloadMagazine();
    8474
    85             //manually set or reset
    86             virtual void setWeapon();
    87             virtual void setMunition();
    88            
    8975            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
    9076                { this->parentWeaponSystem_=parentWeaponSystem; };
     
    9783                { return this->attachedToWeaponSlot_; }
    9884
     85            virtual void setWeapon();
    9986
    10087        private:
     
    10491            bool bulletReadyToShoot_;
    10592            bool magazineReadyToShoot_;
    106             bool unlimitedMunition_;
    10793            float bulletLoadingTime_;
    10894            float magazineLoadingTime_;
    109             unsigned int bulletAmount_;
    110             unsigned int magazineAmount_;
    11195            std::string munitionType_;
    11296
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.cc

    r2907 r2908  
    6363        for (int i=0; i < (int) this->weapons_.size(); i++)
    6464        {
     65//COUT(0) << "WeaponPack::fire (attached from WeaponSet)  from Weapon: "<< i << std::endl;
    6566            this->weapons_[i]->getAttachedToWeaponSlot()->fire();
    6667        }
     
    8283    void WeaponPack::setFireMode(unsigned int firemode)
    8384    {
     85//COUT(0) << "WeaponPack::setFireMode " << std::endl;
    8486        this->firemode_ = firemode;
    8587    }
     
    9294    void WeaponPack::addWeapon(Weapon * weapon)
    9395    {
     96//COUT(0) << "WeaponPack::addWeapon:" << weapon << "   munition " << weapon->getMunitionType() << std::endl;
    9497        this->weapons_.push_back(weapon);
    9598    }
     
    114117        {
    115118            this->weapons_[i]->attachNeededMunition(weapons_[i]->getMunitionType());
     119            //hack!
    116120            this->weapons_[i]->setWeapon();
    117121        }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponPack.h

    r2907 r2908  
    5959            const Weapon * getWeapon(unsigned int index);
    6060
    61             //functions with effect to all weapons of the weaponPack
    6261            //functions needed for creating Pointer to the right objects (-->Pawn.cc)
    6362            void setParentWeaponSystemToAllWeapons(WeaponSystem * weaponSystem);
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2907 r2908  
    5656    void WeaponSet::attachWeaponPack(WeaponPack *wPack)
    5757    {
     58//COUT(0) << "WeaponSet::attachWeaponPack" << std::endl;
     59//COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl;
     60//COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl;
     61//COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl;
    5862        if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
    5963        {
     64//COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl;
    6065            this->attachedWeaponPack_ = wPack;
    6166            int wPackWeapon = 0;    //WeaponCounter for Attaching
    62            
    6367            //should be possible to choose which slot to use
    64             //attach every weapon of the weaponPack to a weaponSlot
    6568            for (  int i=0; i < wPack->getSize() ; i++  )
    6669            {
    6770                //at the moment this function only works for one weaponPack in the entire WeaponSystem...
    68                 //it also takes the first free weaponSlot...
    6971                if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full
    7072                {
     73//COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl;
    7174                    this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) );
    7275                    this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
     
    8083                        if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )
    8184                        {
     85//COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl;
    8286                            this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) );
    8387                            this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
     
    9599    {
    96100        //fires all WeaponSlots available for this weaponSet attached from the WeaponPack
     101//COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl;
    97102        if (this->attachedWeaponPack_)
    98103            this->attachedWeaponPack_->fire();
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2907 r2908  
    3838
    3939
    40 /* WeaponSystem
     40/* WEAPONSYSTEM
     41 * creates the WeaponSystem and the ability to use weapons and munition
     42 * loads the weapon the whole weaponSystem setting from an xml file
    4143 *
    42  *  www.orxonox.net/wiki/WeaponSystem
    4344 */
    4445
     
    5152        RegisterObject(WeaponSystem);
    5253
     54        this->activeWeaponSet_ = 0;
    5355        this->parentPawn_ = 0;
    5456    }
     
    8284    }
    8385
    84 
    85     //returns the Pointer to the munitionType, if this munitionType doesn't exist returns 0, see Weapon::attachNeededMunition
     86    //returns the Pointer to the munitionType
    8687    Munition * WeaponSystem::getMunitionType(std::string munitionType)
    8788    {
     89//COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl;
    8890        std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
    8991        if (it != this->munitionSet_.end())
     
    9496
    9597
     98/*
     99    //the first weaponSet is at n=0
     100    void WeaponSystem::setActiveWeaponSet(unsigned int n)
     101    {
     102        if (n < this->weaponSets_.size())
     103            this->activeWeaponSet_ = this->weaponSets_[n];
     104        else
     105            this->activeWeaponSet_ = this->weaponSets_[0];
     106    }
     107*/
     108
     109
    96110    //n is the n'th weaponSet, starting with zero
    97     //SpaceShip.cc only needs to have the keybinding to a specific Set-number n (=firemode)
    98     //in future this could be well defined and not only for 3 different WeaponModes
     111    //SpaceShip.cc only needs to have the keybinding to a specific Set-number n
    99112    void WeaponSystem::fire(WeaponMode::Enum n)
    100113    {
     
    112125                break;
    113126        }
     127//COUT(0) << "WeaponSystem::fire" << std::endl;
    114128        if (set < (int)this->weaponSets_.size())
     129//COUT(0) << "WeaponSystem::fire - after if" << std::endl;
    115130            this->weaponSets_[set]->fire();
    116131    }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/WeaponSystem.h

    r2907 r2908  
    5353            //void fire();
    5454            void fire(WeaponMode::Enum fireMode);
     55            //void setActiveWeaponSet(unsigned int n);
    5556            void attachWeaponPack(WeaponPack * wPack, unsigned int firemode);
    5657            WeaponSet * getWeaponSetPointer(unsigned int n);
     
    5859            WeaponPack * getWeaponPackPointer(unsigned int n);
    5960            void setNewMunition(std::string munitionType, Munition * munitionToAdd);
    60             void setNewSharedMunition(std::string munitionType, Munition * munitionToAdd);
    6161            Munition * getMunitionType(std::string munitionType);
    6262
     
    7474            std::vector<WeaponPack *> weaponPacks_;
    7575            std::map<std::string, Munition *> munitionSet_;
     76            WeaponSet *activeWeaponSet_;
    7677            Pawn *parentPawn_;
    7778    };
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/CMakeLists.txt

    r2907 r2908  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  LaserGunMunition.cc
    3   FusionMunition.cc
    43)
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc

    r2907 r2908  
    4343        RegisterObject(LaserGunMunition);
    4444
    45         //default if not defined in XML
    4645        this->maxBullets_ = 40;
    4746        this->maxMagazines_ = 100;
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc

    r2907 r2908  
    3232#include <OgreBillboardSet.h>
    3333
    34 #include "core/GameMode.h"
     34#include "core/Core.h"
    3535#include "core/CoreIncludes.h"
    3636#include "objects/Scene.h"
     
    4444        RegisterObject(BillboardProjectile);
    4545
    46         if (GameMode::showsGraphics())
     46        if (Core::showsGraphics())
    4747        {
    4848            assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
     
    5656    BillboardProjectile::~BillboardProjectile()
    5757    {
    58         if (this->isInitialized() && GameMode::showsGraphics() && this->billboard_.getBillboardSet())
     58        if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())
    5959            this->detachOgreObject(this->billboard_.getBillboardSet());
    6060    }
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc

    r2907 r2908  
    3333#include <OgreParticleEmitter.h>
    3434
    35 #include "core/GameMode.h"
     35#include "core/Core.h"
    3636#include "core/CoreIncludes.h"
    3737#include "core/ConfigValueIncludes.h"
     
    4646        RegisterObject(ParticleProjectile);
    4747
    48         if (GameMode::showsGraphics())
     48        if (Core::showsGraphics())
    4949        {
    5050            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc

    r2907 r2908  
    4141#include "objects/worldentities/ParticleSpawner.h"
    4242#include "objects/collisionshapes/SphereCollisionShape.h"
    43 #include "core/GameMode.h"
     43#include "core/Core.h"
    4444
    4545namespace orxonox
     
    5555        // Get notification about collisions
    5656
    57         if (GameMode::isMaster())
     57        if (Core::isMaster())
    5858        {
    5959            this->enableCollisionCallback();
     
    9393    void Projectile::destroyObject()
    9494    {
    95         if (GameMode::isMaster())
     95        if (Core::isMaster())
    9696            delete this;
    9797    }
     
    9999    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    100100    {
    101         if (!this->bDestroy_ && GameMode::isMaster())
     101        if (!this->bDestroy_ && Core::isMaster())
    102102        {
    103103            this->bDestroy_ = true;
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2907 r2908  
    5353    }
    5454
    55     void LaserGun::reloadBullet()
    56     {
    57         this->bulletTimer(this->bulletLoadingTime_);
    58     }
    59 
    60     void LaserGun::reloadMagazine()
    61     {
    62         this->magazineTimer(this->magazineLoadingTime_);
    63     }
    64 
    6555    void LaserGun::takeBullets()
    6656    {
     57//COUT(0) << "LaserGun::takeBullets" << std::endl;
    6758        this->munition_->removeBullets(1);
     59        this->bulletTimer(this->bulletLoadingTime_);
    6860    }
    6961
     
    7163    {
    7264        this->munition_->removeMagazines(1);
     65        this->magazineTimer(this->magazineLoadingTime_);
    7366    }
    7467
    7568    void LaserGun::createProjectile()
    7669    {
     70//COUT(0) << "LaserGun::createProjectile" << std::endl;
    7771        BillboardProjectile* projectile = new ParticleProjectile(this);
    7872        projectile->setOrientation(this->getWorldOrientation());
  • code/branches/questsystem5/src/orxonox/objects/weaponSystem/weapons/LaserGun.h

    r2907 r2908  
    5151            virtual void takeMagazines();
    5252            virtual void createProjectile();
    53             virtual void reloadBullet();
    54             virtual void reloadMagazine();
    5553
    5654        private:
Note: See TracChangeset for help on using the changeset viewer.