Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/ODE/src/world_entities/projectiles/projectile.h @ 10770

Last change on this file since 10770 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

File size: 2.4 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 tick (float dt);
47    /** @brief convenience function
48     * @param dt the Time passed
49     * @returns true if the Projectile is past its lifeTime, false if it shall still live */
50    inline bool tickLifeCycle(float dt ) { this->lifeCycle += dt/this->lifeSpan;  return(unlikely(this->lifeCycle >= 1)); }
51
52
53  protected:
54    // energy
55    float                  energyMin;                 //!< The minimal Energy a Projectile needs to be emitted.
56    bool                   bChargeable;               //!< if the Projectile is Charegeable
57
58    float                  lifeCycle;                 //!< The percentage of the Lifetime done [0-1]
59    float                  lifeSpan;                  //!< The entire lifespan of the Shoot. in seconds
60
61    Vector                 flightDirection;           //!< DOF direction in which the shoot flighs
62
63    Vector                 velocity;                  //!< velocity of the projectile.
64
65    PNode*                 target;                    //!< A target for guided Weapons.
66
67    OrxSound::SoundSource  soundSource;
68  private:
69    OrxSound::SoundBuffer  explosionBuffer;
70    OrxSound::SoundBuffer  engineBuffer;
71};
72
73#endif /* _PROJECTILE_H */
Note: See TracBrowser for help on using the repository browser.