Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/world_entities/playable.h @ 9550

Last change on this file since 9550 was 9507, checked in by patrick, 18 years ago

the player team change should now work on all clients in the network, its now a global synch variable

File size: 4.6 KB
Line 
1
2/*!
3 * @file playable.h
4 * Interface for a basic controllable WorldEntity
5 */
6#ifndef _PLAYABLE_H
7#define _PLAYABLE_H
8
9#include "world_entity.h"
10#include "extendable.h"
11#include "event.h"
12#include <vector>
13#include <list>
14
15#include "world_entities/weapons/weapon_manager.h"
16
17class Weapon;
18class DotEmitter;
19class Player;
20class SpriteParticles;
21class Explosion;
22
23//! Basic controllable WorldEntity
24/**
25 *
26 */
27class Playable : public WorldEntity, public Extendable
28{
29public:
30  //! Defines the Playmode of an Entity.
31  typedef enum {
32    Vertical         =  1,       //!< Vertical (seen from left or right/move in x-z)
33    Horizontal       =  2,       //!< Horizontal (seet from the top/move in x-y)
34    FromBehind       =  4,       //!< Seen from behind (move in z-y)
35    Full3D           =  8,       //!< Full featured 3D-mode. (move in all directions x-y-z)
36    FirstPerson      = 16,
37
38    PlaymodeCount    =  5,
39  } Playmode;
40
41
42public:
43  virtual ~Playable();
44
45  virtual void loadParams(const TiXmlElement* root);
46  void varChangeHandler( std::list< int > & id );
47
48  // Weapon and Pickups
49  virtual bool pickup(PowerUp* powerUp);
50  bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
51  void removeWeapon(Weapon* weapon);
52  void nextWeaponConfig();
53  void previousWeaponConfig();
54  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
55  void weaponConfigChanged();
56  static void addSomeWeapons_CHEAT();
57
58
59  // Player Settup
60  bool hasPlayer(){return !(this->currentPlayer == NULL);}
61  bool setPlayer(Player* player);
62  Player* getCurrentPlayer() const { return this->currentPlayer; };
63  /** @return a List of Events in PEV_* sytle */
64  inline const std::vector<int>& getEventList() { return this->events; };
65
66
67  // Camera and Playmode
68  void attachCamera();
69  void detachCamera();
70  void setCameraMode(unsigned int cameraMode = 0);
71  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
72  bool setPlaymode(Playable::Playmode playmode);
73  Playable::Playmode getPlaymode() const { return this->playmode; };
74  virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0;
75  void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f);
76
77  // Networking interface
78  inline void setScore( int score ) { this->score = score; }
79  inline int  getScore() { return this->score; }
80  inline void setTeamId( int teamId) { this->teamId = teamId;}
81  inline int getTeamId() const { return this->teamId; }
82  virtual void setTeam(int teamID);
83
84
85  void setEnterRadius(float radius) { this->enterRadius = radius; };
86  /** @returns the EnterRadius (how far away a Player must be to enter this entity) */
87  inline float getEnterRadius() const { return this->enterRadius; };
88
89  // WorldEntity Extensions
90  virtual void destroy(WorldEntity* killer);
91  virtual void respawn();
92  virtual void process(const Event &event);
93  virtual void tick(float dt);
94
95
96  inline bool beFire() const { return this->bFire; }
97  inline void fire(bool bF) { this->bFire = bF;}
98
99  // Transformations:
100  static Playable::Playmode stringToPlaymode(const std::string& playmode);
101  static const std::string& playmodeToString(Playable::Playmode playmode);
102  static const std::string playmodeNames[];
103
104protected:
105  Playable();
106
107  // Player Setup
108  virtual void enter() = 0;
109  virtual void leave() = 0;
110  // Playmode
111  void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; };
112  virtual void enterPlaymode(Playable::Playmode playmode);
113
114  // Events.
115  void registerEvent(int eventType);
116  void unregisterEvent(int eventType);
117
118private:
119  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
120  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
121
122  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
123
124  bool                  bFire;              //!< If the Ship is firing.
125  int                   oldFlags;           //!< Used for synchronisation
126
127  int                   score;              //!< players score
128  int                   teamChangeHandler;  //!< handler id for team changes network sync
129  int                   teamId;             //!< id of the current team
130
131  bool                  bDead;
132  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
133  Playable::Playmode    playmode;           //!< The current playmode.
134
135  float                 enterRadius;        //!< How far one can be away from the Playable to enter it.
136
137  WorldEntity*          collider;
138};
139
140#endif /* _PLAYABLE_H */
Note: See TracBrowser for help on using the repository browser.