Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Some surprises for comming wednesday

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