Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/world_entities/projectiles/projectile.h @ 8017

Last change on this file since 8017 was 7460, checked in by bensch, 19 years ago

orxonox/trunk: Namespaces for sound

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