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
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;
[7346]22
23class SpaceShip : public Playable
24{
[9869]25  ObjectListDeclaration(SpaceShip);
[7346]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);
[10019]35    /*
[9971]36    void setTravelHeight(float travelHeight);
37    void setTravelDistance(const Vector2D& distance);
38    void setTravelDistance(float x, float y);
[10019]39    */
[7346]40
[10017]41    //void setAirFriction(float friction) { this->airFriction = friction; };
[9971]42
[7346]43    virtual void enter();
44    virtual void leave();
45
46    virtual void reset();
47
48    virtual void postSpawn();
49    virtual void leftWorld();
[9869]50
[9235]51    virtual void destroy(WorldEntity* killer);
[9008]52    virtual void respawn();
[7346]53
[10095]54    inline Vector getVelocity() { return this->velocity; };
55
[7346]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
[10030]62    inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; };
[9965]63
[9950]64    //Functions for GUI
[9957]65    inline float getShieldCur() { return this->shieldCur; };        //!< returns current shield value
66    inline float getShieldMax() { return this->shieldMax; };        //!< returns maximum shield value
[9950]67
[9957]68    inline float getArmorCur() { return this->armorCur; };          //!< returns current armor value
69    inline float getArmorMax() { return this->armorMax; };          //!< returns current armor value
[9950]70
[9957]71    inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value
72    inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value
[9950]73
74    //damage handler
[9957]75    virtual void damage(float pDamage, float eDamage);  //!< pDamage physical damage, eDamage electronic damage
[9950]76
[9971]77    virtual void enterPlaymode(Playable::Playmode playmode);
[10032]78    void setPlaymodeXML(const std::string& playmode);
[9971]79    virtual void movement (float dt);
80
[10113]81    void nextWeaponConfig();
82    void previousWeaponConfig();
83
[10117]84    virtual void hit(float damage, WorldEntity* killer);
[10113]85
[7346]86  private:
87    void init();
88
[10032]89    //void calculateVelocity(float time);
[7346]90
[9957]91    void regen(float time);  //!< handler for shield and electronic regeneration
[9943]92
[9965]93    void weaponRegen(float time);   //!< weapon energy regeneration
94
[10022]95    inline bool systemFailure() {  return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); };
[10020]96
[9965]97    //WeaponManager         weaponMan;      //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping
[9961]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
[9950]102    //ship atributes
[9957]103    float       shieldCur;          //!< current shield
104    float       shieldMax;          //!< maximum shield
[9950]105    float       shieldEnergyShare;  //!< percentage of reactor output
[9970]106    float       shieldRegen;        //!< shield regeneration rate per second
[9957]107    float       shieldTH;           //!< shield threshhold for reactivation
[9950]108    bool        shieldActive;       //!< wheather the shield is working
[9943]109
[9957]110    float       armorCur;           //!< current armor
111    float       armorMax;           //!< maximum armor
[9963]112    float       armorRegen;         //!< armor regeneration per tick (usable on bioships?)
[9943]113
[9957]114    float       electronicCur;      //!< current electronic
115    float       electronicMax;      //!< maximum electronic
116    float       electronicRegen;    //!< electronic regenration rate per tick
[10020]117    float       electronicTH;       //!< Threshhold for electronic failure
[9943]118
[9970]119    float       engineSpeedCur;     //!< speed output for movement = speed base + energy share part
120    float       engineSpeedBase;    //!< speed base
[9950]121    int         enginePowerConsume; //!< energy needed
122    float       engineEnergyShare;  //!< percentage of reactor output
[9943]123
[9950]124    int         weaponEnergySlot;   //!< number of energy weapon slots
125    int         weaponEnergyUsed;
126    float       weaponEnergyShare;
[9965]127    float       weaponEnergyRegen;
[9950]128    int         weaponSpecialSlot;  //!< number of special weapon slots
129    int         weaponSpecialUsed;
[9943]130
[9965]131    float       reactorOutput;      //!< reactor output
132    float       reactorCapacity;    //!< reactor capacity
[9943]133
[9961]134    int         curWeaponPrimary;   //!< current primary weapon config
135    int         curWeaponSecondary; //!< current secondary weapon config
[9958]136
[10017]137    bool                  bForward;                //!< up button pressed.
138    bool                  bBackward;              //!< down button pressed.
[7346]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)
[10023]145    bool                  bSecFire;           //!< second fire button pressed
[7346]146
[10017]147    /*
[7346]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;
[10017]154    */
[7346]155
[10043]156    Vector                velocity;           //!< the velocity of the player.
[10078]157    Vector                oldPos;
[10017]158
[9971]159// 2D-traveling
160    PNode*                travelNode;
161    float                 travelSpeed;        //!< the current speed of the Ship (to make soft movement)
[10098]162    Vector                travelVelocity;     //!< object internal velocity vector for relative movement to the track node
[10019]163    Vector2D              travelDistancePlus;     //!< Travel-Distance away from the TravelNode
164    Vector2D              travelDistanceMinus;
[9971]165
166// Camera
167    PNode                 cameraNode;
168    float                 cameraLook;
169    float                 rotation;
[10017]170    float                 cameraSpeed;
[9971]171
[10017]172    /*
[7346]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;
[9971]178    float                 dogdeSpeed;        //!< the dogde Speed of the ship.
[10017]179    */
[7346]180
[10032]181    //Quaternion            direction;          //!< the direction of the ship.
[9971]182    float                 acceleration;       //!< the acceleration of the ship.
[10017]183    //float                 airFriction;        //!< AirFriction.
184    //float                 airViscosity;
[7346]185
186    byte                  oldMask;            //!< used for synchronisation
187
[10081]188    Trail*                trail;              //!< Burst trail
189    Trail*                trailL;              //!< Burst trail
190    Trail*                trailR;              //!< Burst trail
191
[7346]192};
193
194#endif /* _SPACE_SHIPS_H */
Note: See TracBrowser for help on using the repository browser.