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