Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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