[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 | |
---|
[7092] | 30 | virtual void loadParams(const TiXmlElement* root); |
---|
[5838] | 31 | |
---|
[6966] | 32 | virtual void die(); |
---|
[7044] | 33 | virtual void respawn(); |
---|
[6966] | 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 | |
---|
[6986] | 46 | bool setPlayer(Player* player); |
---|
| 47 | Player* getCurrentPlayer() const { return this->currentPlayer; }; |
---|
[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 | |
---|
[7092] | 64 | |
---|
| 65 | virtual void setAbsDirPlay(const Quaternion& rot) = 0; |
---|
| 66 | void setAbsDirPlay(float angle, float dirX, float dirY, float dirZ) { this->setAbsDirPlay(Quaternion(angle, Vector(dirX, dirY, dirZ))); } |
---|
| 67 | |
---|
[6959] | 68 | inline void setScore( int score ) { this->score = score; } |
---|
| 69 | inline int getScore() { return this->score; } |
---|
[5838] | 70 | |
---|
[5877] | 71 | protected: |
---|
[6804] | 72 | Playable(); |
---|
| 73 | |
---|
[6986] | 74 | virtual void enter() = 0; |
---|
| 75 | virtual void leave() = 0; |
---|
| 76 | |
---|
[5877] | 77 | void registerEvent(int eventType); |
---|
[5895] | 78 | void unregisterEvent(int eventType); |
---|
[5872] | 79 | |
---|
[5838] | 80 | private: |
---|
| 81 | WeaponManager* weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping |
---|
[5898] | 82 | std::list<int> events; //!< A list of Events, that are captured for this playable |
---|
[5886] | 83 | |
---|
[5898] | 84 | Player* currentPlayer; //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL |
---|
[5888] | 85 | |
---|
[6804] | 86 | bool bFire; //!< If the Ship is firing. |
---|
[6868] | 87 | int oldFlags; //!< Used for synchronisation |
---|
[6966] | 88 | |
---|
[6959] | 89 | int score; |
---|
| 90 | int oldScore; |
---|
[6804] | 91 | |
---|
[6994] | 92 | //TODO HACK: explosion emitter |
---|
[6959] | 93 | DotEmitter* emitter; |
---|
| 94 | SpriteParticles* explosionParticles; |
---|
[7072] | 95 | |
---|
| 96 | WorldEntity* collider; |
---|
[5838] | 97 | }; |
---|
| 98 | |
---|
| 99 | #endif /* _PLAYABLE_H */ |
---|