Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10626 was 10618, checked in by bknecht, 18 years ago

merged cleanup into trunk (only improvements)

File size: 2.4 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 "playable.h"
11
12#include "message_manager.h"
13
14#include <list>
15
16class World;
17class TiXmlElement;
18
19struct QueueEntry
20{
21  float respawnTime;
22  Playable * entity;
23};
24
25//!< used to indicate what type of objects are spawned by this spawning point
26typedef enum SpawningPointMode
27{
28  SPT_ALL_AT_ONCE = 0,                               //!< at this spawning points there will be players spawned (typicaly in MP games)
29  SPT_ONE_AFTER_OTHER,                               //!< at this spawning points there will be NPS spawnded
30
31  SPT_NUMBER
32};
33
34
35/**
36 * The spawning point for WorldEntities (and only WorldEntities)
37 *
38 * There are commonly two different spawning modes:
39 *
40 *  1) Just spawn whatever is in the queue with a given frequency (if delay = 0 => immediate spawn)
41 *  2) Spawn everything in the queue together with the given frequency
42 */
43class SpawningPoint : public WorldEntity {
44  ObjectListDeclaration(SpawningPoint);
45  public:
46    SpawningPoint(const TiXmlElement* root = NULL);
47    virtual ~SpawningPoint ();
48    void init();
49
50    virtual void loadParams(const TiXmlElement* root);
51
52    inline int getTeamId() const { return this->teamId; }
53    inline void setTeamId( int teamId ) { this->teamId = teamId; }
54
55    void pushEntity(Playable* entity, float delay = 0);
56
57    /** activates the spawning point */
58    inline void activate() { this->bSpawning = true; }
59    /** deactivates the spawning point */
60    inline void deactivate() { this->bSpawning = false; }
61    inline bool isActive() const { return this->bSpawning; }
62
63
64    virtual void tick(float dt);
65    virtual void draw() const;
66
67
68  private:
69    void spawn(Playable* entity);
70
71    void sendRespawnMessage( int uniqueId );
72    static bool respawnMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  );
73
74
75  private:
76    float                           localTimer;                     //!< the local timer
77    int                             teamId;                         //!< only spawn players of this team
78    std::list<QueueEntry>           queue;                          //!< queue of waiting WorldEntities to be spawned
79    bool                            bSpawning;                      //!< flag to indicate if this spawning point is active or not
80};
81
82#endif /* _SPAWNING_POINT */
Note: See TracBrowser for help on using the repository browser.