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