Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/vs-enhencements/src/world_entities/space_ships/space_ship.h @ 10659

Last change on this file since 10659 was 10659, checked in by nicolasc, 17 years ago

initial modularisation in spaceship config

File size: 9.9 KB
Line 
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 * By default is on OM_GROUP_00
6 * If player boards the ship, it is moved to OM_GROUP_01
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
16template<class T> class tList;
17class Vector;
18class Event;
19class ParticleEmitter;
20class ParticleSystem;
21class Trail;
22class Wobblegrid;
23
24class SpaceShip : public Playable
25{
26  ObjectListDeclaration(SpaceShip);
27
28  public:
29    SpaceShip(const std::string& fileName);
30    SpaceShip(const TiXmlElement* root = NULL);
31    virtual ~SpaceShip();
32
33    virtual void loadParams(const TiXmlElement* root);
34
35    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
36    /*
37    void setTravelHeight(float travelHeight);
38    void setTravelDistance(const Vector2D& distance);
39    void setTravelDistance(float x, float y);
40    */
41
42    //void setAirFriction(float friction) { this->airFriction = friction; };
43
44    virtual void enter();
45    virtual void leave();
46
47    virtual void reset();
48
49    virtual void postSpawn();
50    virtual void leftWorld();
51
52    virtual void destroy(WorldEntity* killer);
53    virtual void respawn();
54
55    inline Vector getVelocity() { return this->velocity; };
56
57    virtual void tick(float time);
58    virtual void draw() const;
59
60    virtual void process(const Event &event);
61//    virtual void hit (WorldEntity* entity, float damage);
62
63    inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; };
64
65    inline void setReactor(float output) {this->reactorOutput = output; };
66    inline void setShield(float cur, float max, float th, float regen)
67        { this->shieldCur = cur; this->shieldMax = max; this->shieldTH = th; this->shieldRegen = regen;};
68    inline void setArmor(float cur, float max) { this->armorCur = cur; this->armorMax = max; updateHealth(); };
69    inline void setElectronic(float cur, float max, float th, float regen)
70        { this->electronicCur = cur; this->electronicMax = max; this->electronicTH = th; this->electronicRegen = regen; };
71    inline void setEngine( float speedBase) {this->engineSpeedBase = speedBase; };
72    inline void setEnergyShare(float shield, float weapon, float engine)
73        { float tmp = shield + weapon + engine; if (unlikely (tmp > 1)) { tmp = 1/tmp; }
74          // dirty safty hack, prevents total share being bigger than 1!!
75          this->shieldEnergyShare = shield * tmp;
76          this->weaponEnergyShare = weapon * tmp;
77          this->engineEnergyShare = engine * tmp; };
78    inline void setWeapon(float regen) { this->weaponEnergyRegen = regen; };
79
80    //!< Resynchonizes armor with health in WE!!
81    inline void updateHealth() { this->setHealth(this->armorCur); this->setHealthMax(this->armorMax); };
82
83    //Functions for GUI
84    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
85    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
86
87    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
88    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
89
90    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
91    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
92
93    inline PNode* getTravelNode() { return this->travelNode; };
94
95    //damage handler
96    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
97
98    //included by Michel:
99    virtual void enterPlaymode(Playable::Playmode playmode);
100    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
101    void setActionWidthPercentage(int i);
102    void setTravelSpeed(float f);
103    void updateTravelDistance();
104    virtual void movement (float dt);
105
106
107
108    void nextWeaponConfig();
109    void previousWeaponConfig();
110
111    virtual void hit(float damage, WorldEntity* killer);
112
113    void                  setCameraDistance(float dist);
114
115  private:
116    void init();
117
118    //void calculateVelocity(float time);
119
120    void regen(float time);  //!< handler for shield and electronic regeneration
121
122    void weaponRegen(float time);   //!< weapon energy regeneration
123
124    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
125
126    void updateElectronicWidget();
127    void updateShieldWidget();
128
129    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
130    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
131    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
132    Playable::Playmode    playmode;           //!< The current playmode.
133
134    //ship atributes
135    float       shieldCur;          //!< current shield
136    float       shieldMax;          //!< maximum shield
137    float       shieldEnergyShare;  //!< percentage of reactor output
138    float       shieldRegen;        //!< shield regeneration rate per second
139    float       shieldTH;           //!< shield threshhold for reactivation
140    bool        shieldActive;       //!< wheather the shield is working
141    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
142
143    float       armorCur;           //!< current armor
144    float       armorMax;           //!< maximum armor
145    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
146    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
147
148    float       electronicCur;      //!< current electronic
149    float       electronicMax;      //!< maximum electronic
150    float       electronicRegen;    //!< electronic regenration rate per tick
151    float       electronicTH;       //!< Threshhold for electronic failure
152    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
153
154    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
155    float       engineSpeedBase;    //!< speed base
156    int         enginePowerConsume; //!< energy needed
157    float       engineEnergyShare;  //!< percentage of reactor output
158
159    int         weaponEnergySlot;   //!< number of energy weapon slots
160    int         weaponEnergyUsed;
161    float       weaponEnergyShare;
162    float       weaponEnergyRegen;
163    int         weaponSpecialSlot;  //!< number of special weapon slots
164    int         weaponSpecialUsed;
165
166    float       reactorOutput;      //!< reactor output
167//    float       reactorCapacity;    //!< reactor capacity
168
169    int         curWeaponPrimary;   //!< current primary weapon config
170    int         curWeaponSecondary; //!< current secondary weapon config
171
172    bool                  bForward;                //!< up button pressed.
173    bool                  bBackward;              //!< down button pressed.
174    bool                  bLeft;              //!< left button pressed.
175    bool                  bRight;             //!< right button pressed.
176    bool                  bAscend;            //!< ascend button pressed.
177    bool                  bDescend;           //!< descend button presses.
178    bool                  bRollL;             //!< rolling button pressed (left)
179    bool                  bRollR;             //!< rolling button pressed (right)
180    bool                  bSecFire;           //!< second fire button pressed
181
182    /*
183    float                 xMouse;             //!< mouse moved in x-Direction
184    float                 yMouse;             //!< mouse moved in y-Direction
185    float                 mouseSensitivity;   //!< the mouse sensitivity
186    int                   yInvert;
187    int                   controlVelocityX;
188    int                   controlVelocityY;
189    */
190
191    Vector                velocity;           //!< the velocity of the player.
192    Vector                oldPos;
193
194// 2D-traveling
195    PNode*                travelNode;
196    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
197    Vector                travelVelocity;     //!< object internal velocity vector for relative movement to the track node
198    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
199    Vector2D              travelDistanceMinus;
200    bool                  isTravelDistanceInit;
201
202    float                 actionWidthPercentage;
203
204// Camera
205    PNode                 cameraNode;
206    float                 cameraLook;
207    float                 rotation;
208    float                 cameraSpeed;
209
210
211    void                  setCameraFovy(float fovy);
212
213    /*
214    Quaternion            mouseDir;           //!< the direction where the player wants to fly
215    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
216    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
217    Quaternion            rotQuat;
218    Quaternion            pitchDir;
219    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
220    */
221
222    //Quaternion            direction;          //!< the direction of the ship.
223    float                 acceleration;       //!< the acceleration of the ship.
224    //float                 airFriction;        //!< AirFriction.
225    //float                 airViscosity;
226
227    byte                  oldMask;            //!< used for synchronisation
228/*
229    Trail*                trail;              //!< Burst trail
230    Trail*                trailL;              //!< Burst trail
231    Trail*                trailR;              //!< Burst trail
232*/
233
234};
235
236#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.