Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 16, 2010, 12:37:09 PM (14 years ago)
Author:
dafrick
Message:

Documenting and cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/pickup/items/SpeedPickup.cc

    r7401 r7547  
    3434#include "SpeedPickup.h"
    3535
     36#include <sstream>
    3637#include "core/CoreIncludes.h"
    3738#include "core/XMLPort.h"
    38 #include "util/StringUtils.h"
    39 
    40 #include "worldentities/pawns/SpaceShip.h"
     39
    4140#include "items/Engine.h"
    4241#include "pickup/PickupIdentifier.h"
    43 
    44 #include <sstream>
    45 
     42#include "worldentities/pawns/SpaceShip.h"
    4643
    4744namespace orxonox
     
    130127        SUPER(SpeedPickup, changedUsed);
    131128
    132         //! If the pickup is not picked up nothing must be done.
     129        // If the pickup is not picked up nothing must be done.
    133130        if(!this->isPickedUp())
    134131            return;
    135132
    136133        Engine* engine = this->carrierToEngineHelper();
    137         if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
     134        if(engine == NULL) // If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
    138135            this->Pickupable::destroy();
    139136
    140         //! If the pickup has transited to used.
     137        // If the pickup has transited to used.
    141138        if(this->isUsed())
    142139        {
    143             if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
     140            // If its durationType is continuous, we set a Timer to be reminded, when the time has run out.
     141            if(this->isContinuous())
    144142            {
    145                 this->durationTimer_.unpauseTimer();
    146             }
    147             else
    148             {
    149                 this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this)));
    150             }
    151             engine->setSpeedAdd(this->getSpeedAdd());
    152             engine->setSpeedMultiply(this->getSpeedMultiply());
    153         }
    154         else
    155         {
    156             engine->setSpeedAdd(0.0f);
    157             engine->setSpeedMultiply(1.0f);
    158 
    159             if(this->isOnce())
    160             {
    161                 if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
     143                if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
    162144                {
    163                     this->Pickupable::destroy();
     145                    this->durationTimer_.unpauseTimer();
    164146                }
    165147                else
    166148                {
    167                     this->durationTimer_.pauseTimer();
     149                    this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this)));
    168150                }
     151            }
     152
     153            engine->setSpeedAdd(this->getSpeedAdd());
     154            engine->setSpeedMultiply(this->getSpeedMultiply());
     155        }
     156        else
     157        {
     158            engine->setSpeedAdd(0.0f);
     159            engine->setSpeedMultiply(1.0f);
     160
     161            // We destroy the pickup if either, the pickup has activationType immediate and durationType once or it has durationType continuous and the duration was exceeded.
     162            if((!this->isContinuous() && this->isImmediate()) || (this->isContinuous() && !this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration()))
     163            {
     164                this->Pickupable::destroy();
     165            }
     166            // We pause the Timer if the pickup is continuous and the duration is not yet exceeded,
     167            else if(this->isContinuous() && this->durationTimer_.isActive())
     168            {
     169                this->durationTimer_.pauseTimer();
    169170            }
    170171        }
     
    213214    /**
    214215    @brief
    215         Sets the duration.
     216        Sets the duration for which the SpeedPickup stays active.
    216217    @param duration
    217         The duration
     218        The duration in seconds.
    218219    */
    219220    void SpeedPickup::setDuration(float duration)
     
    232233    /**
    233234    @brief
    234         Sets the SpeedAdd
     235        Sets the speedAdd, the value that is added to the speed of the Pawn.
    235236    @param speedAdd
    236         The added Speed
     237        The added speed.
    237238    */
    238239    void SpeedPickup::setSpeedAdd(float speedAdd)
     
    251252    /**
    252253    @brief
    253         Sets the SpeedMultiply
     254        Sets the speedMultiply, the factor by which the speed of the Pawn is multiplied.
    254255    @param speedMultiply
    255         The multiplied Speed
     256        The factor by which the speed is mutiplied.
    256257    */
    257258    void SpeedPickup::setSpeedMultiply(float speedMultiply)
Note: See TracChangeset for help on using the changeset viewer.