[7346] | 1 | /*! |
---|
| 2 | * @file space_ship.h |
---|
| 3 | * Implements the Control of a Spaceship |
---|
[9958] | 4 | * Space Ships are the core class for all types of ships in Orxonox |
---|
[7346] | 5 | */ |
---|
| 6 | |
---|
| 7 | #ifndef _SPACE_SHIP_H |
---|
| 8 | #define _SPACE_SHIP_H |
---|
| 9 | |
---|
| 10 | #include "playable.h" |
---|
| 11 | #include "extendable.h" |
---|
| 12 | |
---|
| 13 | // Forward Declaration |
---|
| 14 | template<class T> class tList; |
---|
| 15 | class Vector; |
---|
| 16 | class Event; |
---|
| 17 | class ParticleEmitter; |
---|
| 18 | class ParticleSystem; |
---|
| 19 | |
---|
| 20 | class SpaceShip : public Playable |
---|
| 21 | { |
---|
[9869] | 22 | ObjectListDeclaration(SpaceShip); |
---|
[7346] | 23 | |
---|
| 24 | public: |
---|
| 25 | SpaceShip(const std::string& fileName); |
---|
| 26 | SpaceShip(const TiXmlElement* root = NULL); |
---|
| 27 | virtual ~SpaceShip(); |
---|
| 28 | |
---|
| 29 | virtual void loadParams(const TiXmlElement* root); |
---|
| 30 | |
---|
| 31 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); |
---|
[9971] | 32 | void setTravelSpeed(float travelSpeed); |
---|
[10019] | 33 | /* |
---|
[9971] | 34 | void setTravelHeight(float travelHeight); |
---|
| 35 | void setTravelDistance(const Vector2D& distance); |
---|
| 36 | void setTravelDistance(float x, float y); |
---|
[10019] | 37 | */ |
---|
[7346] | 38 | |
---|
[10017] | 39 | //void setAirFriction(float friction) { this->airFriction = friction; }; |
---|
[9971] | 40 | |
---|
[7346] | 41 | virtual void enter(); |
---|
| 42 | virtual void leave(); |
---|
| 43 | |
---|
| 44 | virtual void reset(); |
---|
| 45 | |
---|
| 46 | virtual void postSpawn(); |
---|
| 47 | virtual void leftWorld(); |
---|
[9869] | 48 | |
---|
[9235] | 49 | virtual void destroy(WorldEntity* killer); |
---|
[9008] | 50 | virtual void respawn(); |
---|
[7346] | 51 | |
---|
| 52 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
| 53 | virtual void tick(float time); |
---|
| 54 | virtual void draw() const; |
---|
| 55 | |
---|
| 56 | virtual void process(const Event &event); |
---|
| 57 | |
---|
[10030] | 58 | inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; }; |
---|
[9965] | 59 | |
---|
[9950] | 60 | //Functions for GUI |
---|
[9957] | 61 | inline float getShieldCur() { return this->shieldCur; }; //!< returns current shield value |
---|
| 62 | inline float getShieldMax() { return this->shieldMax; }; //!< returns maximum shield value |
---|
[9950] | 63 | |
---|
[9957] | 64 | inline float getArmorCur() { return this->armorCur; }; //!< returns current armor value |
---|
| 65 | inline float getArmorMax() { return this->armorMax; }; //!< returns current armor value |
---|
[9950] | 66 | |
---|
[9957] | 67 | inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value |
---|
| 68 | inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value |
---|
[9950] | 69 | |
---|
| 70 | //damage handler |
---|
[9957] | 71 | virtual void damage(float pDamage, float eDamage); //!< pDamage physical damage, eDamage electronic damage |
---|
[9950] | 72 | |
---|
[9971] | 73 | virtual void enterPlaymode(Playable::Playmode playmode); |
---|
[10032] | 74 | void setPlaymodeXML(const std::string& playmode); |
---|
[9971] | 75 | virtual void movement (float dt); |
---|
| 76 | |
---|
[7346] | 77 | private: |
---|
| 78 | void init(); |
---|
| 79 | |
---|
[10032] | 80 | //void calculateVelocity(float time); |
---|
[7346] | 81 | |
---|
[9957] | 82 | void regen(float time); //!< handler for shield and electronic regeneration |
---|
[9943] | 83 | |
---|
[9965] | 84 | void weaponRegen(float time); //!< weapon energy regeneration |
---|
| 85 | |
---|
[10022] | 86 | inline bool systemFailure() { return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); }; |
---|
[10020] | 87 | |
---|
[9965] | 88 | //WeaponManager weaponMan; //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping |
---|
[9961] | 89 | WeaponManager secWeaponMan; //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping |
---|
| 90 | short supportedPlaymodes; //!< What Playmodes are Supported in this Playable. |
---|
| 91 | Playable::Playmode playmode; //!< The current playmode. |
---|
| 92 | |
---|
[9950] | 93 | //ship atributes |
---|
[9957] | 94 | float shieldCur; //!< current shield |
---|
| 95 | float shieldMax; //!< maximum shield |
---|
[9950] | 96 | float shieldEnergyShare; //!< percentage of reactor output |
---|
[9970] | 97 | float shieldRegen; //!< shield regeneration rate per second |
---|
[9957] | 98 | float shieldTH; //!< shield threshhold for reactivation |
---|
[9950] | 99 | bool shieldActive; //!< wheather the shield is working |
---|
[9943] | 100 | |
---|
[9957] | 101 | float armorCur; //!< current armor |
---|
| 102 | float armorMax; //!< maximum armor |
---|
[9963] | 103 | float armorRegen; //!< armor regeneration per tick (usable on bioships?) |
---|
[9943] | 104 | |
---|
[9957] | 105 | float electronicCur; //!< current electronic |
---|
| 106 | float electronicMax; //!< maximum electronic |
---|
| 107 | float electronicRegen; //!< electronic regenration rate per tick |
---|
[10020] | 108 | float electronicTH; //!< Threshhold for electronic failure |
---|
[9943] | 109 | |
---|
[9970] | 110 | float engineSpeedCur; //!< speed output for movement = speed base + energy share part |
---|
| 111 | float engineSpeedBase; //!< speed base |
---|
[9950] | 112 | int enginePowerConsume; //!< energy needed |
---|
| 113 | float engineEnergyShare; //!< percentage of reactor output |
---|
[9943] | 114 | |
---|
[9950] | 115 | int weaponEnergySlot; //!< number of energy weapon slots |
---|
| 116 | int weaponEnergyUsed; |
---|
| 117 | float weaponEnergyShare; |
---|
[9965] | 118 | float weaponEnergyRegen; |
---|
[9950] | 119 | int weaponSpecialSlot; //!< number of special weapon slots |
---|
| 120 | int weaponSpecialUsed; |
---|
[9943] | 121 | |
---|
[9965] | 122 | float reactorOutput; //!< reactor output |
---|
| 123 | float reactorCapacity; //!< reactor capacity |
---|
[9943] | 124 | |
---|
[9961] | 125 | int curWeaponPrimary; //!< current primary weapon config |
---|
| 126 | int curWeaponSecondary; //!< current secondary weapon config |
---|
[9958] | 127 | |
---|
[10017] | 128 | bool bForward; //!< up button pressed. |
---|
| 129 | bool bBackward; //!< down button pressed. |
---|
[7346] | 130 | bool bLeft; //!< left button pressed. |
---|
| 131 | bool bRight; //!< right button pressed. |
---|
| 132 | bool bAscend; //!< ascend button pressed. |
---|
| 133 | bool bDescend; //!< descend button presses. |
---|
| 134 | bool bRollL; //!< rolling button pressed (left) |
---|
| 135 | bool bRollR; //!< rolling button pressed (right) |
---|
[10023] | 136 | bool bSecFire; //!< second fire button pressed |
---|
[7346] | 137 | |
---|
[10017] | 138 | /* |
---|
[7346] | 139 | float xMouse; //!< mouse moved in x-Direction |
---|
| 140 | float yMouse; //!< mouse moved in y-Direction |
---|
| 141 | float mouseSensitivity; //!< the mouse sensitivity |
---|
| 142 | int yInvert; |
---|
| 143 | int controlVelocityX; |
---|
| 144 | int controlVelocityY; |
---|
[10017] | 145 | */ |
---|
[7346] | 146 | |
---|
[10032] | 147 | Vector velocity; //!< the velocity of the player. |
---|
[10017] | 148 | |
---|
[9971] | 149 | // 2D-traveling |
---|
| 150 | PNode* travelNode; |
---|
| 151 | float travelSpeed; //!< the current speed of the Ship (to make soft movement) |
---|
[10019] | 152 | Vector2D travelDistancePlus; //!< Travel-Distance away from the TravelNode |
---|
| 153 | Vector2D travelDistanceMinus; |
---|
[9971] | 154 | |
---|
| 155 | // Camera |
---|
| 156 | PNode cameraNode; |
---|
| 157 | float cameraLook; |
---|
| 158 | float rotation; |
---|
[10017] | 159 | float cameraSpeed; |
---|
[9971] | 160 | |
---|
[10017] | 161 | /* |
---|
[7346] | 162 | Quaternion mouseDir; //!< the direction where the player wants to fly |
---|
| 163 | Quaternion oldMouseDir; //!< the direction where the player wanted to fly |
---|
| 164 | float shipInertia; //!< the inertia of the ship(how fast the ship reacts to a mouse input) |
---|
| 165 | Quaternion rotQuat; |
---|
| 166 | Quaternion pitchDir; |
---|
[9971] | 167 | float dogdeSpeed; //!< the dogde Speed of the ship. |
---|
[10017] | 168 | */ |
---|
[7346] | 169 | |
---|
[10032] | 170 | //Quaternion direction; //!< the direction of the ship. |
---|
[9971] | 171 | float acceleration; //!< the acceleration of the ship. |
---|
[10017] | 172 | //float airFriction; //!< AirFriction. |
---|
| 173 | //float airViscosity; |
---|
[7346] | 174 | |
---|
| 175 | byte oldMask; //!< used for synchronisation |
---|
| 176 | |
---|
| 177 | ParticleEmitter* burstEmitter; |
---|
| 178 | ParticleSystem* burstSystem; |
---|
| 179 | }; |
---|
| 180 | |
---|
| 181 | #endif /* _SPACE_SHIPS_H */ |
---|