Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: merged the proxy bache back with no conflicts

File size: 2.4 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
[8802]10#include "playable.h"
[6080]11
[9008]12#include "message_manager.h"
13
[8802]14#include <list>
[8068]15
[6083]16class World;
[6086]17class TiXmlElement;
[6083]18
[8802]19struct QueueEntry
20{
21  float respawnTime;
[9008]22  Playable * entity;
[8802]23};
[7357]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 */
[6080]43class SpawningPoint : public WorldEntity {
44
45  public:
[9008]46    SpawningPoint(const TiXmlElement* root = NULL);
[6080]47    virtual ~SpawningPoint ();
[6088]48    void init();
[6080]49
[6512]50    virtual void loadParams(const TiXmlElement* root);
[6086]51
[9494]52    inline int getTeamId() const { return this->teamId; }
53    inline void setTeamId( int teamId ) { this->teamId = teamId; }
[6081]54
[9008]55    void pushEntity(Playable* entity, float delay = 0);
[6080]56
[7357]57    /** activates the spawning point */
[8068]58    inline void activate() { this->bSpawning = true; }
[7357]59    /** deactivates the spawning point */
[8068]60    inline void deactivate() { this->bSpawning = false; }
61    inline bool isActive() const { return this->bSpawning; }
[7357]62
63
[6080]64    virtual void tick(float dt);
[9494]65    virtual void draw() const;
[6080]66
[7357]67
[6080]68  private:
[9008]69    void spawn(Playable* entity);
[9494]70
[9008]71    void sendRespawnMessage( int uniqueId );
[9656]72    static bool respawnMessageHandler( MessageType messageType, byte * data, int dataLength, void * someData, int senderId, int destinationId  );
[6080]73
[7357]74
75  private:
[8068]76    float                           localTimer;                     //!< the local timer
[8802]77    int                             teamId;                         //!< only spawn players of this team
78    std::list<QueueEntry>           queue;                          //!< queue of waiting WorldEntities to be spawned
[8068]79    bool                            bSpawning;                      //!< flag to indicate if this spawning point is active or not
[6080]80};
81
82#endif /* _SPAWNING_POINT */
Note: See TracBrowser for help on using the repository browser.