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