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