Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10020 was 10020, checked in by nicolasc, 17 years ago
File size: 7.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 */
6
7#ifndef _SPACE_SHIP_H
8#define _SPACE_SHIP_H
9
10#include "playable.h"
11#include "extendable.h"
12
13// Forward Declaration
14template<class T> class tList;
15class Vector;
16class Event;
17class ParticleEmitter;
18class ParticleSystem;
19
20class SpaceShip : public Playable
21{
22  ObjectListDeclaration(SpaceShip);
23
24  public:
25    SpaceShip(const std::string& fileName);
26    SpaceShip(const TiXmlElement* root = NULL);
27    virtual ~SpaceShip();
28
29    virtual void loadParams(const TiXmlElement* root);
30
31    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
32    void setTravelSpeed(float travelSpeed);
33    /*
34    void setTravelHeight(float travelHeight);
35    void setTravelDistance(const Vector2D& distance);
36    void setTravelDistance(float x, float y);
37    */
38
39    //void setAirFriction(float friction) { this->airFriction = friction; };
40
41    virtual void enter();
42    virtual void leave();
43
44    virtual void reset();
45
46    virtual void postSpawn();
47    virtual void leftWorld();
48
49    virtual void destroy(WorldEntity* killer);
50    virtual void respawn();
51
52    virtual void collidesWith(WorldEntity* entity, const Vector& location);
53    virtual void tick(float time);
54    virtual void draw() const;
55
56    virtual void process(const Event &event);
57
58    inline WeaponManager getWeaponManagerSecondary() { return this->secWeaponMan; };
59
60    //Functions for GUI
61    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
62    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
63
64    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
65    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
66
67    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
68    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
69
70    //damage handler
71    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
72
73    virtual void enterPlaymode(Playable::Playmode playmode);
74    virtual void movement (float dt);
75
76  private:
77    void init();
78
79    void calculateVelocity(float time);
80
81    void regen(float time);  //!< handler for shield and electronic regeneration
82
83    void weaponRegen(float time);   //!< weapon energy regeneration
84
85    inline bool systemFailure();
86
87    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
88    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
89    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
90    Playable::Playmode    playmode;           //!< The current playmode.
91    bool                  bSecFire;
92
93    //ship atributes
94    float       shieldCur;          //!< current shield
95    float       shieldMax;          //!< maximum shield
96    float       shieldEnergyShare;  //!< percentage of reactor output
97    float       shieldRegen;        //!< shield regeneration rate per second
98    float       shieldTH;           //!< shield threshhold for reactivation
99    bool        shieldActive;       //!< wheather the shield is working
100
101    float       armorCur;           //!< current armor
102    float       armorMax;           //!< maximum armor
103    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
104
105    float       electronicCur;      //!< current electronic
106    float       electronicMax;      //!< maximum electronic
107    float       electronicRegen;    //!< electronic regenration rate per tick
108    float       electronicTH;       //!< Threshhold for electronic failure
109
110    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
111    float       engineSpeedBase;    //!< speed base
112    int         enginePowerConsume; //!< energy needed
113    float       engineEnergyShare;  //!< percentage of reactor output
114
115    int         weaponEnergySlot;   //!< number of energy weapon slots
116    int         weaponEnergyUsed;
117    float       weaponEnergyShare;
118    float       weaponEnergyRegen;
119    int         weaponSpecialSlot;  //!< number of special weapon slots
120    int         weaponSpecialUsed;
121
122    float       reactorOutput;      //!< reactor output
123    float       reactorCapacity;    //!< reactor capacity
124
125    int         curWeaponPrimary;   //!< current primary weapon config
126    int         curWeaponSecondary; //!< current secondary weapon config
127
128    bool                  bForward;                //!< up button pressed.
129    bool                  bBackward;              //!< down button pressed.
130    bool                  bLeft;              //!< left button pressed.
131    bool                  bRight;             //!< right button pressed.
132    bool                  bAscend;            //!< ascend button pressed.
133    bool                  bDescend;           //!< descend button presses.
134//    bool                  bFire;              //!< fire button pressed.(moved to playable)
135    bool                  bRollL;             //!< rolling button pressed (left)
136    bool                  bRollR;             //!< rolling button pressed (right)
137
138    /*
139    float                 xMouse;             //!< mouse moved in x-Direction
140    float                 yMouse;             //!< mouse moved in y-Direction
141    float                 mouseSensitivity;   //!< the mouse sensitivity
142    int                   yInvert;
143    int                   controlVelocityX;
144    int                   controlVelocityY;
145    */
146//   float                 cycle;              //!< hovercycle
147
148
149    Vector                velocity;           //!< the velocity of the player.
150    //Vector                oldVelocity;        //!< the velocity the player had last synced
151
152
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    ParticleEmitter*      burstEmitter;
183    ParticleSystem*       burstSystem;
184};
185
186#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.