Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/space_ships/space_ship.h @ 10749

Last change on this file since 10749 was 10749, checked in by rennerc, 17 years ago

die player die

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