Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

traveldistance calculated dynamically now, but calculations aren't correct yet.

File size: 8.7 KB
RevLine 
[7346]1/*!
2 * @file space_ship.h
3 * Implements the Control of a Spaceship
[9958]4 * Space Ships are the core class for all types of ships in Orxonox
[10073]5 * By default is on OM_GROUP_00
6 * If player boards the ship, it is moved to OM_GROUP_01
[7346]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;
[10081]21class Trail;
[10156]22class Wobblegrid;
[7346]23
24class SpaceShip : public Playable
25{
[9869]26  ObjectListDeclaration(SpaceShip);
[7346]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);
[10019]36    /*
[9971]37    void setTravelHeight(float travelHeight);
38    void setTravelDistance(const Vector2D& distance);
39    void setTravelDistance(float x, float y);
[10019]40    */
[7346]41
[10017]42    //void setAirFriction(float friction) { this->airFriction = friction; };
[9971]43
[7346]44    virtual void enter();
45    virtual void leave();
46
47    virtual void reset();
48
49    virtual void postSpawn();
50    virtual void leftWorld();
[9869]51
[9235]52    virtual void destroy(WorldEntity* killer);
[9008]53    virtual void respawn();
[7346]54
[10095]55    inline Vector getVelocity() { return this->velocity; };
56
[7346]57    virtual void tick(float time);
58    virtual void draw() const;
59
60    virtual void process(const Event &event);
[10274]61//    virtual void hit (WorldEntity* entity, float damage);
[7346]62
[10030]63    inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; };
[9965]64
[9950]65    //Functions for GUI
[9957]66    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
67    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
[9950]68
[9957]69    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
70    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
[9950]71
[9957]72    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
73    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
[9950]74
[10270]75    inline PNode* getTravelNode() { return this->travelNode; };
76
[9950]77    //damage handler
[9957]78    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
[9950]79
[10291]80    //included by Michel:
[9971]81    virtual void enterPlaymode(Playable::Playmode playmode);
[10120]82    void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation)
[10291]83    inline void setActionWidthPercentage(float f) {this->actionWidthPercentage = f; updateTravelDistance();};
84    void updateTravelDistance();
[9971]85    virtual void movement (float dt);
86
[10291]87    //
[10120]88
[10113]89    void nextWeaponConfig();
90    void previousWeaponConfig();
91
[10117]92    virtual void hit(float damage, WorldEntity* killer);
[10113]93
[7346]94  private:
95    void init();
96
[10032]97    //void calculateVelocity(float time);
[7346]98
[9957]99    void regen(float time);  //!< handler for shield and electronic regeneration
[9943]100
[9965]101    void weaponRegen(float time);   //!< weapon energy regeneration
102
[10022]103    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
[10020]104
[10120]105    void updateElectronicWidget();
106    void updateShieldWidget();
107
[9965]108    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
[9961]109    WeaponManager         secWeaponMan;       //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping
110    short                 supportedPlaymodes; //!< What Playmodes are Supported in this Playable.
111    Playable::Playmode    playmode;           //!< The current playmode.
112
[9950]113    //ship atributes
[9957]114    float       shieldCur;          //!< current shield
115    float       shieldMax;          //!< maximum shield
[9950]116    float       shieldEnergyShare;  //!< percentage of reactor output
[9970]117    float       shieldRegen;        //!< shield regeneration rate per second
[9957]118    float       shieldTH;           //!< shield threshhold for reactivation
[9950]119    bool        shieldActive;       //!< wheather the shield is working
[10120]120    OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar
[9943]121
[9957]122    float       armorCur;           //!< current armor
123    float       armorMax;           //!< maximum armor
[9963]124    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
[10120]125    //note that the armor widget is set on the health- widget in world- entity (see in player.cc)
[9943]126
[9957]127    float       electronicCur;      //!< current electronic
128    float       electronicMax;      //!< maximum electronic
129    float       electronicRegen;    //!< electronic regenration rate per tick
[10020]130    float       electronicTH;       //!< Threshhold for electronic failure
[10120]131    OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar
[9943]132
[9970]133    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
134    float       engineSpeedBase;    //!< speed base
[9950]135    int         enginePowerConsume; //!< energy needed
136    float       engineEnergyShare;  //!< percentage of reactor output
[9943]137
[9950]138    int         weaponEnergySlot;   //!< number of energy weapon slots
139    int         weaponEnergyUsed;
140    float       weaponEnergyShare;
[9965]141    float       weaponEnergyRegen;
[9950]142    int         weaponSpecialSlot;  //!< number of special weapon slots
143    int         weaponSpecialUsed;
[9943]144
[9965]145    float       reactorOutput;      //!< reactor output
146    float       reactorCapacity;    //!< reactor capacity
[9943]147
[9961]148    int         curWeaponPrimary;   //!< current primary weapon config
149    int         curWeaponSecondary; //!< current secondary weapon config
[9958]150
[10017]151    bool                  bForward;                //!< up button pressed.
152    bool                  bBackward;              //!< down button pressed.
[7346]153    bool                  bLeft;              //!< left button pressed.
154    bool                  bRight;             //!< right button pressed.
155    bool                  bAscend;            //!< ascend button pressed.
156    bool                  bDescend;           //!< descend button presses.
157    bool                  bRollL;             //!< rolling button pressed (left)
158    bool                  bRollR;             //!< rolling button pressed (right)
[10023]159    bool                  bSecFire;           //!< second fire button pressed
[7346]160
[10017]161    /*
[7346]162    float                 xMouse;             //!< mouse moved in x-Direction
163    float                 yMouse;             //!< mouse moved in y-Direction
164    float                 mouseSensitivity;   //!< the mouse sensitivity
165    int                   yInvert;
166    int                   controlVelocityX;
167    int                   controlVelocityY;
[10017]168    */
[7346]169
[10043]170    Vector                velocity;           //!< the velocity of the player.
[10078]171    Vector                oldPos;
[10017]172
[9971]173// 2D-traveling
174    PNode*                travelNode;
175    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
[10098]176    Vector                travelVelocity;     //!< object internal velocity vector for relative movement to the track node
[10019]177    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
178    Vector2D              travelDistanceMinus;
[10291]179    bool                  isTravelDistanceInit;
[9971]180
[10291]181    float                 actionWidthPercentage;
182
[9971]183// Camera
184    PNode                 cameraNode;
185    float                 cameraLook;
186    float                 rotation;
[10017]187    float                 cameraSpeed;
[9971]188
[10270]189    void                  setCameraDistance(float dist);
190    void                  setCameraFovy(float fovy);
191
[10017]192    /*
[7346]193    Quaternion            mouseDir;           //!< the direction where the player wants to fly
194    Quaternion            oldMouseDir;        //!< the direction where the player wanted to fly
195    float                 shipInertia;        //!< the inertia of the ship(how fast the ship reacts to a mouse input)
196    Quaternion            rotQuat;
197    Quaternion            pitchDir;
[9971]198    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
[10017]199    */
[7346]200
[10032]201    //Quaternion            direction;          //!< the direction of the ship.
[9971]202    float                 acceleration;       //!< the acceleration of the ship.
[10017]203    //float                 airFriction;        //!< AirFriction.
204    //float                 airViscosity;
[7346]205
206    byte                  oldMask;            //!< used for synchronisation
207
[10081]208    Trail*                trail;              //!< Burst trail
209    Trail*                trailL;              //!< Burst trail
210    Trail*                trailR;              //!< Burst trail
211
[10156]212
[7346]213};
214
215#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.