| [4597] | 1 | /*! | 
|---|
| [5039] | 2 |  * @file projectile.h | 
|---|
| [5498] | 3 |  * a projectile, that is been shooted by a weapon | 
|---|
 | 4 |  * | 
|---|
 | 5 |  * You can use this class to make some Projectiles/Bullets/Lasers/Rockets/etc. | 
|---|
 | 6 |  * | 
|---|
 | 7 |  */ | 
|---|
| [3710] | 8 |  | 
|---|
| [3573] | 9 | #ifndef _PROJECTILE_H | 
|---|
 | 10 | #define _PROJECTILE_H | 
|---|
 | 11 |  | 
|---|
 | 12 | #include "world_entity.h" | 
|---|
| [9869] | 13 | #include "loading/fast_factory.h" | 
|---|
| [10368] | 14 | #include "space_ships/space_ship.h" | 
|---|
| [3573] | 15 |  | 
|---|
| [7084] | 16 | #include "sound_source.h" | 
|---|
 | 17 | #include "sound_buffer.h" | 
|---|
 | 18 |  | 
|---|
| [4597] | 19 | class Projectile : public WorldEntity | 
|---|
| [3573] | 20 | { | 
|---|
| [9869] | 21 |   ObjectListDeclaration(Projectile); | 
|---|
| [4890] | 22 |   public: | 
|---|
| [4932] | 23 |     Projectile (); | 
|---|
| [4890] | 24 |     virtual ~Projectile (); | 
|---|
| [3573] | 25 |  | 
|---|
| [10368] | 26 |     /** @brief Constructor with variable passing*/ | 
|---|
 | 27 |     Projectile (float pDamage, float eDamage, PNode* target); | 
|---|
 | 28 |     /** @brief for void construction; setting values later - needed for FastFactory*/ | 
|---|
 | 29 |     virtual void initialize(float pDamage, float eDamage, PNode* target); | 
|---|
 | 30 |  | 
|---|
| [4927] | 31 |     void setFlightDirection(const Quaternion& flightDirection); | 
|---|
| [4890] | 32 |     void setVelocity(const Vector &velocity); | 
|---|
 | 33 |     void setLifeSpan(float lifeSpan); | 
|---|
| [3573] | 34 |  | 
|---|
| [7221] | 35 |     void loadExplosionSound(const std::string& explosionSound); | 
|---|
 | 36 |     void loadEngineSound(const std::string& engineSound); | 
|---|
| [6431] | 37 |     void setMinEnergy(float energyMin); | 
|---|
| [4948] | 38 |     /** @returns the minimal charched energy */ | 
|---|
| [6431] | 39 |     inline float getMinEnergy() { return this->energyMin; }; | 
|---|
| [4948] | 40 |     /** @returns if the Projectile can be charged */ | 
|---|
 | 41 |     inline bool isChageable() { return this->bChargeable; }; | 
|---|
| [3578] | 42 |  | 
|---|
| [5766] | 43 |     void setTarget(PNode* target); | 
|---|
| [3573] | 44 |  | 
|---|
| [5443] | 45 |     /** @brief This is called, when the Projectile is Emitted */ | 
|---|
 | 46 |     virtual void activate() = 0; | 
|---|
 | 47 |     /** @brief This is called, when the Projectile is being destroyed, or deleted */ | 
|---|
 | 48 |     virtual void deactivate() = 0; | 
|---|
| [4948] | 49 |  | 
|---|
| [9235] | 50 |     virtual void destroy (WorldEntity* killer); | 
|---|
| [4597] | 51 |  | 
|---|
| [10368] | 52 |     virtual void collidesWith (WorldEntity* target, const Vector& location);  //!< collision handler; used against SpaceShip as most target will be | 
|---|
 | 53 |  | 
|---|
 | 54 |  | 
|---|
| [6056] | 55 |     virtual void tick (float dt); | 
|---|
 | 56 |     /** @brief convenience function | 
|---|
 | 57 |      * @param dt the Time passed | 
|---|
 | 58 |      * @returns true if the Projectile is past its lifeTime, false if it shall still live */ | 
|---|
 | 59 |     inline bool tickLifeCycle(float dt ) { this->lifeCycle += dt/this->lifeSpan;  return(unlikely(this->lifeCycle >= 1)); } | 
|---|
| [4890] | 60 |  | 
|---|
| [10368] | 61 |     inline float getPhysDamage() { return this->physDamage; }; | 
|---|
 | 62 |     inline float getElecDamage() { return this->elecDamage; }; | 
|---|
| [6056] | 63 |  | 
|---|
| [10368] | 64 |     inline void setPhysDamage( float dmg) {this->physDamage = dmg; }; | 
|---|
 | 65 |     inline void setElecDamage( float dmg) {this->elecDamage = dmg; }; | 
|---|
 | 66 |  | 
|---|
| [4890] | 67 |   protected: | 
|---|
 | 68 |     // energy | 
|---|
| [10368] | 69 |     int                origList;                        //!< FIXME currently a fix around the collision seg fault | 
|---|
 | 70 |     float                   energyMin;                //!< The minimal Energy a Projectile needs to be emitted. | 
|---|
 | 71 |     bool                    bChargeable;              //!< if the Projectile is Charegeable | 
|---|
| [4890] | 72 |  | 
|---|
| [10368] | 73 |     float                   lifeCycle;                //!< The percentage of the Lifetime done [0-1] | 
|---|
 | 74 |     float                   lifeSpan;                 //!< The entire lifespan of the Shoot. in seconds | 
|---|
| [4890] | 75 |  | 
|---|
| [10368] | 76 |     float                   physDamage;               //!< damage to shield and armor | 
|---|
 | 77 |     float                   elecDamage;               //!< damage to elctronic | 
|---|
 | 78 |     float                   turningSpeed;             //!< degrees per tick | 
|---|
| [4890] | 79 |  | 
|---|
| [10368] | 80 |     Vector                  flightDirection;          //!< DOF direction in which the shoot flighs | 
|---|
| [5766] | 81 |  | 
|---|
| [10368] | 82 |     Vector                  velocity;                 //!< velocity of the projectile. | 
|---|
| [7084] | 83 |  | 
|---|
| [10368] | 84 |     PNode*                  target;                   //!< A target for guided Weapons. | 
|---|
 | 85 |  | 
|---|
| [7460] | 86 |     OrxSound::SoundSource  soundSource; | 
|---|
| [7084] | 87 |   private: | 
|---|
| [9869] | 88 |     OrxSound::SoundBuffer  explosionBuffer; | 
|---|
 | 89 |     OrxSound::SoundBuffer  engineBuffer; | 
|---|
| [3573] | 90 | }; | 
|---|
 | 91 |  | 
|---|
 | 92 | #endif /* _PROJECTILE_H */ | 
|---|