Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

weapon, collision, particles

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    /*
33    void setTravelHeight(float travelHeight);
34    void setTravelDistance(const Vector2D& distance);
35    void setTravelDistance(float x, float y);
36    */
37
38    //void setAirFriction(float friction) { this->airFriction = friction; };
39
40    virtual void enter();
41    virtual void leave();
42
43    virtual void reset();
44
45    virtual void postSpawn();
46    virtual void leftWorld();
47
48    virtual void destroy(WorldEntity* killer);
49    virtual void respawn();
50
51    virtual void collidesWith(WorldEntity* entity, const Vector& location);
52    virtual void tick(float time);
53    virtual void draw() const;
54
55    virtual void process(const Event &event);
56
57    inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; };
58
59    //Functions for GUI
60    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
61    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
62
63    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
64    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
65
66    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
67    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
68
69    //damage handler
70    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
71
72    virtual void enterPlaymode(Playable::Playmode playmode);
73    void setPlaymodeXML(const std::string& 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() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
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
92    //ship atributes
93    float       shieldCur;          //!< current shield
94    float       shieldMax;          //!< maximum shield
95    float       shieldEnergyShare;  //!< percentage of reactor output
96    float       shieldRegen;        //!< shield regeneration rate per second
97    float       shieldTH;           //!< shield threshhold for reactivation
98    bool        shieldActive;       //!< wheather the shield is working
99
100    float       armorCur;           //!< current armor
101    float       armorMax;           //!< maximum armor
102    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
103
104    float       electronicCur;      //!< current electronic
105    float       electronicMax;      //!< maximum electronic
106    float       electronicRegen;    //!< electronic regenration rate per tick
107    float       electronicTH;       //!< Threshhold for electronic failure
108
109    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
110    float       engineSpeedBase;    //!< speed base
111    int         enginePowerConsume; //!< energy needed
112    float       engineEnergyShare;  //!< percentage of reactor output
113
114    int         weaponEnergySlot;   //!< number of energy weapon slots
115    int         weaponEnergyUsed;
116    float       weaponEnergyShare;
117    float       weaponEnergyRegen;
118    int         weaponSpecialSlot;  //!< number of special weapon slots
119    int         weaponSpecialUsed;
120
121    float       reactorOutput;      //!< reactor output
122    float       reactorCapacity;    //!< reactor capacity
123
124    int         curWeaponPrimary;   //!< current primary weapon config
125    int         curWeaponSecondary; //!< current secondary weapon config
126
127    bool                  bForward;                //!< up button pressed.
128    bool                  bBackward;              //!< down button pressed.
129    bool                  bLeft;              //!< left button pressed.
130    bool                  bRight;             //!< right button pressed.
131    bool                  bAscend;            //!< ascend button pressed.
132    bool                  bDescend;           //!< descend button presses.
133    bool                  bRollL;             //!< rolling button pressed (left)
134    bool                  bRollR;             //!< rolling button pressed (right)
135    bool                  bSecFire;           //!< second fire button pressed
136
137    /*
138    float                 xMouse;             //!< mouse moved in x-Direction
139    float                 yMouse;             //!< mouse moved in y-Direction
140    float                 mouseSensitivity;   //!< the mouse sensitivity
141    int                   yInvert;
142    int                   controlVelocityX;
143    int                   controlVelocityY;
144    */
145
146    Vector                velocity;           //!< the velocity of the player.
147
148// 2D-traveling
149    PNode*                travelNode;
150    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
151    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
152    Vector2D              travelDistanceMinus;
153
154// Camera
155    PNode                 cameraNode;
156    float                 cameraLook;
157    float                 rotation;
158    float                 cameraSpeed;
159
160    /*
161    Quaternion            mouseDir;           //!< the direction where the player wants to fly
162    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
163    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
164    Quaternion            rotQuat;
165    Quaternion            pitchDir;
166    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
167    */
168
169    //Quaternion            direction;          //!< the direction of the ship.
170    float                 acceleration;       //!< the acceleration of the ship.
171    //float                 airFriction;        //!< AirFriction.
172    //float                 airViscosity;
173
174    byte                  oldMask;            //!< used for synchronisation
175
176    ParticleEmitter*      burstEmitter;
177    ParticleSystem*       burstSystem;
178
179   
180    SpriteParticles*           explosionParticles;
181    ParticleEmitter*           emitter;
182};
183
184#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.