Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.old/src/world_entities/playable.h @ 10642

Last change on this file since 10642 was 9406, checked in by bensch, 18 years ago

orxonox/trunk: merged the proxy back

merged with commandsvn merge -r9346:HEAD https://svn.orxonox.net/orxonox/branches/proxy .

no conflicts

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