Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10274 was 10274, checked in by marcscha, 17 years ago

fixes and workaround bugs of Orx

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