Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ODE/src/world_entities/playable.h @ 10244

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

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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