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