Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/vs-enhencements/src/world_entities/space_ships/space_ship.h @ 10660

Last change on this file since 10660 was 10660, checked in by nicolasc, 17 years ago

night bunp

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