Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Addition of billboard calc to wobblegrid. Temp addition to show it of in spaceship

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