Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10362 was 10362, checked in by patrick, 17 years ago

merged playability. but got strange bug

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