Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

velocity fix

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