Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/projectiles/projectile.h @ 9958

Last change on this file since 9958 was 9958, checked in by marcscha, 17 years ago

Inline of damage get on projectile, part implementation of primary - secondary weapon and handling variables for the weapon manager

File size: 2.9 KB
Line 
1/*!
2 * @file projectile.h
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 */
8
9#ifndef _PROJECTILE_H
10#define _PROJECTILE_H
11
12#include "world_entity.h"
13#include "loading/fast_factory.h"
14
15#include "sound_source.h"
16#include "sound_buffer.h"
17
18class Projectile : public WorldEntity
19{
20  ObjectListDeclaration(Projectile);
21  public:
22    Projectile ();
23    virtual ~Projectile ();
24
25    void setFlightDirection(const Quaternion& flightDirection);
26    void setVelocity(const Vector &velocity);
27    void setLifeSpan(float lifeSpan);
28
29    void loadExplosionSound(const std::string& explosionSound);
30    void loadEngineSound(const std::string& engineSound);
31    void setMinEnergy(float energyMin);
32    /** @returns the minimal charched energy */
33    inline float getMinEnergy() { return this->energyMin; };
34    /** @returns if the Projectile can be charged */
35    inline bool isChageable() { return this->bChargeable; };
36
37    void setTarget(PNode* target);
38
39    /** @brief This is called, when the Projectile is Emitted */
40    virtual void activate() = 0;
41    /** @brief This is called, when the Projectile is being destroyed, or deleted */
42    virtual void deactivate() = 0;
43
44    virtual void destroy (WorldEntity* killer);
45
46    virtual void collidesWith (WorldEntity* entity, const Vector& location);   //!< collision handler as used in diverse weapons
47
48    virtual void tick (float dt);
49    /** @brief convenience function
50     * @param dt the Time passed
51     * @returns true if the Projectile is past its lifeTime, false if it shall still live */
52    inline bool tickLifeCycle(float dt ) { this->lifeCycle += dt/this->lifeSpan;  return(unlikely(this->lifeCycle >= 1)); }
53
54    inline int getPhysDamage() { return this->physDamage; };
55    inline int getElecDamage() { return this->elecDamage; };
56
57  protected:
58    // energy
59    float                  energyMin;                 //!< The minimal Energy a Projectile needs to be emitted.
60    bool                   bChargeable;               //!< if the Projectile is Charegeable
61
62    float                  lifeCycle;                 //!< The percentage of the Lifetime done [0-1]
63    float                  lifeSpan;                  //!< The entire lifespan of the Shoot. in seconds
64
65    Vector                 flightDirection;           //!< DOF direction in which the shoot flighs
66
67    Vector                 velocity;                  //!< velocity of the projectile.
68
69    PNode*                 target;                    //!< A target for guided Weapons.
70
71    OrxSound::SoundSource  soundSource;
72  private:
73    OrxSound::SoundBuffer  explosionBuffer;
74    OrxSound::SoundBuffer  engineBuffer;
75
76    int                     physDamage;               //!< damage to shield and armor
77    int                     elecDamage;               //!< damage to elctronic
78};
79
80#endif /* _PROJECTILE_H */
Note: See TracBrowser for help on using the repository browser.