Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10270 was 10270, checked in by muellmic, 17 years ago

1) the centerpoint of the radar is now the centerpoint of the camera, so the enemies won't move in the radar when the player is moving; 2)fovy and cameradistance of each viewmode can now be set dynamically. so one would't have to readjust the fovy for each viewmode, when it has been manually changed once. (it's better to just change the fovy or distance for the viewmode where you need it); 3)unlike in the last revision, it doesnt have a soft- zoom- effect when setting a fovy anymore.

File size: 8.4 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;
22class Wobblegrid;
23
24class SpaceShip : public Playable
25{
26  ObjectListDeclaration(SpaceShip);
27
28  public:
29    SpaceShip(const std::string& fileName);
30    SpaceShip(const TiXmlElement* root = NULL);
31    virtual ~SpaceShip();
32
33    virtual void loadParams(const TiXmlElement* root);
34
35    virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f);
36    /*
37    void setTravelHeight(float travelHeight);
38    void setTravelDistance(const Vector2D& distance);
39    void setTravelDistance(float x, float y);
40    */
41
42    //void setAirFriction(float friction) { this->airFriction = friction; };
43
44    virtual void enter();
45    virtual void leave();
46
47    virtual void reset();
48
49    virtual void postSpawn();
50    virtual void leftWorld();
51
52    virtual void destroy(WorldEntity* killer);
53    virtual void respawn();
54
55    inline Vector getVelocity() { return this->velocity; };
56
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    inline PNode* getTravelNode() { return this->travelNode; };
75
76    //damage handler
77    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
78
79    //included by Michel: ((
80    virtual void enterPlaymode(Playable::Playmode playmode);
81    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
82    virtual void movement (float dt);
83
84    //))
85
86    void nextWeaponConfig();
87    void previousWeaponConfig();
88
89    virtual void hit(float damage, WorldEntity* killer);
90
91  private:
92    void init();
93
94    //void calculateVelocity(float time);
95
96    void regen(float time);  //!< handler for shield and electronic regeneration
97
98    void weaponRegen(float time);   //!< weapon energy regeneration
99
100    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
101
102    void updateElectronicWidget();
103    void updateShieldWidget();
104
105    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
106    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
107    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
108    Playable::Playmode    playmode;           //!< The current playmode.
109
110    //ship atributes
111    float       shieldCur;          //!< current shield
112    float       shieldMax;          //!< maximum shield
113    float       shieldEnergyShare;  //!< percentage of reactor output
114    float       shieldRegen;        //!< shield regeneration rate per second
115    float       shieldTH;           //!< shield threshhold for reactivation
116    bool        shieldActive;       //!< wheather the shield is working
117    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
118
119    float       armorCur;           //!< current armor
120    float       armorMax;           //!< maximum armor
121    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
122    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
123
124    float       electronicCur;      //!< current electronic
125    float       electronicMax;      //!< maximum electronic
126    float       electronicRegen;    //!< electronic regenration rate per tick
127    float       electronicTH;       //!< Threshhold for electronic failure
128    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
129
130    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
131    float       engineSpeedBase;    //!< speed base
132    int         enginePowerConsume; //!< energy needed
133    float       engineEnergyShare;  //!< percentage of reactor output
134
135    int         weaponEnergySlot;   //!< number of energy weapon slots
136    int         weaponEnergyUsed;
137    float       weaponEnergyShare;
138    float       weaponEnergyRegen;
139    int         weaponSpecialSlot;  //!< number of special weapon slots
140    int         weaponSpecialUsed;
141
142    float       reactorOutput;      //!< reactor output
143    float       reactorCapacity;    //!< reactor capacity
144
145    int         curWeaponPrimary;   //!< current primary weapon config
146    int         curWeaponSecondary; //!< current secondary weapon config
147
148    bool                  bForward;                //!< up button pressed.
149    bool                  bBackward;              //!< down button pressed.
150    bool                  bLeft;              //!< left button pressed.
151    bool                  bRight;             //!< right button pressed.
152    bool                  bAscend;            //!< ascend button pressed.
153    bool                  bDescend;           //!< descend button presses.
154    bool                  bRollL;             //!< rolling button pressed (left)
155    bool                  bRollR;             //!< rolling button pressed (right)
156    bool                  bSecFire;           //!< second fire button pressed
157
158    /*
159    float                 xMouse;             //!< mouse moved in x-Direction
160    float                 yMouse;             //!< mouse moved in y-Direction
161    float                 mouseSensitivity;   //!< the mouse sensitivity
162    int                   yInvert;
163    int                   controlVelocityX;
164    int                   controlVelocityY;
165    */
166
167    Vector                velocity;           //!< the velocity of the player.
168    Vector                oldPos;
169
170// 2D-traveling
171    PNode*                travelNode;
172    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
173    Vector                travelVelocity;     //!< object internal velocity vector for relative movement to the track node
174    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
175    Vector2D              travelDistanceMinus;
176
177// Camera
178    PNode                 cameraNode;
179    float                 cameraLook;
180    float                 rotation;
181    float                 cameraSpeed;
182
183    void                  setCameraDistance(float dist);
184    void                  setCameraFovy(float fovy);
185
186    /*
187    Quaternion            mouseDir;           //!< the direction where the player wants to fly
188    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
189    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
190    Quaternion            rotQuat;
191    Quaternion            pitchDir;
192    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
193    */
194
195    //Quaternion            direction;          //!< the direction of the ship.
196    float                 acceleration;       //!< the acceleration of the ship.
197    //float                 airFriction;        //!< AirFriction.
198    //float                 airViscosity;
199
200    byte                  oldMask;            //!< used for synchronisation
201
202    Trail*                trail;              //!< Burst trail
203    Trail*                trailL;              //!< Burst trail
204    Trail*                trailR;              //!< Burst trail
205
206//    Wobblegrid*           test;
207
208};
209
210#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.