Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jan 9, 2016, 6:26:20 PM (9 years ago)
Author:
landauf
Message:

merged branch presentationHS15 back to trunk

Location:
code/trunk
Files:
2 deleted
11 edited
4 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/worldentities/CMakeLists.txt

    r8706 r11052  
    66  ControllableEntity.cc
    77  Drone.cc
    8   BigExplosion.cc
    98  EffectContainer.cc
    109  ExplosionChunk.cc
     
    1211  SpawnPoint.cc
    1312  TeamSpawnPoint.cc
     13  ExplosionPart.cc
     14  Actionpoint.cc
    1415)
    1516
  • code/trunk/src/orxonox/worldentities/MobileEntity.h

    r10437 r11052  
    4747        linear velocity. Then the linear velocity is multiplied by the time since the last call of tick and then added to the position. The same happens with
    4848        the angular acceleration and velocity. With this procedure MobileEntities can change their position and orientation with time.
     49
     50        A MobileEntity can only have the collisition type WorldEntity::None, WorldEntity::Dynamic or WorldEntity::Kinematic. The collsion type WorldEntity::Static is illegal.
    4951    */
    5052
  • code/trunk/src/orxonox/worldentities/SpawnPoint.h

    r9667 r11052  
    5555                { return this->template_; }
    5656
    57             Pawn* spawn();
     57            virtual Pawn* spawn();
    5858            void spawn(ControllableEntity* entity);
    5959
  • code/trunk/src/orxonox/worldentities/StaticEntity.h

    r10437 r11052  
    4444        it is called StaticEntity. It will keep the same position (always with respect to its parent) forever unless you call the
    4545        function @see setPosition to changee it.
     46
     47        A StaticEntity can only have the collisition type WorldEntity::None or WorldEntity::Static. The collsion types WorldEntity::Dynamic and WorldEntity::Kinematic are illegal.
    4648    */
    4749
  • code/trunk/src/orxonox/worldentities/TeamSpawnPoint.cc

    r9667 r11052  
    4949        XMLPortParam(TeamSpawnPoint, "team", setTeamNumber, getTeamNumber, xmlelement, mode).defaultValues(0);
    5050    }
     51    Pawn* TeamSpawnPoint::spawn()
     52    {
     53        Pawn* entity = SpawnPoint::spawn();
     54        static_cast<ControllableEntity*>(entity)->setTeam (this->teamNumber_);
     55        return entity;
     56    }
    5157}
  • code/trunk/src/orxonox/worldentities/TeamSpawnPoint.h

    r9667 r11052  
    4949            unsigned int getTeamNumber() const
    5050                { return this->teamNumber_; }
     51            virtual Pawn* spawn();
    5152
    5253        private:
    53             unsigned int teamNumber_;
     54            int teamNumber_;
    5455    };
    5556}
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r10650 r11052  
    3434#include "core/GameMode.h"
    3535#include "core/XMLPort.h"
     36#include "core/EventIncludes.h"
    3637#include "network/NetworkFunction.h"
    3738
     
    4142#include "graphics/ParticleSpawner.h"
    4243#include "worldentities/ExplosionChunk.h"
    43 #include "worldentities/BigExplosion.h"
     44#include "worldentities/ExplosionPart.h"
    4445#include "weaponsystem/WeaponSystem.h"
    4546#include "weaponsystem/WeaponSlot.h"
    4647#include "weaponsystem/WeaponPack.h"
    4748#include "weaponsystem/WeaponSet.h"
     49#include "weaponsystem/Munition.h"
    4850#include "sound/WorldSound.h"
    4951
     
    6163
    6264        this->bAlive_ = true;
    63         this->bReload_ = false;
     65        this->bVulnerable_ = true;
    6466
    6567        this->health_ = 0;
     
    7173        this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
    7274        this->shieldAbsorption_ = 0.5;
    73 
    74         this->reloadRate_ = 0;
    75         this->reloadWaitTime_ = 1.0f;
    76         this->reloadWaitCountdown_ = 0;
     75        this->shieldRechargeRate_ = 0;
     76        this->shieldRechargeWaitTime_ = 1.0f;
     77        this->shieldRechargeWaitCountdown_ = 0;
    7778
    7879        this->lastHitOriginator_ = 0;
     
    8485
    8586        this->aimPosition_ = Vector3::ZERO;
     87
     88        //this->explosionPartList_ = NULL;
    8689
    8790        if (GameMode::isMaster())
     
    135138        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
    136139
     140        XMLPortParam(Pawn, "vulnerable", setVulnerable, isVulnerable, xmlelement, mode).defaultValues(true);
     141
    137142        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
    138143        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
    139         XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
     144        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(0);
    140145
    141146        XMLPortObject(Pawn, WeaponSlot, "weaponslots", addWeaponSlot, getWeaponSlot, xmlelement, mode);
    142147        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    143         XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
    144 
    145         XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
    146         XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
     148        XMLPortObject(Pawn, WeaponPack, "weaponpacks", addWeaponPackXML, getWeaponPack, xmlelement, mode);
     149        XMLPortObject(Pawn, Munition, "munition", addMunitionXML, getMunitionXML, xmlelement, mode);
     150
     151        XMLPortObject(Pawn, ExplosionPart, "explosion", addExplosionPart, getExplosionPart, xmlelement, mode);
     152        XMLPortParam(Pawn, "shieldrechargerate", setShieldRechargeRate, getShieldRechargeRate, xmlelement, mode).defaultValues(0);
     153        XMLPortParam(Pawn, "shieldrechargewaittime", setShieldRechargeWaitTime, getShieldRechargeWaitTime, xmlelement, mode).defaultValues(1.0f);
    147154
    148155        XMLPortParam(Pawn, "explosionSound",  setExplosionSound,  getExplosionSound,  xmlelement, mode);
     
    151158    }
    152159
     160    void Pawn::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     161    {
     162        SUPER(Pawn, XMLEventPort, xmlelement, mode);
     163
     164        XMLPortEventState(Pawn, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
     165    }
     166
    153167    void Pawn::registerVariables()
    154168    {
    155         registerVariable(this->bAlive_,           VariableDirection::ToClient);
    156         registerVariable(this->health_,           VariableDirection::ToClient);
    157         registerVariable(this->maxHealth_,        VariableDirection::ToClient);
    158         registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
    159         registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
    160         registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
    161         registerVariable(this->bReload_,          VariableDirection::ToServer);
    162         registerVariable(this->aimPosition_,      VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
     169        registerVariable(this->bAlive_,            VariableDirection::ToClient);
     170        registerVariable(this->health_,            VariableDirection::ToClient);
     171        registerVariable(this->maxHealth_,         VariableDirection::ToClient);
     172        registerVariable(this->shieldHealth_,      VariableDirection::ToClient);
     173        registerVariable(this->maxShieldHealth_,   VariableDirection::ToClient);
     174        registerVariable(this->shieldAbsorption_,  VariableDirection::ToClient);
     175        registerVariable(this->aimPosition_,       VariableDirection::ToServer);  // For the moment this variable gets only transfered to the server
    163176    }
    164177
    165178    void Pawn::tick(float dt)
    166179    {
     180        //BigExplosion* chunk = new BigExplosion(this->getContext());
    167181        SUPER(Pawn, tick, dt);
    168182
    169         this->bReload_ = false;
    170 
     183        // Recharge the shield
    171184        // TODO: use the existing timer functions instead
    172         if(this->reloadWaitCountdown_ > 0)
    173         {
    174             this->decreaseReloadCountdownTime(dt);
    175         }
    176         else
    177         {
    178             this->addShieldHealth(this->getReloadRate() * dt);
    179             this->resetReloadCountdown();
     185        if(this->shieldRechargeWaitCountdown_ > 0)
     186        {
     187            this->decreaseShieldRechargeCountdownTime(dt);
     188        }
     189        else
     190        {
     191            this->addShieldHealth(this->getShieldRechargeRate() * dt);
     192            this->resetShieldRechargeCountdown();
    180193        }
    181194
     
    229242    }
    230243
    231     void Pawn::setReloadRate(float reloadrate)
    232     {
    233         this->reloadRate_ = reloadrate;
    234     }
    235 
    236     void Pawn::setReloadWaitTime(float reloadwaittime)
    237     {
    238         this->reloadWaitTime_ = reloadwaittime;
    239     }
    240 
    241     void Pawn::decreaseReloadCountdownTime(float dt)
    242     {
    243         this->reloadWaitCountdown_ -= dt;
     244    void Pawn::setShieldRechargeRate(float shieldRechargeRate)
     245    {
     246        this->shieldRechargeRate_ = shieldRechargeRate;
     247    }
     248
     249    void Pawn::setShieldRechargeWaitTime(float shieldRechargeWaitTime)
     250    {
     251        this->shieldRechargeWaitTime_ = shieldRechargeWaitTime;
     252    }
     253
     254    void Pawn::decreaseShieldRechargeCountdownTime(float dt)
     255    {
     256        this->shieldRechargeWaitCountdown_ -= dt;
     257    }
     258
     259    void Pawn::changedVulnerability()
     260    {
     261
    244262    }
    245263
    246264    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
    247265    {
     266        // A pawn can only get damaged if it is vulnerable
     267        if (!isVulnerable())
     268        {
     269            return;
     270        }
     271
    248272        // Applies multiplier given by the DamageBoost Pickup.
    249273        if (originator)
     
    252276        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    253277        {
     278            // Health-damage cannot be absorbed by shields.
     279            // Shield-damage only reduces shield health.
     280            // Normal damage can be (partially) absorbed by shields.
     281
    254282            if (shielddamage >= this->getShieldHealth())
    255283            {
     
    366394            if (GameMode::isMaster())
    367395            {
    368                 this->deatheffect();
    369396                this->goWithStyle();
    370397            }
     
    373400    void Pawn::goWithStyle()
    374401    {
     402
    375403        this->bAlive_ = false;
    376404        this->setDestroyWhenPlayerLeft(false);
    377405
    378         BigExplosion* chunk = new BigExplosion(this->getContext());
    379         chunk->setPosition(this->getPosition());
    380         chunk->setVelocity(this->getVelocity());
     406        while(!explosionPartList_.empty())
     407        {
     408            explosionPartList_.back()->setPosition(this->getPosition());
     409            explosionPartList_.back()->setVelocity(this->getVelocity());
     410            explosionPartList_.back()->setOrientation(this->getOrientation());
     411            explosionPartList_.back()->Explode();
     412            explosionPartList_.pop_back();
     413        }
     414
     415        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
     416        {
     417            ExplosionChunk* chunk = new ExplosionChunk(this->getContext());
     418            chunk->setPosition(this->getPosition());
     419        }
    381420
    382421        this->explosionSound_->setPosition(this->getPosition());
    383422        this->explosionSound_->play();
    384     }
    385     void Pawn::deatheffect()
    386     {
    387         // play death effect
    388         /*{
    389             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    390             effect->setPosition(this->getPosition());
    391             effect->setOrientation(this->getOrientation());
    392             effect->setDestroyAfterLife(true);
    393             effect->setSource("Orxonox/explosion2b");
    394             effect->setLifetime(4.0f);
    395         }
    396         {
    397             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    398             effect->setPosition(this->getPosition());
    399             effect->setOrientation(this->getOrientation());
    400             effect->setDestroyAfterLife(true);
    401             effect->setSource("Orxonox/smoke6");
    402             effect->setLifetime(4.0f);
    403         }
    404         {
    405             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    406             effect->setPosition(this->getPosition());
    407             effect->setOrientation(this->getOrientation());
    408             effect->setDestroyAfterLife(true);
    409             effect->setSource("Orxonox/sparks");
    410             effect->setLifetime(4.0f);
    411         }*/
    412        
    413        
    414         {
    415             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    416             effect->setPosition(this->getPosition());
    417             effect->setOrientation(this->getOrientation());
    418             effect->setDestroyAfterLife(true);
    419             effect->setSource("orxonox/explosion_flash2");
    420             effect->setLifetime(5.0f);
    421         }
    422         {
    423             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    424             effect->setPosition(this->getPosition());
    425             effect->setOrientation(this->getOrientation());
    426             effect->setDestroyAfterLife(true);
    427             effect->setSource("orxonox/explosion_flame2");
    428             effect->setLifetime(5.0f);
    429         }
    430         {
    431             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    432             effect->setPosition(this->getPosition());
    433             effect->setOrientation(this->getOrientation());
    434             effect->setDestroyAfterLife(true);
    435             effect->setSource("orxonox/explosion_shockwave2");
    436             effect->scale(20);
    437             effect->setLifetime(5.0f);
    438         }{
    439             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    440             effect->setPosition(this->getPosition());
    441             effect->setOrientation(this->getOrientation());
    442             effect->setDestroyAfterLife(true);
    443             effect->setSource("orxonox/explosion_sparks2");
    444             effect->setLifetime(5.0f);
    445         }
    446         {
    447             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    448             effect->setPosition(this->getPosition());
    449             effect->setOrientation(this->getOrientation());
    450             effect->setDestroyAfterLife(true);
    451             effect->setSource("orxonox/explosion_streak2");
    452             effect->setLifetime(5.0f);
    453         }
    454         {
    455             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
    456             effect->setPosition(this->getPosition());
    457             effect->setOrientation(this->getOrientation());
    458             effect->setDestroyAfterLife(true);
    459             effect->setSource("orxonox/explosion_afterglow");
    460             effect->scale(20);
    461             effect->setLifetime(5.0f);
    462         }
    463        
    464        
    465         for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
    466         {
    467             ExplosionChunk* chunk = new ExplosionChunk(this->getContext());
    468             chunk->setPosition(this->getPosition());
    469         }
    470423    }
    471424
     
    474427        Check whether the Pawn has a @ref Orxonox::WeaponSystem and fire it with the specified firemode if it has one.
    475428    */
     429
    476430    void Pawn::fired(unsigned int firemode)
    477431    {
    478432        if (this->weaponSystem_)
    479433            this->weaponSystem_->fire(firemode);
    480     }
    481 
    482     void Pawn::reload()
    483     {
    484         this->bReload_ = true;
    485434    }
    486435
     
    491440            this->spawneffect();
    492441    }
     442
     443
     444    void Pawn::addExplosionPart(ExplosionPart* ePart)
     445    {this->explosionPartList_.push_back(ePart);}
     446
     447
     448    ExplosionPart * Pawn::getExplosionPart()
     449    {return this->explosionPartList_.back();}
     450
     451
    493452
    494453    /* WeaponSystem:
     
    554513    }
    555514
     515    std::vector<WeaponPack *> * Pawn::getAllWeaponPacks()
     516    {
     517        if (this->weaponSystem_)
     518            return this->weaponSystem_->getAllWeaponPacks();
     519        else
     520            return 0;       
     521    }
     522
     523    void Pawn::addMunitionXML(Munition* munition)
     524    {
     525        if (this->weaponSystem_ && munition)
     526        {
     527            this->weaponSystem_->addMunition(munition);
     528        }
     529    }
     530
     531    Munition* Pawn::getMunitionXML() const
     532    {
     533        return NULL;
     534    }
     535
     536    Munition* Pawn::getMunition(SubclassIdentifier<Munition> * identifier)
     537    {
     538        if (weaponSystem_)
     539        {
     540            return weaponSystem_->getMunition(identifier);
     541        }
     542
     543        return NULL;
     544    }
     545
    556546    //Tell the Map (RadarViewable), if this is a playership
    557547    void Pawn::startLocalHumanControl()
    558548    {
    559 //        SUPER(ControllableEntity, changedPlayer());
     549//        SUPER(ControllableEntity, startLocalHumanControl());
    560550        ControllableEntity::startLocalHumanControl();
    561551        this->isHumanShip_ = true;
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.h

    r10437 r11052  
    3333
    3434#include <string>
     35#include <vector>
    3536#include "interfaces/PickupCarrier.h"
    3637#include "interfaces/RadarViewable.h"
    3738#include "worldentities/ControllableEntity.h"
     39#include "worldentities/ExplosionPart.h"
    3840
    3941
     
    4244    /**
    4345    @brief
    44         Everything in Orxonoy that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
     46        Everything in Orxonox that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
    4547        its initial health. In every call of the Pawns tick function the game checks whether the pawns health is at
    4648        or below zero. If it is, the pawn gets killed.
    4749
    48         Pawns can carry pickups and fire weapons. The can also have shields.
     50        Pawns can carry pickups and fire weapons. They can also have shields.
    4951
    5052        Notice that every Pawn is a ControllableEntity.
     
    6264
    6365            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     66            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    6467            virtual void tick(float dt);
    6568
     
    116119                { return this->shieldAbsorption_; }
    117120
    118             // TODO: Rename to shieldRechargeRate
    119             virtual void setReloadRate(float reloadrate);
    120             inline float getReloadRate() const
    121                 { return this->reloadRate_; }
    122 
    123             virtual void setReloadWaitTime(float reloadwaittime);
    124             inline float getReloadWaitTime() const
    125                 { return this->reloadWaitTime_; }
    126 
    127             inline void resetReloadCountdown()
    128                 { this->reloadWaitCountdown_ = 0; }
    129 
    130             inline void startReloadCountdown()
    131                 { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
    132 
    133             virtual void decreaseReloadCountdownTime(float dt);
     121            virtual void setShieldRechargeRate(float shieldRechargeRate);
     122            inline float getShieldRechargeRate() const
     123                { return this->shieldRechargeRate_; }
     124
     125            virtual void setShieldRechargeWaitTime(float shieldRechargeWaitTime);
     126            inline float getShieldRechargeWaitTime() const
     127                { return this->shieldRechargeWaitTime_; }
     128
     129            inline void resetShieldRechargeCountdown()
     130                { this->shieldRechargeWaitCountdown_ = 0; }
     131
     132            inline void startShieldRechargeCountdown()
     133                { this->shieldRechargeWaitCountdown_ = this->getShieldRechargeWaitTime(); } // TODO: Implement in Projectile.cc
     134
     135            virtual void decreaseShieldRechargeCountdownTime(float dt);
     136
     137            /** @brief Sets the state of the pawns vulnerability. @param bVulnerable */
     138            inline void setVulnerable(bool bVulnerable)
     139            {
     140                if (this->bVulnerable_ != bVulnerable)
     141                {
     142                    this->bVulnerable_ = bVulnerable;
     143                    this->changedVulnerability();
     144                }
     145            }
     146            /** @brief Returns the state of the pawns vulnerability. @return The state of the vulnerability */
     147            inline const bool& isVulnerable() const { return this->bVulnerable_; }
     148            /** @brief This function gets called if the vulnerability of the pawn changes. */
     149            virtual void changedVulnerability();
    134150
    135151            inline ControllableEntity* getLastHitOriginator() const
    136152                { return this->lastHitOriginator_; }
    137153
    138             //virtual void hit(Pawn* originator, const Vector3& force, float damage);
    139             //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
    140154            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    141155            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     
    144158
    145159            virtual void fired(unsigned int firemode);
    146             virtual void reload();
    147160            virtual void postSpawn();
     161
     162            void addExplosionPart(ExplosionPart* ePart);
     163            ExplosionPart * getExplosionPart();
    148164
    149165            void addWeaponSlot(WeaponSlot * wSlot);
     
    154170            void addWeaponPackXML(WeaponPack * wPack);
    155171            WeaponPack * getWeaponPack(unsigned int index) const;
     172            std::vector<WeaponPack *> * getAllWeaponPacks();
     173
     174            void addMunitionXML(Munition* munition);
     175            Munition* getMunitionXML() const;
     176           
     177            Munition* getMunition(SubclassIdentifier<Munition> * identifier);
    156178
    157179            virtual void addedWeaponPack(WeaponPack* wPack) {}
     
    194216            const std::string& getExplosionSound();
    195217
     218            virtual const WeaponSystem* getWeaponSystem() const
     219                { return this->weaponSystem_; }
     220
    196221        protected:
    197222            virtual void preDestroy();
     
    204229            virtual Controller* getSlave();
    205230            virtual void goWithStyle();
    206             virtual void deatheffect();
    207231            virtual void spawneffect();
    208232
    209             //virtual void damage(float damage, Pawn* originator = 0);
    210233            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL, const btCollisionShape* cs = NULL);
    211234
    212235            bool bAlive_;
     236            bool bVulnerable_; ///< If false the pawn may not ged damaged
    213237
    214238            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
     
    226250            float initialShieldHealth_;
    227251            float shieldAbsorption_; ///< Has to be between 0 and 1
    228             float reloadRate_;
    229             float reloadWaitTime_;
    230             float reloadWaitCountdown_;
     252            float shieldRechargeRate_;
     253            float shieldRechargeWaitTime_;
     254            float shieldRechargeWaitCountdown_;
    231255
    232256            float damageMultiplier_; ///< Used by the Damage Boost Pickup.
     
    235259
    236260            WeaponSystem* weaponSystem_;
    237             bool bReload_;
    238261
    239262            std::string spawnparticlesource_;
    240263            float spawnparticleduration_;
    241264            unsigned int numexplosionchunks_;
     265
     266            std::vector<ExplosionPart*> explosionPartList_;
    242267
    243268        private:
  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc

    r10216 r11052  
    115115
    116116        XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode);
     117
     118       
    117119    }
    118120
     
    297299        }
    298300    }
     301
     302    void SpaceShip::gainBoostPower(float gainedBoostPower)
     303    {
     304        this->boostPower_ += gainedBoostPower;
     305       
     306        if (this->boostPower_ > this->initialBoostPower_)
     307        {
     308            this->boostPower_ = this->initialBoostPower_;
     309        }
     310
     311        // If the booster is in cooldown mode and we gained boost power, the abort the cooldown.
     312        if (this->isBoostCoolingDown() && this->boostPower_ > 0.0f)
     313        {
     314            timer_.stopTimer();
     315            this->boostCooledDown();
     316        }
     317    }
     318
    299319    /**
    300320    @brief
  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h

    r10437 r11052  
    5353        - The <b>boost</b>, there are quite some parameters pertaining to boosting. The boost is a special move of the SpaceShip, where, for a limited amount of time, it can fly considerably faster than usual. The <b>boostPower</b> is the amount of power available for boosting. The <b>boostPowerRate</b> is the rate at which the boost power is replenished. The <b>boostRate</b> is the rate at which boosting uses power. And the <b>boostCooldownDuration</b> is the time the SpaceShip cannot boost, once all the boost power has been used up. Naturally all of these parameters must be non-negative.
    5454        - The <b>boost shaking</b>, when the SpaceShip boosts, the camera shakes to create a more immersive effect. Two parameters can be used to adjust the effect. The <b>shakeFrequency</b> is the frequency with which the camera shakes. And the <b>shakeAmplitude</b> is the amount with which the camera shakes. Again these parameters must bee non-negative.
    55         - The <b>lift</b> creates a more natural flight feeling through the addition of a lift force. There are again tow parameters that can be specified. The <b>lift</b> which is the lift force that is applied. And the <b>stallSpeed</b> which is the forward speed after which no more lift is generated.
     55        - The <b>lift</b> creates a more natural flight feeling through the addition of a lift force. There are again two parameters that can be specified. The <b>lift</b> which is the lift force that is applied. And the <b>stallSpeed</b> which is the forward speed after which no more lift is generated.
     56
     57        A spaceship always needs to have the collision type "dynamic". Other collision types are illegal.
    5658
    5759        As mentioned @ref orxonox::Engine Engines can be mounted on the SpaceShip. Here is a (primitive) example of a SpaceShip defined in XML:
     
    250252            inline float getShakeAmplitude() const
    251253                { return this->shakeAmplitude_; }
     254            /**
     255            @brief Add boost power. Is non-negative.
     256            @return Returns the current boost power.
     257            */
     258            void gainBoostPower(float gainedBoostPower);
    252259
    253260        protected:
     
    262269            bool bBoostCooldown_;         //!< Whether the SpaceShip is currently in boost cooldown, during which boosting is impossible.
    263270            float initialBoostPower_;     //!< The initial (and maximal) boost power.
    264             float boostPower_;            //!< The current boost power.
     271            float boostPower_;            //!< The current boost power. If the boost power is reduced to zero the boost cooldown will start.
    265272            float boostPowerRate_;        //!< The rate at which the boost power is recharged.
    266273            float boostRate_;             //!< The rate at which boost power is used up.
     
    289296            std::vector<Engine*> engineList_; //!< The list of all Engines mounted on this SpaceShip.
    290297
    291             Timer timer_;                          //!< Timer for the cooldown duration.
     298            Timer timer_;                          //!< Timer for the cooldown of the boost.
    292299            float shakeDt_;                        //!< Temporary variable for the shaking of the camera.
    293300            Vector3 cameraOriginalPosition_;       //!< The original position of the camera before shaking it.
Note: See TracChangeset for help on using the changeset viewer.