Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/vs-enhencements/src/world_entities/space_ships/space_ship.h @ 10670

Last change on this file since 10670 was 10670, checked in by nicolasc, 17 years ago

moved "ship attributes" to world entity
electronic and shield widget not yet working

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