Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Last update, collision working again. SEGFAULT problems

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