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 <list> |
---|
13 | |
---|
14 | #include "world_entities/weapons/weapon_manager.h" |
---|
15 | |
---|
16 | class Weapon; |
---|
17 | class DotEmitter; |
---|
18 | class Player; |
---|
19 | class SpriteParticles; |
---|
20 | class Explosion; |
---|
21 | |
---|
22 | //! Basic controllable WorldEntity |
---|
23 | /** |
---|
24 | * |
---|
25 | */ |
---|
26 | class Playable : public WorldEntity, public Extendable |
---|
27 | { |
---|
28 | public: |
---|
29 | virtual ~Playable(); |
---|
30 | |
---|
31 | virtual void loadParams(const TiXmlElement* root); |
---|
32 | |
---|
33 | virtual void die(); |
---|
34 | virtual void respawn(); |
---|
35 | |
---|
36 | virtual bool pickup(PowerUp* powerUp); |
---|
37 | |
---|
38 | void addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); |
---|
39 | void removeWeapon(Weapon* weapon); |
---|
40 | void nextWeaponConfig(); |
---|
41 | void previousWeaponConfig(); |
---|
42 | |
---|
43 | inline WeaponManager* getWeaponManager() const { return this->weaponMan; }; |
---|
44 | void weaponConfigChanged(); |
---|
45 | |
---|
46 | |
---|
47 | bool setPlayer(Player* player); |
---|
48 | Player* getCurrentPlayer() const { return this->currentPlayer; }; |
---|
49 | |
---|
50 | void attachCamera(); |
---|
51 | void detachCamera(); |
---|
52 | virtual void setCameraMode(unsigned int cameraMode = 0); |
---|
53 | |
---|
54 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
55 | virtual void process(const Event &event); |
---|
56 | |
---|
57 | virtual void tick(float dt); |
---|
58 | |
---|
59 | /** @return a List of Events in PEV_* sytle */ |
---|
60 | inline const std::list<int>& getEventList() { return this->events; }; |
---|
61 | |
---|
62 | int writeSync(const byte* data, int length, int sender); |
---|
63 | int readSync(byte* data, int maxLength ); |
---|
64 | bool needsReadSync(); |
---|
65 | |
---|
66 | |
---|
67 | virtual void setAbsDirPlay(const Quaternion& rot) = 0; |
---|
68 | void setAbsDirPlay(float angle, float dirX, float dirY, float dirZ) { this->setAbsDirPlay(Quaternion(angle, Vector(dirX, dirY, dirZ))); } |
---|
69 | |
---|
70 | inline void setScore( int score ) { this->score = score; } |
---|
71 | inline int getScore() { return this->score; } |
---|
72 | |
---|
73 | protected: |
---|
74 | Playable(); |
---|
75 | |
---|
76 | virtual void enter() = 0; |
---|
77 | virtual void leave() = 0; |
---|
78 | |
---|
79 | void registerEvent(int eventType); |
---|
80 | void unregisterEvent(int eventType); |
---|
81 | |
---|
82 | private: |
---|
83 | WeaponManager* weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping |
---|
84 | std::list<int> events; //!< A list of Events, that are captured for this playable |
---|
85 | |
---|
86 | Player* currentPlayer; //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL |
---|
87 | |
---|
88 | bool bFire; //!< If the Ship is firing. |
---|
89 | int oldFlags; //!< Used for synchronisation |
---|
90 | |
---|
91 | int score; |
---|
92 | int oldScore; |
---|
93 | |
---|
94 | bool bDead; |
---|
95 | |
---|
96 | //TODO HACK: explosion emitter |
---|
97 | |
---|
98 | |
---|
99 | WorldEntity* collider; |
---|
100 | }; |
---|
101 | |
---|
102 | #endif /* _PLAYABLE_H */ |
---|