1 | /*! |
---|
2 | * @file space_ship.h |
---|
3 | * Implements the Control of a Spaceship |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef _SPACE_SHIP_H |
---|
7 | #define _SPACE_SHIP_H |
---|
8 | |
---|
9 | #include "playable.h" |
---|
10 | #include "extendable.h" |
---|
11 | |
---|
12 | // Forward Declaration |
---|
13 | template<class T> class tList; |
---|
14 | class Vector; |
---|
15 | class Event; |
---|
16 | class ParticleEmitter; |
---|
17 | class ParticleSystem; |
---|
18 | |
---|
19 | class SpaceShip : public Playable |
---|
20 | { |
---|
21 | ObjectListDeclaration(SpaceShip); |
---|
22 | |
---|
23 | public: |
---|
24 | SpaceShip(const std::string& fileName); |
---|
25 | SpaceShip(const TiXmlElement* root = NULL); |
---|
26 | virtual ~SpaceShip(); |
---|
27 | |
---|
28 | virtual void loadParams(const TiXmlElement* root); |
---|
29 | |
---|
30 | virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); |
---|
31 | |
---|
32 | virtual void enter(); |
---|
33 | virtual void leave(); |
---|
34 | |
---|
35 | virtual void reset(); |
---|
36 | |
---|
37 | virtual void postSpawn(); |
---|
38 | virtual void leftWorld(); |
---|
39 | |
---|
40 | virtual void destroy(WorldEntity* killer); |
---|
41 | virtual void respawn(); |
---|
42 | |
---|
43 | virtual void collidesWith(WorldEntity* entity, const Vector& location); |
---|
44 | virtual void tick(float time); |
---|
45 | virtual void draw() const; |
---|
46 | |
---|
47 | virtual void process(const Event &event); |
---|
48 | |
---|
49 | //Functions for GUI |
---|
50 | virtual int getShieldCur(); //!< returns current shield value |
---|
51 | virtual int getShieldMax(); //!< returns maximum shield value |
---|
52 | |
---|
53 | virtual int getArmorCur(); //!< returns current armor value |
---|
54 | virtual int getArmorMax(); //!< returns current armor value |
---|
55 | |
---|
56 | virtual int getElectronicCur(); //!< returns current electronic value |
---|
57 | virtual int getElectronicMax(); //!< returns current electronic value |
---|
58 | |
---|
59 | //damage handler |
---|
60 | virtual void damage(int pDamage, int eDamage); //!< pDamage physical damage, eDamage electronic damage |
---|
61 | |
---|
62 | private: |
---|
63 | void init(); |
---|
64 | |
---|
65 | void calculateVelocity(float time); |
---|
66 | |
---|
67 | void regen(); //!< handler for shield and electronic regeneration |
---|
68 | |
---|
69 | //ship atributes |
---|
70 | int shieldCur; //!< current shield |
---|
71 | int shieldMax; //!< maximum shield |
---|
72 | float shieldEnergyShare; //!< percentage of reactor output |
---|
73 | int shieldRegen; //!< shield regeneration rate |
---|
74 | int shieldTH; //!< shield threshhold for reactivation |
---|
75 | bool shieldActive; //!< wheather the shield is working |
---|
76 | |
---|
77 | int armorCur; //!< current armor |
---|
78 | int armorMax; //!< maximum armor |
---|
79 | |
---|
80 | int electronicCur; //!< current electronic |
---|
81 | int electronicMax; //!< maximum electronic |
---|
82 | int electronicRegen; //!< electronic regenration rate |
---|
83 | |
---|
84 | int engineSpeedCur; //!< speed output |
---|
85 | int enginePowerConsume; //!< energy needed |
---|
86 | float engineEnergyShare; //!< percentage of reactor output |
---|
87 | |
---|
88 | int weaponEnergySlot; //!< number of energy weapon slots |
---|
89 | int weaponEnergyUsed; |
---|
90 | float weaponEnergyShare; |
---|
91 | int weaponSpecialSlot; //!< number of special weapon slots |
---|
92 | int weaponSpecialUsed; |
---|
93 | |
---|
94 | int reactorOutput; //!< reactor output |
---|
95 | int reactorCapacity; //!< reactor capacity |
---|
96 | |
---|
97 | bool bUp; //!< up button pressed. |
---|
98 | bool bDown; //!< down button pressed. |
---|
99 | bool bLeft; //!< left button pressed. |
---|
100 | bool bRight; //!< right button pressed. |
---|
101 | bool bAscend; //!< ascend button pressed. |
---|
102 | bool bDescend; //!< descend button presses. |
---|
103 | // bool bFire; //!< fire button pressed.(moved to playable) |
---|
104 | bool bRollL; //!< rolling button pressed (left) |
---|
105 | bool bRollR; //!< rolling button pressed (right) |
---|
106 | |
---|
107 | float xMouse; //!< mouse moved in x-Direction |
---|
108 | float yMouse; //!< mouse moved in y-Direction |
---|
109 | float mouseSensitivity; //!< the mouse sensitivity |
---|
110 | int yInvert; |
---|
111 | int controlVelocityX; |
---|
112 | int controlVelocityY; |
---|
113 | // float cycle; //!< hovercycle |
---|
114 | |
---|
115 | Vector velocity; //!< the velocity of the player. |
---|
116 | Vector oldVelocity; //!< the velocity the player had last synced |
---|
117 | Quaternion mouseDir; //!< the direction where the player wants to fly |
---|
118 | Quaternion oldMouseDir; //!< the direction where the player wanted to fly |
---|
119 | float shipInertia; //!< the inertia of the ship(how fast the ship reacts to a mouse input) |
---|
120 | Quaternion rotQuat; |
---|
121 | Quaternion pitchDir; |
---|
122 | float travelSpeed; //!< the current speed of the player (to make soft movement) |
---|
123 | float acceleration; //!< the acceleration of the player. |
---|
124 | |
---|
125 | float airViscosity; |
---|
126 | |
---|
127 | byte oldMask; //!< used for synchronisation |
---|
128 | |
---|
129 | ParticleEmitter* burstEmitter; |
---|
130 | ParticleSystem* burstSystem; |
---|
131 | }; |
---|
132 | |
---|
133 | #endif /* _SPACE_SHIPS_H */ |
---|