Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/playable.h @ 7348

Last change on this file since 7348 was 7347, checked in by bensch, 19 years ago

orxonox/trunk: some more stuff (now one can play around with them using the Shell →
GameWorld Urban Playmode …. Vertical/Full3D/Horizontal

File size: 3.8 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  } Playmode;
36
37
38public:
39  virtual ~Playable();
40
41  virtual void loadParams(const TiXmlElement* root);
42
43  // Weapon and Pickups
44  virtual bool pickup(PowerUp* powerUp);
45  void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1);
46  void removeWeapon(Weapon* weapon);
47  void nextWeaponConfig();
48  void previousWeaponConfig();
49  inline WeaponManager& getWeaponManager() { return this->weaponMan; };
50  void weaponConfigChanged();
51
52
53  // Player Settup
54  bool setPlayer(Player* player);
55  Player* getCurrentPlayer() const { return this->currentPlayer; };
56  /** @return a List of Events in PEV_* sytle */
57  inline const std::vector<int>& getEventList() { return this->events; };
58
59  // Camera and Playmode
60  void attachCamera();
61  void detachCamera();
62  void setCameraMode(unsigned int cameraMode = 0);
63  bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; };
64  bool setPlaymode(Playable::Playmode playmode);
65  Playable::Playmode getPlaymode() const { return this->playmode; };
66  virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0;
67  void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f);
68
69  inline void setScore( int score ) { this->score = score; }
70  inline int  getScore() { return this->score; }
71
72
73  // WorldEntity Extensions
74  virtual void die();
75  virtual void respawn();
76  virtual void collidesWith(WorldEntity* entity, const Vector& location);
77  virtual void process(const Event &event);
78  virtual void tick(float dt);
79
80  // NETWORK
81  int       writeSync(const byte* data, int length, int sender);
82  int       readSync(byte* data, int maxLength );
83  bool      needsReadSync();
84
85
86  // Transformations:
87  static Playable::Playmode stringToPlaymode(const std::string& playmode);
88  static const char* playmodeToString(Playable::Playmode playmode);
89protected:
90  Playable();
91
92  // Player Setup
93  virtual void enter() = 0;
94  virtual void leave() = 0;
95  // Playmode
96  void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; };
97  virtual void enterPlaymode(Playable::Playmode playmode);
98
99  // Events.
100  void registerEvent(int eventType);
101  void unregisterEvent(int eventType);
102
103private:
104  WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping
105  std::vector<int>      events;             //!< A list of Events, that are captured for this playable
106
107  Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL
108
109  bool                  bFire;              //!< If the Ship is firing.
110  int                   oldFlags;           //!< Used for synchronisation
111
112  int                   score;
113  int                   oldScore;
114
115  bool                  bDead;
116  short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
117  Playable::Playmode    playmode;           //!< The current playmode.
118
119  WorldEntity* collider;
120};
121
122#endif /* _PLAYABLE_H */
Note: See TracBrowser for help on using the repository browser.