Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10120 was 10120, checked in by muellmic, 17 years ago

some interface hacks

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