Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 13, 2010, 12:41:52 AM (15 years ago)
Author:
dafrick
Message:

Small adaptations in SpeedPickup.

Location:
code/branches/ppspickups1/src/modules/pickup/items
Files:
2 edited

Legend:

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

    r6694 r6706  
    7575    void SpeedPickup::initialize(void)
    7676    {
    77         this->duration_ = 0.0;
    78         this->speedAdd_ = 0.0;
    79         this->speedMultiply_ = 1.0;
     77        this->duration_ = 0.0f;
     78        this->speedAdd_ = 0.0f;
     79        this->speedMultiply_ = 1.0f;
    8080
    8181        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     
    134134            return;
    135135
     136        Engine* engine = this->carrierToEngineHelper();
     137        if(engine == NULL) //!< If the PickupCarrier is no Engine, then this pickup is useless and therefore is destroyed.
     138            this->destroy();
     139       
    136140        //! If the pickup has transited to used.
    137141        if(this->isUsed())
    138142        {
    139             Engine* engine = this->carrierToEngineHelper();
    140             if(engine == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
    141                 this->destroy();
    142 
    143143            this->startPickupTimer(this->getDuration());
    144144            engine->setSpeedAdd(this->getSpeedAdd());
    145145            engine->setSpeedMultiply(this->getSpeedMultiply());
    146146        }
    147     }
    148 
    149 
     147        else
     148        {
     149            engine->setSpeedAdd(0.0f);
     150            engine->setSpeedMultiply(1.0f);
     151           
     152            if(this->isOnce())
     153            {
     154                this->destroy();
     155            }
     156        }
     157    }
    150158
    151159    /**
     
    250258    }
    251259
    252     void SpeedPickup::PickupTimerCallBack(void) {
    253             Engine* engine = this->carrierToEngineHelper();
    254             if(engine == NULL) //!< If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.
    255                 this->destroy();
    256 
    257             engine->setSpeedAdd(0.0f);
    258             engine->setSpeedMultiply(1.0f);
     260    void SpeedPickup::pickupTimerCallback(void)
     261    {       
     262        this->setUsed(false);
    259263    }
    260264}
  • code/branches/ppspickups1/src/modules/pickup/items/SpeedPickup.h

    r6705 r6706  
    3838
    3939#include <string>
    40 #include <worldentities/pawns/Pawn.h>
     40#include "worldentities/pawns/Pawn.h"
    4141#include "worldentities/StaticEntity.h"
    4242
     
    7878        protected:
    7979            void initializeIdentifier(void); //!< Initializes the PickupIdentifier of this pickup.
     80           
     81            virtual void pickupTimerCallback(void); //!< Function that gets called when timer ends.
    8082
    8183            void setDuration(float duration);
     
    8587        private:
    8688            void initialize(void); //!< Initializes the member variables.
    87             void PickupTimerCallBack(void); //!< Function that gets called when timer ends.
    8889            Engine* carrierToEngineHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    8990
Note: See TracChangeset for help on using the changeset viewer.