Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/pickup/PickupSpawner.h @ 6531

Last change on this file since 6531 was 6524, checked in by dafrick, 15 years ago

Merged pickup branch into trunk. Yay. Persisting bugs will be fixed, very soon.

  • Property svn:eol-style set to native
File size: 5.0 KB
RevLine 
[2917]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Daniel 'Huty' Haggenmueller
24 *   Co-authors:
[6475]25 *      Damian 'Mozork' Frick
[2917]26 *
27 */
28
29/**
30    @file
31    @brief Definition of PickupSpawner.
32*/
33
34#ifndef _PickupSpawner_H__
35#define _PickupSpawner_H__
36
[6466]37#include "PickupPrereqs.h"
[2917]38
[3196]39#include <string>
[6475]40#include "interfaces/Pickupable.h"
[3196]41#include "tools/Timer.h"
[6475]42
[5693]43#include "tools/interfaces/Tickable.h"
[5735]44#include "worldentities/StaticEntity.h"
[2917]45
46namespace orxonox
47{
48    /**
[6475]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
[2917]55    */
[6496]56    class _PickupExport PickupSpawner : public StaticEntity, public Tickable
[2917]57    {
[5947]58        public:
[6475]59            PickupSpawner(BaseObject* creator); //!< Default Constructor.
60            PickupSpawner(BaseObject* creator, Pickupable* pickup, float triggerDistance, float respawnTime, int maxSpawnedItems); //!< Constructor.
61            virtual ~PickupSpawner(); //!< Destructor.
[2917]62
[5947]63            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);  //!< Method for creating a PickupSpawner through XML.
[6475]64            virtual void changedActivity(); //!< Invoked when activity has changed (set visibilty).
[5947]65            virtual void tick(float dt);
[2917]66
[5947]67            /**
[6475]68            @brief Get the distance in which to trigger.
69            @return Returns the distance in which this gets triggered.
[5947]70            */
71            inline float getTriggerDistance() const
72                { return this->triggerDistance_; }
73            /**
[6475]74            @brief Set the distance in which to trigger.
75            @param value The new distance in which to trigger.
[5947]76            */
77            inline void setTriggerDistance(float value)
78                { this->triggerDistance_ = value; }
[2917]79
[5947]80            /**
[6475]81            @brief Get the time to respawn.
82            @returns Returns the time after which this gets re-actived.
[5947]83            */
84            inline float getRespawnTime() const
85                { return this->respawnTime_; }
86            /**
[6475]87            @brief Set the time to respawn.
88            @param time New time after which this gets re-actived.
[5947]89            */
90            inline void setRespawnTime(float time)
91                { this->respawnTime_ = time; }
[5953]92
[6421]93            /**
[6475]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.
[6421]96            */
[5953]97            inline int getMaxSpawnedItems(void)
98                { return this->maxSpawnedItems_; }
[6475]99            void setMaxSpawnedItems(int items); //!< Sets the maximum number of spawned items.
[5953]100
101        protected:
[6475]102            void decrementSpawnsRemaining(void); //!< Decrements the number of remaining spawns.
[6512]103                       
104            void startRespawnTimer(void);
[6405]105           
[6475]106            virtual Pickupable* getPickup(void); //!< Creates a new Pickupable.
[6405]107           
[6475]108            void setPickupable(Pickupable* pickup); //!< Sets a Pickupable for the PickupSpawner to spawn.
109            const Pickupable* getPickupable(void); //!< Get the Pickupable that is spawned by this PickupSpawner.
[6421]110           
111            Pickupable* pickup_; //!< The pickup to be spawned.
[5953]112
[5947]113        private:
[5953]114            void initialize(void);
[6405]115           
[6475]116            void trigger(Pawn* pawn); //!< Method called when a Pawn is close enough.
117            void respawnTimerCallback(); //!< Method called when the timer runs out.
[5953]118
[6475]119            int maxSpawnedItems_; //!< Maximum number of items spawned by this PickupSpawner.
120            int spawnsRemaining_; //!< Number of items that can be spawned by this PickupSpawner until it selfdestructs.
[5953]121
[6475]122            float triggerDistance_; //!< Distance in which this gets triggered.
[2917]123
[6475]124            float respawnTime_; //!< Time after which this gets re-actived.
125            Timer respawnTimer_; //!< Timer used for re-activating.
[3046]126
[6475]127            static const int INF = -1; //!< Constant for infinity.
[2917]128    };
129}
130
131#endif /* _PickupSpawner_H__ */
Note: See TracBrowser for help on using the repository browser.