Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/playability/src/world_entities/projectiles/projectile.h @ 9959

Last change on this file since 9959 was 9959, checked in by nicolasc, 17 years ago

moved damage attr to proteced; collidesWith checks against SpaceShip and does some damage

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