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