Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/space_ships/space_ship.h @ 10715

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

crosshair moves, but WM not

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