Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: Namespaces for sound

File size: 2.4 KB
RevLine 
[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"
[7193]13#include "fast_factory.h"
[3573]14
[7084]15#include "sound_source.h"
16#include "sound_buffer.h"
17
[4597]18class Projectile : public WorldEntity
[3573]19{
[4890]20  public:
[4932]21    Projectile ();
[4890]22    virtual ~Projectile ();
[3573]23
[4927]24    void setFlightDirection(const Quaternion& flightDirection);
[4890]25    void setVelocity(const Vector &velocity);
26    void setLifeSpan(float lifeSpan);
[3573]27
[7221]28    void loadExplosionSound(const std::string& explosionSound);
29    void loadEngineSound(const std::string& engineSound);
[6431]30    void setMinEnergy(float energyMin);
[4948]31    /** @returns the minimal charched energy */
[6431]32    inline float getMinEnergy() { return this->energyMin; };
[4948]33    /** @returns if the Projectile can be charged */
34    inline bool isChageable() { return this->bChargeable; };
[3578]35
[5766]36    void setTarget(PNode* target);
[3573]37
[5443]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;
[4948]42
[4890]43    virtual void destroy ();
[4597]44
[6056]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)); }
[4890]50
[6056]51
[4890]52  protected:
53    // energy
[7460]54    float                  energyMin;                 //!< The minimal Energy a Projectile needs to be emitted.
55    bool                   bChargeable;               //!< if the Projectile is Charegeable
[4890]56
[7460]57    float                  lifeCycle;                 //!< The percentage of the Lifetime done [0-1]
58    float                  lifeSpan;                  //!< The entire lifespan of the Shoot. in seconds
[4890]59
[7460]60    Vector                 flightDirection;           //!< DOF direction in which the shoot flighs
[4890]61
[7460]62    Vector                 velocity;                  //!< velocity of the projectile.
[5766]63
[7460]64    PNode*                 target;                    //!< A target for guided Weapons.
[7084]65
[7460]66    OrxSound::SoundSource  soundSource;
[7084]67  private:
[7460]68    OrxSound::SoundBuffer* explosionBuffer;
69    OrxSound::SoundBuffer* engineBuffer;
[3573]70};
71
72#endif /* _PROJECTILE_H */
Note: See TracBrowser for help on using the repository browser.