Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6708


Ignore:
Timestamp:
Apr 13, 2010, 9:07:08 AM (15 years ago)
Author:
dafrick
Message:

Some cleanup.

Location:
code/branches/ppspickups2/src/modules/pickup
Files:
7 edited

Legend:

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

    r6641 r6708  
    250250            return false;
    251251        }
    252         this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::PickupTimerCallBack, this)));
     252        this->durationTimer_.setTimer(durationTime, false, createExecutor(createFunctor(&Pickup::pickupTimerCallback, this)));
    253253        return true;
    254254    }
  • code/branches/ppspickups2/src/modules/pickup/Pickup.h

    r6641 r6708  
    137137            bool startPickupTimer(float durationTime);
    138138
    139             virtual void PickupTimerCallBack(void) {}
     139            virtual void pickupTimerCallback(void) {}
    140140
    141141            /**
  • code/branches/ppspickups2/src/modules/pickup/PickupPrereqs.h

    r6524 r6708  
    7676    //items
    7777    class HealthPickup;
     78    class InvisiblePickup;
    7879    class MetaPickup;
    7980   
  • code/branches/ppspickups2/src/modules/pickup/PickupSpawner.cc

    r6540 r6708  
    103103    void PickupSpawner::initialize(void)
    104104    {
    105         this->triggerDistance_ = 20;
     105        this->triggerDistance_ = 10;
    106106        this->respawnTime_ = 0;
    107107        this->maxSpawnedItems_ = INF;
  • code/branches/ppspickups2/src/modules/pickup/items/CMakeLists.txt

    r6641 r6708  
    11ADD_SOURCE_FILES(PICKUP_SRC_FILES
    22  HealthPickup.cc
     3  InvisiblePickup.cc
    34  MetaPickup.cc
    4   InvisiblePickup.cc
    55)
  • code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.cc

    r6684 r6708  
    5555    {
    5656        RegisterObject(InvisiblePickup);
    57         //! Defines who is allowed to pick up the pickup.
    58         this->initialize();
     57        //! Defines who is allowed to pick up the pickup.
     58        this->initialize();
    5959    }
    6060   
     
    7070    void InvisiblePickup::initializeIdentifier(void)
    7171    {
    72         std::stringstream stream;
    73         stream << this->getDuration();
    74         std::string type1 = "duration";
    75         std::string val1 = stream.str();
    76         this->pickupIdentifier_->addParameter(type1, val1);
     72        std::stringstream stream;
     73        stream << this->getDuration();
     74        std::string type1 = "duration";
     75        std::string val1 = stream.str();
     76        this->pickupIdentifier_->addParameter(type1, val1);
    7777    }
    7878   
     
    8383    void InvisiblePickup::initialize(void)
    8484    {
    85         this->duration_ = 0.0;
    86         this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
     85        this->duration_ = 0.0f;
     86        this->addTarget(ClassIdentifier<Pawn>::getIdentifier());
    8787    }
    8888
     
    9494    {
    9595        SUPER(InvisiblePickup, XMLPort, xmlelement, mode);   
    96         XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
    97        
    98         this->initializeIdentifier();
     96        XMLPortParam(InvisiblePickup, "duration", setDuration, getDuration, xmlelement, mode);
     97       
     98        this->initializeIdentifier();
    9999    }
    100100   
     
    106106    {
    107107        SUPER(InvisiblePickup, changedUsed);
    108        
    109108       
    110109        //! If the pickup is not picked up nothing must be done.
    111110        if(!this->isPickedUp())
    112111            return;
    113         if (this->isUsed())
    114         {
    115             this->startPickupTimer(this->getDuration());
    116             this->setInvisible(true);
    117         }
    118         else
    119           this->setInvisible(false);
    120        
     112       
     113        if (this->isUsed())
     114        {
     115            this->startPickupTimer(this->getDuration());
     116            this->setInvisible(true);
     117        }
     118        else
     119        {
     120            this->setInvisible(false);
     121            this->destroy();
     122        }
     123       
    121124    }
    122125   
     
    151154       
    152155        SUPER(InvisiblePickup, clone, item);
    153        
    154         InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
    155         pickup->setDuration(this->getDuration());
    156         pickup->initializeIdentifier();
     156       
     157        InvisiblePickup* pickup = dynamic_cast<InvisiblePickup*>(item);
     158        pickup->setDuration(this->getDuration());
     159        pickup->initializeIdentifier();
    157160    }
    158161   
     
    160163    @brief
    161164        Sets the invisibility.
    162     @param health
     165    @param invisibility
    163166        The invisibility.
    164167    */
    165168    bool InvisiblePickup::setInvisible(bool invisibility)
    166169    {
    167      
    168       Pawn* pawn = this->carrierToPawnHelper();
    169       pawn->setVisible(!invisibility);
    170       return 0;
    171     }
    172    
    173     /**
    174     @brief
    175     Sets the duration.
     170        Pawn* pawn = this->carrierToPawnHelper();
     171        if(pawn == NULL)
     172            return false;
     173       
     174        pawn->setVisible(!invisibility);
     175        return true;
     176    }
     177   
     178    /**
     179    @brief
     180        Sets the duration.
    176181    @param duration
    177     The duration
     182        The duration
    178183    */
    179184    void InvisiblePickup::setDuration(float duration)
    180185    {
    181         if(duration >= 0.0f)
    182         {
    183             this->duration_ = duration;
    184         }
    185         else
    186         {
    187             COUT(1) << "Invalid duration in InvisiblePickup." << std::endl;
    188             this->duration_ = 0;
    189         }
    190     }
    191    
    192     void InvisiblePickup::PickupTimerCallBack(void)
    193     {
    194         this->setInvisible(false);
     186        if(duration >= 0.0f)
     187        {
     188            this->duration_ = duration;
     189        }
     190        else
     191        {
     192            COUT(1) << "Invalid duration in InvisiblePickup." << std::endl;
     193            this->duration_ = 0.0f;
     194        }
     195    }
     196   
     197    void InvisiblePickup::pickupTimerCallback(void)
     198    {
     199        this->setUsed(false);
    195200    }
    196201
  • code/branches/ppspickups2/src/modules/pickup/items/InvisiblePickup.h

    r6641 r6708  
    6464            virtual void clone(OrxonoxClass*& item); //!< Creates a duplicate of the input OrxonoxClass.
    6565           
    66              /**
    67             @brief Checks wether the Pawn is invisible.
     66            /**
     67            @brief Checks whether the Pawn is invisible.
    6868            @return Returns if the Pawn is invisible.
    6969            */
    7070            inline bool getInvisibility(bool)
    7171                { return this->invisible_; }
    72             inline float getDuration()
    73                 {return this->duration_;}
     72            inline float getDuration()
     73                { return this->duration_; }
    7474 
    7575        protected:
    76             bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
    77             void setDuration(float duration);
    78             void initializeIdentifier(void);
     76            bool setInvisible(bool invisibility); //!< Set the Pawn to be invisible or visible again.
     77            void setDuration(float duration);
     78            void initializeIdentifier(void);
     79            virtual void pickupTimerCallback(void); //!< Function that gets called when the timer ends.
    7980       
    8081        private:
    81            void initialize(void); //!< Initializes the member variables.
     82            void initialize(void); //!< Initializes the member variables.
    8283            Pawn* carrierToPawnHelper(void); //!< Helper to transform the PickupCarrier to a Pawn, and throw an error message if the conversion fails.
    83             void PickupTimerCallBack(void); //!< Function that gets called when the timer ends.
    84             bool invisible_; //!< Helper to remember wether the Pawn is invisible.
    85             float duration_; //! Duration of invisibility.
     84            bool invisible_; //!< Helper to remember wether the Pawn is invisible.
     85            float duration_; //! Duration of invisibility.
    8686    };
    8787}
Note: See TracChangeset for help on using the changeset viewer.