Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6689 was 6434, checked in by bensch, 19 years ago

orxonox/trunk: moved the projectiles to Projectiles

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