Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7208 for code/trunk/src


Ignore:
Timestamp:
Aug 24, 2010, 9:49:54 AM (14 years ago)
Author:
dafrick
Message:

Removed Timer from Pickup, as this is no his core functionality.

Location:
code/trunk/src/modules/pickup
Files:
8 edited

Legend:

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

    r7163 r7208  
    236236    }
    237237
    238     /**
    239     @brief
    240         Starts the pickup duration timer.
    241         After the specified durationTime has expired the function pickupTimerCallback is called.
    242         pickupTimerCallback can be overloaded and thus the desired functionality can be implemented.
    243     @param durationTime
    244         The duration after which the expires and the callback function is called.
    245     @return
    246         Returns true if the pickup duration timer was started successfully, false if not.
    247     */
    248     bool Pickup::startPickupTimer(float durationTime)
    249     {
    250         if (durationTime<=0)
    251         {
    252             COUT(1) << "Invalid durationTime in pickup." << std::endl;
    253             return false;
    254         }
    255         if (this->durationTimer_.isActive()) //!< Check if Timer is already running
    256         {
    257             COUT(1) << "Pickup durationTimer already in use." << std::endl;
    258             return false;
    259         }
    260         this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::pickupTimerCallback, this)));
    261         return true;
    262     }
    263238}
  • code/trunk/src/modules/pickup/Pickup.h

    r7163 r7208  
    133133            virtual bool createSpawner(void); //!< Facilitates the creation of a PickupSpawner upon dropping of the Pickupable.
    134134
    135             bool startPickupTimer(float durationTime); //!< Starts the pickup duration timer.
    136             /**
    137             @brief Get your Timer.
    138             @return Returns a pointer to the Timer.
    139             */
    140             inline Timer* getTimer(void)
    141                 { return &this->durationTimer_; }
    142 
    143             /**
    144             @brief The callback method for the Timer.
    145                    Can be overloaded to implement desired functionality.
    146             */
    147             virtual void pickupTimerCallback(void) {}
    148 
    149135            /**
    150136            @brief Set the activation type of the pickup.
     
    166152            void initialize(void); //!< Initializes the member variables.
    167153
    168             //TODO: Problems, when there are more Timers needed? Solutions?
    169             Timer durationTimer_; //!< Timer at the disposal of each Class implementing Pickup.
    170 
    171154            pickupActivationType::Value activationType_; //!< The activation type of the Pickup.
    172155            pickupDurationType::Value durationType_; //!< The duration type of the pickup.
  • code/trunk/src/modules/pickup/items/InvisiblePickup.cc

    r7163 r7208  
    115115        if (this->isUsed())
    116116        {
    117             if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)
    118             {
    119                 this->getTimer()->unpauseTimer();
     117            if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
     118            {
     119                this->durationTimer_.unpauseTimer();
    120120            }
    121121            else
    122122            {
    123                 this->startPickupTimer(this->getDuration());
     123                this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&InvisiblePickup::pickupTimerCallback, this)));
    124124            }
    125125
     
    131131            this->setInvisible(false);
    132132
    133             if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
     133            if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
    134134            {
    135135                this->Pickupable::destroy();
     
    137137            else
    138138            {
    139                 this->getTimer()->pauseTimer();
     139                this->durationTimer_.pauseTimer();
    140140            }
    141141        }
  • code/trunk/src/modules/pickup/items/InvisiblePickup.h

    r7163 r7208  
    7777            void setDuration(float duration);
    7878            void initializeIdentifier(void);
    79             virtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends.
     79            void pickupTimerCallback(void); //!< Function that gets called when the timer ends.
    8080
    8181        private:
    8282            void initialize(void); //!< Initializes the member variables.
    8383            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
     84
     85            Timer durationTimer_; //!< Timer.
     86
    8487            bool invisible_; //!< Helper to remember wether the Pawn is invisible.
    8588            float duration_; //! Duration of invisibility.
  • code/trunk/src/modules/pickup/items/ShieldPickup.cc

    r7163 r7208  
    160160        if(this->isUsed())
    161161        {
    162             if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)
     162            if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
    163163            {
    164                 this->getTimer()->unpauseTimer();
     164                this->durationTimer_.unpauseTimer();
    165165            }
    166166            else
    167167            {
    168                 this->startPickupTimer(this->getDuration());
     168                this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&ShieldPickup::pickupTimerCallback, this)));
    169169            }
    170170            pawn->setShieldAbsorption(this->getShieldAbsorption());
     
    179179            if(this->isOnce())
    180180            {
    181                 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
     181                if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
    182182                {
    183183                    this->Pickupable::destroy();
     
    185185                else
    186186                {
    187                     this->getTimer()->pauseTimer();
     187                    this->durationTimer_.pauseTimer();
    188188                }
    189189            }
  • code/trunk/src/modules/pickup/items/ShieldPickup.h

    r7163 r7208  
    8080            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    8181
    82             virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
     82            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    8383
    8484            void setDuration(float duration);
     
    9090            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    9191
     92            Timer durationTimer_; //!< Timer.
     93
    9294            float duration_; //!< The health that is transferred to the Pawn.
    9395            float shieldHealth_;
  • code/trunk/src/modules/pickup/items/SpeedPickup.cc

    r7163 r7208  
    141141        if(this->isUsed())
    142142        {
    143             if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() > 0.0f)
     143            if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() > 0.0f)
    144144            {
    145                 this->getTimer()->unpauseTimer();
     145                this->durationTimer_.unpauseTimer();
    146146            }
    147147            else
    148148            {
    149                 this->startPickupTimer(this->getDuration());
     149                this->durationTimer_.setTimer(this->getDuration(), false, createExecutor(createFunctor(&SpeedPickup::pickupTimerCallback, this)));
    150150            }
    151151            engine->setSpeedAdd(this->getSpeedAdd());
     
    159159            if(this->isOnce())
    160160            {
    161                 if(!this->getTimer()->isActive() && this->getTimer()->getRemainingTime() == this->getDuration())
     161                if(!this->durationTimer_.isActive() && this->durationTimer_.getRemainingTime() == this->getDuration())
    162162                {
    163163                    this->Pickupable::destroy();
     
    165165                else
    166166                {
    167                     this->getTimer()->pauseTimer();
     167                    this->durationTimer_.pauseTimer();
    168168                }
    169169            }
  • code/trunk/src/modules/pickup/items/SpeedPickup.h

    r7163 r7208  
    7979            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
    8080
    81             virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
     81            void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    8282
    8383            void setDuration(float duration);
     
    8989            Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    9090
     91            Timer durationTimer_; //!< Timer.
     92
    9193            float duration_; //!< The health that is transferred to the Pawn.
    9294            float speedAdd_;
Note: See TracChangeset for help on using the changeset viewer.