Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 5, 2010, 6:26:54 PM (14 years ago)
Author:
dafrick
Message:

Additional documentation, code niceifying and potential bug fixing. Also: Renamed DroppedItem to DroppedPickup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/pickup3/src/modules/pickup/PickupSpawner.h

    r6466 r6475  
    2323 *      Daniel 'Huty' Haggenmueller
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     
    3838
    3939#include <string>
     40#include "interfaces/Pickupable.h"
    4041#include "tools/Timer.h"
     42
    4143#include "tools/interfaces/Tickable.h"
    4244#include "worldentities/StaticEntity.h"
    43 #include "interfaces/Pickupable.h"
    4445
    4546namespace orxonox
    4647{
    4748    /**
    48         @brief PickupSpawner.
    49         @author Daniel 'Huty' Haggenmueller
     49        @brief
     50            The PickupSpawner class is responsible for spawning pickups of a specific type.
     51            Forthermore it can be specified how long the time interval between spawning two items is and how many pickups are spawned at maximum, amongst other things.
     52        @author
     53            Daniel 'Huty' Haggenmueller
     54            Damian 'Mozork' Frick
    5055    */
    5156    class _OrxonoxExport PickupSpawner : public StaticEntity, public Tickable
    5257    {
    5358        public:
    54             //TODO: Add limit of items spawned here.
    55             PickupSpawner(BaseObject* creator);
    56             PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems);
    57             virtual ~PickupSpawner();
     59            PickupSpawner(BaseObject* creator); //!< Default Constructor.
     60            PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor.
     61            virtual ~PickupSpawner(); //!< Destructor.
    5862
    59             //virtual void changedActivity();                                 //!< Invoked when activity has changed (set visibilty).
    6063            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a PickupSpawner through XML.
     64            virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
    6165            virtual void tick(float dt);
    6266
    6367            /**
    64                 @brief Get the distance in which to trigger.
    65                 @return Returns the distance in which this gets triggered.
     68            @brief Get the distance in which to trigger.
     69            @return Returns the distance in which this gets triggered.
    6670            */
    6771            inline float getTriggerDistance() const
    6872                { return this->triggerDistance_; }
    6973            /**
    70                 @brief Set the distance in which to trigger.
    71                 @param value The new distance in which to trigger.
     74            @brief Set the distance in which to trigger.
     75            @param value The new distance in which to trigger.
    7276            */
    7377            inline void setTriggerDistance(float value)
     
    7579
    7680            /**
    77                 @brief Get the time to respawn.
    78                 @returns Returns the time after which this gets re-actived.
     81            @brief Get the time to respawn.
     82            @returns Returns the time after which this gets re-actived.
    7983            */
    8084            inline float getRespawnTime() const
    8185                { return this->respawnTime_; }
    8286            /**
    83                 @brief Set the time to respawn.
    84                 @param time New time after which this gets re-actived.
     87            @brief Set the time to respawn.
     88            @param time New time after which this gets re-actived.
    8589            */
    8690            inline void setRespawnTime(float time)
     
    8892
    8993            /**
    90                 @brief Get the maximum number of items that will be spawned by this PickupSpawner.
    91                 @return Returns the maximum number of items spawned by this PickupSpawner.
     94            @brief Get the maximum number of items that will be spawned by this PickupSpawner.
     95            @return Returns the maximum number of items spawned by this PickupSpawner.
    9296            */
    9397            inline int getMaxSpawnedItems(void)
    9498                { return this->maxSpawnedItems_; }
    95             void setMaxSpawnedItems(int items);
     99            void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.
    96100
    97101        protected:
    98             virtual Pickupable* getPickup(void);
     102            void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
    99103           
    100             void setPickupable(Pickupable* pickup);
    101             const Pickupable* getPickupable(void);
     104            virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
    102105           
    103             void decrementSpawnsRemaining(void);
     106            void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
     107            const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
    104108           
    105109            Pickupable* pickup_; //!< The pickup to be spawned.
     
    108112            void initialize(void);
    109113           
    110             void trigger(Pawn* pawn);                                       //!< Method called when a Pawn is close enough.
    111             void respawnTimerCallback();                                    //!< Method called when the timer runs out.
     114            void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
     115            void respawnTimerCallback(); //!< Method called when the timer runs out.
    112116
    113             int maxSpawnedItems_;                   //!< Maximum number of items spawned by this PickupSpawner.
    114             int spawnsRemaining_;                   //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
     117            int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner.
     118            int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
    115119
    116             float triggerDistance_;                 //!< Distance in which this gets triggered.
     120            float triggerDistance_; //!< Distance in which this gets triggered.
    117121
    118             /* Pickup animation */
    119             float tickSum_;                         //!< Adds up tick to use in sine movement
    120             static const float bounceSpeed_s;       //!< Speed of pickup to bounce up and down
    121             static const float bounceDistance_s;    //!< Distance the pickup bounces up and down
    122             static const float rotationSpeed_s;     //!< Rotation speed of pickup
     122            float respawnTime_; //!< Time after which this gets re-actived.
     123            Timer respawnTimer_; //!< Timer used for re-activating.
    123124
    124             float respawnTime_;                     //!< Time after which this gets re-actived.
    125             Timer respawnTimer_;                    //!< Timer used for re-activating.
    126 
    127             static const int INF = -1;             //!< Constant for infinity.
     125            static const int INF = -1; //!< Constant for infinity.
    128126    };
    129127}
Note: See TracChangeset for help on using the changeset viewer.