Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/space_ships/space_ship.h @ 10666

Last change on this file since 10666 was 10531, checked in by bknecht, 18 years ago

explosions and such

File size: 8.6 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    //Functions for GUI
66    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
67    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
68
69    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
70    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
71
72    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
73    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
74
75    inline PNode* getTravelNode() { return this->travelNode; };
76
77    //damage handler
78    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
79
80    //included by Michel:
81    virtual void enterPlaymode(Playable::Playmode playmode);
82    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
83    void setActionWidthPercentage(int i);
84    void setTravelSpeed(float f);
85    void updateTravelDistance();
86    virtual void movement (float dt);
87
88    //
89
90    void nextWeaponConfig();
91    void previousWeaponConfig();
92
93    virtual void hit(float damage, WorldEntity* killer);
94   
95    void                  setCameraDistance(float dist);
96
97  private:
98    void init();
99
100    //void calculateVelocity(float time);
101
102    void regen(float time);  //!< handler for shield and electronic regeneration
103
104    void weaponRegen(float time);   //!< weapon energy regeneration
105
106    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
107
108    void updateElectronicWidget();
109    void updateShieldWidget();
110
111    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
112    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
113    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
114    Playable::Playmode    playmode;           //!< The current playmode.
115
116    //ship atributes
117    float       shieldCur;          //!< current shield
118    float       shieldMax;          //!< maximum shield
119    float       shieldEnergyShare;  //!< percentage of reactor output
120    float       shieldRegen;        //!< shield regeneration rate per second
121    float       shieldTH;           //!< shield threshhold for reactivation
122    bool        shieldActive;       //!< wheather the shield is working
123    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
124
125    float       armorCur;           //!< current armor
126    float       armorMax;           //!< maximum armor
127    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
128    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
129
130    float       electronicCur;      //!< current electronic
131    float       electronicMax;      //!< maximum electronic
132    float       electronicRegen;    //!< electronic regenration rate per tick
133    float       electronicTH;       //!< Threshhold for electronic failure
134    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
135
136    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
137    float       engineSpeedBase;    //!< speed base
138    int         enginePowerConsume; //!< energy needed
139    float       engineEnergyShare;  //!< percentage of reactor output
140
141    int         weaponEnergySlot;   //!< number of energy weapon slots
142    int         weaponEnergyUsed;
143    float       weaponEnergyShare;
144    float       weaponEnergyRegen;
145    int         weaponSpecialSlot;  //!< number of special weapon slots
146    int         weaponSpecialUsed;
147
148    float       reactorOutput;      //!< reactor output
149    float       reactorCapacity;    //!< reactor capacity
150
151    int         curWeaponPrimary;   //!< current primary weapon config
152    int         curWeaponSecondary; //!< current secondary weapon config
153
154    bool                  bForward;                //!< up button pressed.
155    bool                  bBackward;              //!< down button pressed.
156    bool                  bLeft;              //!< left button pressed.
157    bool                  bRight;             //!< right button pressed.
158    bool                  bAscend;            //!< ascend button pressed.
159    bool                  bDescend;           //!< descend button presses.
160    bool                  bRollL;             //!< rolling button pressed (left)
161    bool                  bRollR;             //!< rolling button pressed (right)
162    bool                  bSecFire;           //!< second fire button pressed
163
164    /*
165    float                 xMouse;             //!< mouse moved in x-Direction
166    float                 yMouse;             //!< mouse moved in y-Direction
167    float                 mouseSensitivity;   //!< the mouse sensitivity
168    int                   yInvert;
169    int                   controlVelocityX;
170    int                   controlVelocityY;
171    */
172
173    Vector                velocity;           //!< the velocity of the player.
174    Vector                oldPos;
175
176// 2D-traveling
177    PNode*                travelNode;
178    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
179    Vector                travelVelocity;     //!< object internal velocity vector for relative movement to the track node
180    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
181    Vector2D              travelDistanceMinus;
182    bool                  isTravelDistanceInit;
183
184    float                 actionWidthPercentage;
185
186// Camera
187    PNode                 cameraNode;
188    float                 cameraLook;
189    float                 rotation;
190    float                 cameraSpeed;
191
192
193    void                  setCameraFovy(float fovy);
194
195    /*
196    Quaternion            mouseDir;           //!< the direction where the player wants to fly
197    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
198    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
199    Quaternion            rotQuat;
200    Quaternion            pitchDir;
201    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
202    */
203
204    //Quaternion            direction;          //!< the direction of the ship.
205    float                 acceleration;       //!< the acceleration of the ship.
206    //float                 airFriction;        //!< AirFriction.
207    //float                 airViscosity;
208
209    byte                  oldMask;            //!< used for synchronisation
210
211    Trail*                trail;              //!< Burst trail
212    Trail*                trailL;              //!< Burst trail
213    Trail*                trailR;              //!< Burst trail
214
215
216};
217
218#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.