| 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 <vector> | 
|---|
| 13 |  | 
|---|
| 14 | #include "world_entities/weapons/weapon_manager.h" | 
|---|
| 15 |  | 
|---|
| 16 | class Weapon; | 
|---|
| 17 | class DotEmitter; | 
|---|
| 18 | class Player; | 
|---|
| 19 | class SpriteParticles; | 
|---|
| 20 | class Explosion; | 
|---|
| 21 |  | 
|---|
| 22 | //! Basic controllable WorldEntity | 
|---|
| 23 | /** | 
|---|
| 24 |  * | 
|---|
| 25 |  */ | 
|---|
| 26 | class Playable : public WorldEntity, public Extendable | 
|---|
| 27 | { | 
|---|
| 28 | public: | 
|---|
| 29 |   //! Defines the Playmode of an Entity. | 
|---|
| 30 |   typedef enum { | 
|---|
| 31 |     Vertical         = 1,       //!< Vertical (seen from left or right/move in x-z) | 
|---|
| 32 |     Horizontal       = 2,       //!< Horizontal (seet from the top/move in x-y) | 
|---|
| 33 |     FromBehind       = 4,       //!< Seen from behind (move in z-y) | 
|---|
| 34 |     Full3D           = 8,       //!< Full featured 3D-mode. (move in all directions x-y-z) | 
|---|
| 35 |  | 
|---|
| 36 |     PlaymodeCount    = 4, | 
|---|
| 37 |   } Playmode; | 
|---|
| 38 |  | 
|---|
| 39 |  | 
|---|
| 40 | public: | 
|---|
| 41 |   virtual ~Playable(); | 
|---|
| 42 |  | 
|---|
| 43 |   virtual void loadParams(const TiXmlElement* root); | 
|---|
| 44 |  | 
|---|
| 45 |   // Weapon and Pickups | 
|---|
| 46 |   virtual bool pickup(PowerUp* powerUp); | 
|---|
| 47 |   bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); | 
|---|
| 48 |   void removeWeapon(Weapon* weapon); | 
|---|
| 49 |   void nextWeaponConfig(); | 
|---|
| 50 |   void previousWeaponConfig(); | 
|---|
| 51 |   inline WeaponManager& getWeaponManager() { return this->weaponMan; }; | 
|---|
| 52 |   void weaponConfigChanged(); | 
|---|
| 53 |   static void addSomeWeapons_CHEAT(); | 
|---|
| 54 |  | 
|---|
| 55 |  | 
|---|
| 56 |   // Player Settup | 
|---|
| 57 |   bool setPlayer(Player* player); | 
|---|
| 58 |   Player* getCurrentPlayer() const { return this->currentPlayer; }; | 
|---|
| 59 |   /** @return a List of Events in PEV_* sytle */ | 
|---|
| 60 |   inline const std::vector<int>& getEventList() { return this->events; }; | 
|---|
| 61 |  | 
|---|
| 62 |   // Camera and Playmode | 
|---|
| 63 |   void attachCamera(); | 
|---|
| 64 |   void detachCamera(); | 
|---|
| 65 |   void setCameraMode(unsigned int cameraMode = 0); | 
|---|
| 66 |   bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; }; | 
|---|
| 67 |   bool setPlaymode(Playable::Playmode playmode); | 
|---|
| 68 |   Playable::Playmode getPlaymode() const { return this->playmode; }; | 
|---|
| 69 |   virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0; | 
|---|
| 70 |   void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f); | 
|---|
| 71 |  | 
|---|
| 72 |   inline void setScore( int score ) { this->score = score; } | 
|---|
| 73 |   inline int  getScore() { return this->score; } | 
|---|
| 74 |  | 
|---|
| 75 |  | 
|---|
| 76 |   // WorldEntity Extensions | 
|---|
| 77 |   virtual void die(); | 
|---|
| 78 |   virtual void respawn(); | 
|---|
| 79 |   virtual void collidesWith(WorldEntity* entity, const Vector& location); | 
|---|
| 80 |   virtual void process(const Event &event); | 
|---|
| 81 |   virtual void tick(float dt); | 
|---|
| 82 |  | 
|---|
| 83 |   // Transformations: | 
|---|
| 84 |   static Playable::Playmode stringToPlaymode(const std::string& playmode); | 
|---|
| 85 |   static const std::string& playmodeToString(Playable::Playmode playmode); | 
|---|
| 86 |   static const std::string playmodeNames[]; | 
|---|
| 87 |  | 
|---|
| 88 | protected: | 
|---|
| 89 |   Playable(); | 
|---|
| 90 |  | 
|---|
| 91 |   // Player Setup | 
|---|
| 92 |   virtual void enter() = 0; | 
|---|
| 93 |   virtual void leave() = 0; | 
|---|
| 94 |   // Playmode | 
|---|
| 95 |   void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; }; | 
|---|
| 96 |   virtual void enterPlaymode(Playable::Playmode playmode); | 
|---|
| 97 |  | 
|---|
| 98 |   // Events. | 
|---|
| 99 |   void registerEvent(int eventType); | 
|---|
| 100 |   void unregisterEvent(int eventType); | 
|---|
| 101 |  | 
|---|
| 102 | private: | 
|---|
| 103 |   WeaponManager         weaponMan;          //!< the weapon manager: managing a list of weapon to wepaon-slot mapping | 
|---|
| 104 |   std::vector<int>      events;             //!< A list of Events, that are captured for this playable | 
|---|
| 105 |  | 
|---|
| 106 |   Player*               currentPlayer;      //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL | 
|---|
| 107 |  | 
|---|
| 108 |   bool                  bFire;              //!< If the Ship is firing. | 
|---|
| 109 |   int                   oldFlags;           //!< Used for synchronisation | 
|---|
| 110 |  | 
|---|
| 111 |   int                   score;              //!< players score | 
|---|
| 112 |  | 
|---|
| 113 |   bool                  bDead; | 
|---|
| 114 |   short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable. | 
|---|
| 115 |   Playable::Playmode    playmode;           //!< The current playmode. | 
|---|
| 116 |  | 
|---|
| 117 |   WorldEntity* collider; | 
|---|
| 118 | }; | 
|---|
| 119 |  | 
|---|
| 120 | #endif /* _PLAYABLE_H */ | 
|---|