Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/space_ships/space_ship.h @ 10508

Last change on this file since 10508 was 10508, checked in by muellmic, 17 years ago

raised the ship's relative-to-track-speed a bit. the way to do this, is to raise the value 'engineSpeedBase' in the SpaceShip initialisation.. and recompile :(

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