[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" |
---|
[7338] | 12 | #include <vector> |
---|
[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; |
---|
[7118] | 20 | class Explosion; |
---|
[5838] | 21 | |
---|
| 22 | //! Basic controllable WorldEntity |
---|
| 23 | /** |
---|
[5864] | 24 | * |
---|
[5838] | 25 | */ |
---|
[6547] | 26 | class Playable : public WorldEntity, public Extendable |
---|
[5838] | 27 | { |
---|
[7338] | 28 | public: |
---|
[7346] | 29 | //! Defines the Playmode of an Entity. |
---|
[7338] | 30 | typedef enum { |
---|
[8055] | 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 | FirstPerson = 16, |
---|
[7412] | 36 | |
---|
[8055] | 37 | PlaymodeCount = 5, |
---|
[7338] | 38 | } Playmode; |
---|
[5838] | 39 | |
---|
| 40 | |
---|
[7338] | 41 | public: |
---|
| 42 | virtual ~Playable(); |
---|
[6966] | 43 | |
---|
[7338] | 44 | virtual void loadParams(const TiXmlElement* root); |
---|
[6547] | 45 | |
---|
[7346] | 46 | // Weapon and Pickups |
---|
[7338] | 47 | virtual bool pickup(PowerUp* powerUp); |
---|
[7350] | 48 | bool addWeapon(Weapon* weapon, int configID = -1, int slotID = -1); |
---|
[7338] | 49 | void removeWeapon(Weapon* weapon); |
---|
| 50 | void nextWeaponConfig(); |
---|
| 51 | void previousWeaponConfig(); |
---|
| 52 | inline WeaponManager& getWeaponManager() { return this->weaponMan; }; |
---|
| 53 | void weaponConfigChanged(); |
---|
[7351] | 54 | static void addSomeWeapons_CHEAT(); |
---|
[5895] | 55 | |
---|
[6241] | 56 | |
---|
[7346] | 57 | // Player Settup |
---|
[9061] | 58 | bool hasPlayer(){return !(this->currentPlayer == NULL);} |
---|
[7338] | 59 | bool setPlayer(Player* player); |
---|
| 60 | Player* getCurrentPlayer() const { return this->currentPlayer; }; |
---|
[7346] | 61 | /** @return a List of Events in PEV_* sytle */ |
---|
| 62 | inline const std::vector<int>& getEventList() { return this->events; }; |
---|
[5898] | 63 | |
---|
[7346] | 64 | // Camera and Playmode |
---|
[7338] | 65 | void attachCamera(); |
---|
| 66 | void detachCamera(); |
---|
[7347] | 67 | void setCameraMode(unsigned int cameraMode = 0); |
---|
[7338] | 68 | bool playmodeSupported(Playable::Playmode playmode) const { return this->supportedPlaymodes & playmode; }; |
---|
[7339] | 69 | bool setPlaymode(Playable::Playmode playmode); |
---|
| 70 | Playable::Playmode getPlaymode() const { return this->playmode; }; |
---|
[7346] | 71 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f) = 0; |
---|
| 72 | void setPlayDirection(float angle, float dirX, float dirY, float dirZ, float speed = 0.0f); |
---|
[5898] | 73 | |
---|
[7346] | 74 | inline void setScore( int score ) { this->score = score; } |
---|
| 75 | inline int getScore() { return this->score; } |
---|
| 76 | |
---|
[9061] | 77 | void setEnterRadius(float radius) { this->enterRadius = radius; }; |
---|
| 78 | /** @returns the EnterRadius (how far away a Player must be to enter this entity) */ |
---|
| 79 | inline float getEnterRadius() const { return this->enterRadius; }; |
---|
[7346] | 80 | |
---|
| 81 | // WorldEntity Extensions |
---|
[9235] | 82 | virtual void destroy(WorldEntity* killer); |
---|
[7346] | 83 | virtual void respawn(); |
---|
[7338] | 84 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
| 85 | virtual void process(const Event &event); |
---|
| 86 | virtual void tick(float dt); |
---|
[6966] | 87 | |
---|
[7339] | 88 | // Transformations: |
---|
| 89 | static Playable::Playmode stringToPlaymode(const std::string& playmode); |
---|
[7412] | 90 | static const std::string& playmodeToString(Playable::Playmode playmode); |
---|
| 91 | static const std::string playmodeNames[]; |
---|
[9235] | 92 | |
---|
| 93 | inline bool beFire(){ return this->bFire; } |
---|
| 94 | inline void fire(bool bF){ this->bFire = bF;} |
---|
[7412] | 95 | |
---|
[7338] | 96 | protected: |
---|
| 97 | Playable(); |
---|
[5872] | 98 | |
---|
[7346] | 99 | // Player Setup |
---|
[7338] | 100 | virtual void enter() = 0; |
---|
| 101 | virtual void leave() = 0; |
---|
[7346] | 102 | // Playmode |
---|
[7338] | 103 | void setSupportedPlaymodes(short playmodes) { this->supportedPlaymodes = playmodes; }; |
---|
[7346] | 104 | virtual void enterPlaymode(Playable::Playmode playmode); |
---|
[5888] | 105 | |
---|
[7346] | 106 | // Events. |
---|
[7338] | 107 | void registerEvent(int eventType); |
---|
| 108 | void unregisterEvent(int eventType); |
---|
[6966] | 109 | |
---|
[7338] | 110 | private: |
---|
| 111 | WeaponManager weaponMan; //!< the weapon manager: managing a list of weapon to wepaon-slot mapping |
---|
| 112 | std::vector<int> events; //!< A list of Events, that are captured for this playable |
---|
[6804] | 113 | |
---|
[7338] | 114 | Player* currentPlayer; //!< The Player currently connected to this Playable (the one that has controll) otherwise NULL |
---|
[7118] | 115 | |
---|
[7338] | 116 | bool bFire; //!< If the Ship is firing. |
---|
| 117 | int oldFlags; //!< Used for synchronisation |
---|
[7072] | 118 | |
---|
[7954] | 119 | int score; //!< players score |
---|
[7118] | 120 | |
---|
[7338] | 121 | bool bDead; |
---|
| 122 | short supportedPlaymodes; //!< What Playmodes are Supported in this Playable. |
---|
| 123 | Playable::Playmode playmode; //!< The current playmode. |
---|
| 124 | |
---|
[9061] | 125 | float enterRadius; //!< How far one can be away from the Playable to enter it. |
---|
| 126 | |
---|
[7338] | 127 | WorldEntity* collider; |
---|
[5838] | 128 | }; |
---|
| 129 | |
---|
| 130 | #endif /* _PLAYABLE_H */ |
---|