Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/spawning_point.h @ 7370

Last change on this file since 7370 was 7370, checked in by bensch, 18 years ago

orxonox/trunk: drawLists/tickLists are used, and made some TiXmlElement to const TiXmlElement, also fixed some bugs in the loadWorldEntities-functions from Gameworld and SipleGameMenu

File size: 2.8 KB
Line 
1/*!
2 * @file spawning_point.h
3 *  Definition of a spawning point within the game, used for network game
4 */
5
6
7#ifndef _SPAWNING_POINT
8#define _SPAWNING_POINT
9
10#include "world_entity.h"
11
12class World;
13class TiXmlElement;
14
15
16//!< used to indicate what type of objects are spawned by this spawning point
17typedef enum SpawningPointMode
18{
19  SPT_ALL_AT_ONCE = 0,                               //!< at this spawning points there will be players spawned (typicaly in MP games)
20  SPT_ONE_AFTER_OTHER,                               //!< at this spawning points there will be NPS spawnded
21
22  SPT_NUMBER
23};
24
25
26/**
27 * The spawning point for WorldEntities (and only WorldEntities)
28 *
29 * There are commonly two different spawning modes:
30 *
31 *  1) Just spawn whatever is in the queue with a given frequency (if delay = 0 => immediate spawn)
32 *  2) Spawn everything in the queue together with the given frequency
33 */
34class SpawningPoint : public WorldEntity {
35
36  public:
37    SpawningPoint (ClassID classID, const Vector& position = Vector(0.0, 0.0, 0.0));
38    SpawningPoint (const Vector& position, ClassID classID, SpawningPointMode type, float delay);
39    virtual ~SpawningPoint ();
40    void init();
41
42    virtual void loadParams(const TiXmlElement* root);
43
44    /**  sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */
45    void SpawningPoint::setSpawningEntity(ClassID classID) { this->classID = classID; }
46    /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */
47    void SpawningPoint::setSpawningDelay(float delay) { this->delay = delay; }
48    /** sets the spawning point mode @param mode: the mode */
49    void SpawningPoint::setSpawningMode(int mode) { this->mode = (SpawningPointMode)mode; }
50
51
52    /** activates the spawning point */
53    void activate() { this->bSpawning = true; }
54    /** deactivates the spawning point */
55    void deactivate() { this->bSpawning = false; }
56
57
58    virtual void tick(float dt);
59    virtual void draw();
60
61
62  private:
63    void spawn();
64
65
66  private:
67    float                     delay;                          //!< the timer that counts down until the next spawn
68    float                     localTimer;                     //!< the local timer
69    float                     seed;                           //!< the random seed of the position
70    ClassID                   classID;                        //!< the classid of the entity to spawn
71    SpawningPointMode         mode;                           //!< the mode of the spawning point
72    ObjectManager::EntityList   queue;                          //!< queue of waiting WorldEntities to be spawned
73    bool                      bSpawning;                      //!< flag to indicate if this spawning point is active or not
74};
75
76#endif /* _SPAWNING_POINT */
Note: See TracBrowser for help on using the repository browser.