Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 7899 was 7370, checked in by bensch, 19 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
RevLine 
[6080]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
[6083]12class World;
[6086]13class TiXmlElement;
[6083]14
[7357]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 */
[6080]34class SpawningPoint : public WorldEntity {
35
36  public:
[7357]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);
[6080]39    virtual ~SpawningPoint ();
[6088]40    void init();
[6080]41
[6512]42    virtual void loadParams(const TiXmlElement* root);
[6086]43
[6081]44    /**  sets the entity that is going to be spawned by this point @param classID: the id from the class_id.h file */
[6093]45    void SpawningPoint::setSpawningEntity(ClassID classID) { this->classID = classID; }
[6081]46    /** sets the frequency with which the point is going to spawn entities (1/sec) @param frequency: the frequency */
[7357]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; }
[6081]50
[6080]51
[7357]52    /** activates the spawning point */
53    void activate() { this->bSpawning = true; }
54    /** deactivates the spawning point */
55    void deactivate() { this->bSpawning = false; }
56
57
[6080]58    virtual void tick(float dt);
59    virtual void draw();
60
[7357]61
[6080]62  private:
[7357]63    void spawn();
[6080]64
[7357]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
[7370]72    ObjectManager::EntityList   queue;                          //!< queue of waiting WorldEntities to be spawned
[7357]73    bool                      bSpawning;                      //!< flag to indicate if this spawning point is active or not
[6080]74};
75
76#endif /* _SPAWNING_POINT */
Note: See TracBrowser for help on using the repository browser.