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