/*! * @file space_ship.h * Implements the Control of a Spaceship * Space Ships are the core class for all types of ships in Orxonox * By default is on OM_GROUP_00 * If player boards the ship, it is moved to OM_GROUP_01 */ #ifndef _SPACE_SHIP_H #define _SPACE_SHIP_H #include "playable.h" #include "extendable.h" // Forward Declaration template class tList; class Vector; class Event; class ParticleEmitter; class ParticleSystem; class Trail; class Wobblegrid; class SpaceShip : public Playable { ObjectListDeclaration(SpaceShip); public: SpaceShip(const std::string& fileName); SpaceShip(const TiXmlElement* root = NULL); virtual ~SpaceShip(); virtual void loadParams(const TiXmlElement* root); virtual void setPlayDirection(const Quaternion& rot, float speed = 0.0f); /* void setTravelHeight(float travelHeight); void setTravelDistance(const Vector2D& distance); void setTravelDistance(float x, float y); */ //void setAirFriction(float friction) { this->airFriction = friction; }; virtual void enter(); virtual void leave(); virtual void reset(); virtual void postSpawn(); virtual void leftWorld(); virtual void destroy(WorldEntity* killer); virtual void respawn(); inline Vector getVelocity() { return this->velocity; }; virtual void tick(float time); virtual void draw() const; virtual void process(const Event &event); // virtual void hit (WorldEntity* entity, float damage); inline WeaponManager& getWeaponManagerSecondary() { return this->secWeaponMan; }; //!< functions for XML loading inline void setReactor(float output) {this->reactorOutput = output; }; inline void setShield(float cur, float max, float th, float regen) { this->shieldCur = cur; this->shieldMax = max; this->shieldTH = th; this->shieldRegen = regen;}; inline void setArmor(float cur, float max) { this->armorCur = cur; this->armorMax = max; updateHealth(); }; inline void setElectronic(float cur, float max, float th, float regen) { this->electronicCur = cur; this->electronicMax = max; this->electronicTH = th; this->electronicRegen = regen; }; inline void setEngine( float speedBase) {this->engineSpeedBase = speedBase; }; inline void setEnergyShare(float shield, float weapon, float engine) { float tmp = shield + weapon + engine; if (unlikely (tmp > 1)) { tmp = 1/tmp; } // dirty safty hack, prevents total share being bigger than 1!! this->shieldEnergyShare = shield * tmp; this->weaponEnergyShare = weapon * tmp; this->engineEnergyShare = engine * tmp; }; inline void setWeapon(float regen) { this->weaponEnergyRegen = regen; }; //!< Resynchonizes armor with health in WE!! inline void updateHealth() { this->setHealth(this->armorCur); this->setHealthMax(this->armorMax); }; inline void setPriWM(int slot) { this->weaponMan.setSlotCount(slot); }; inline void setSecWM(int slot) { this->secWeaponMan.setSlotCount(slot); }; inline void createPriWMSlot( int slot, Vector location, long capability) { this->weaponMan.setSlotPosition(slot, location); this->weaponMan.setSlotCapability(slot, capability); }; inline void createSecWMSlot( int slot, Vector location, long capability) { this->secWeaponMan.setSlotPosition(slot, location); this->secWeaponMan.setSlotCapability(slot, capability); }; //Functions for GUI inline float getShieldCur() { return this->shieldCur; }; //!< returns current shield value inline float getShieldMax() { return this->shieldMax; }; //!< returns maximum shield value inline float getArmorCur() { return this->armorCur; }; //!< returns current armor value inline float getArmorMax() { return this->armorMax; }; //!< returns current armor value inline float getElectronicCur() { return this->electronicCur; }; //!< returns current electronic value inline float getElectronicMax() { return this->electronicMax; }; //!< returns current electronic value inline PNode* getTravelNode() { return this->travelNode; }; //damage handler virtual void damage(float pDamage, float eDamage); //!< pDamage physical damage, eDamage electronic damage //included by Michel: virtual void enterPlaymode(Playable::Playmode playmode); void setPlaymodeXML(const std::string& playmode); //recieves the playmode from a string (useful for script implementation) void setActionWidthPercentage(int i); void setTravelSpeed(float f); void updateTravelDistance(); virtual void movement (float dt); void nextWeaponConfig(); void previousWeaponConfig(); virtual void hit(float damage, WorldEntity* killer); void setCameraDistance(float dist); private: void init(); //void calculateVelocity(float time); void regen(float time); //!< handler for shield and electronic regeneration void weaponRegen(float time); //!< weapon energy regeneration inline bool systemFailure() { return (this->electronicCur < float(rand())/float(RAND_MAX) * this->electronicTH); }; void updateElectronicWidget(); void updateShieldWidget(); //WeaponManager weaponMan; //!< the primary weapon manager: managing a list of energy weapons to wepaon-slot mapping WeaponManager secWeaponMan; //!< the secondary weapon manager: managing a list of special weapons to weapon-slot mapping short supportedPlaymodes; //!< What Playmodes are Supported in this Playable. Playable::Playmode playmode; //!< The current playmode. //ship atributes float shieldCur; //!< current shield float shieldMax; //!< maximum shield float shieldEnergyShare; //!< percentage of reactor output float shieldRegen; //!< shield regeneration rate per second float shieldTH; //!< shield threshhold for reactivation bool shieldActive; //!< wheather the shield is working OrxGui::GLGuiEnergyWidgetVertical* shieldWidget; //!< holds the widget that shows the shield bar float armorCur; //!< current armor float armorMax; //!< maximum armor float armorRegen; //!< armor regeneration per tick (usable on bioships?) //note that the armor widget is set on the health- widget in world- entity (see in player.cc) float electronicCur; //!< current electronic float electronicMax; //!< maximum electronic float electronicRegen; //!< electronic regenration rate per tick float electronicTH; //!< Threshhold for electronic failure OrxGui::GLGuiEnergyWidgetVertical* electronicWidget; //!< holds the widget that shows the electronic bar float engineSpeedCur; //!< speed output for movement = speed base + energy share part float engineSpeedBase; //!< speed base int enginePowerConsume; //!< energy needed float engineEnergyShare; //!< percentage of reactor output int weaponEnergySlot; //!< number of energy weapon slots int weaponEnergyUsed; float weaponEnergyShare; float weaponEnergyRegen; int weaponSpecialSlot; //!< number of special weapon slots int weaponSpecialUsed; float reactorOutput; //!< reactor output // float reactorCapacity; //!< reactor capacity int curWeaponPrimary; //!< current primary weapon config int curWeaponSecondary; //!< current secondary weapon config bool bForward; //!< up button pressed. bool bBackward; //!< down button pressed. bool bLeft; //!< left button pressed. bool bRight; //!< right button pressed. bool bAscend; //!< ascend button pressed. bool bDescend; //!< descend button presses. bool bRollL; //!< rolling button pressed (left) bool bRollR; //!< rolling button pressed (right) bool bSecFire; //!< second fire button pressed /* float xMouse; //!< mouse moved in x-Direction float yMouse; //!< mouse moved in y-Direction float mouseSensitivity; //!< the mouse sensitivity int yInvert; int controlVelocityX; int controlVelocityY; */ Vector velocity; //!< the velocity of the player. Vector oldPos; // 2D-traveling PNode* travelNode; float travelSpeed; //!< the current speed of the Ship (to make soft movement) Vector travelVelocity; //!< object internal velocity vector for relative movement to the track node Vector2D travelDistancePlus; //!< Travel-Distance away from the TravelNode Vector2D travelDistanceMinus; bool isTravelDistanceInit; float actionWidthPercentage; // Camera PNode cameraNode; float cameraLook; float rotation; float cameraSpeed; void setCameraFovy(float fovy); /* Quaternion mouseDir; //!< the direction where the player wants to fly Quaternion oldMouseDir; //!< the direction where the player wanted to fly float shipInertia; //!< the inertia of the ship(how fast the ship reacts to a mouse input) Quaternion rotQuat; Quaternion pitchDir; float dogdeSpeed; //!< the dogde Speed of the ship. */ //Quaternion direction; //!< the direction of the ship. float acceleration; //!< the acceleration of the ship. //float airFriction; //!< AirFriction. //float airViscosity; byte oldMask; //!< used for synchronisation /* Trail* trail; //!< Burst trail Trail* trailL; //!< Burst trail Trail* trailR; //!< Burst trail */ }; #endif /* _SPACE_SHIPS_H */