Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/blink/src/world_entities/projectiles/projectile_weapon.h @ 10474

Last change on this file since 10474 was 10368, checked in by patrick, 18 years ago

merged the branche playability into the trunk

File size: 4.9 KB
Line 
1/*!
2 * @file projectile_weapon.h
3 * a projectile_weapon, that is been shooted by a weapon
4 *
5 * You can use this class to make some ProjectileWeapons/Bullets/Lasers/Rockets/etc.
6 *
7 */
8
9#ifndef _PROJECTILE_WEAPON_H
10#define _PROJECTILE_WEAPON_H
11
12#include "world_entity.h"
13#include "loading/fast_factory.h"
14#include "space_ships/space_ship.h"
15
16#include "loading/fast_factory.h"
17#include "world_entities/projectiles/projectile.h"
18#include "weapons/weapon.h"
19
20
21#include "sound_source.h"
22#include "sound_buffer.h"
23
24class FastFactory;
25
26
27class ProjectileWeapon : public Projectile
28{
29  ObjectListDeclaration(ProjectileWeapon);
30  public:
31    ProjectileWeapon ();
32    virtual ~ProjectileWeapon ();
33
34    /** @brief Constructor with variable passing*/
35    ProjectileWeapon (float pDamage, float eDamage, PNode* target);
36    /** @brief for void construction; setting values later - needed for FastFactory*/
37    virtual void initialize(float pDamage, float eDamage, PNode* target);
38
39    void setFlightDirection(const Quaternion& flightDirection);
40    void setVelocity(const Vector &velocity);
41    void setLifeSpan(float lifeSpan);
42
43    void loadExplosionSound(const std::string& explosionSound);
44    void loadEngineSound(const std::string& engineSound);
45    void setMinEnergy(float energyMin);
46    /** @returns the minimal charched energy */
47    inline float getMinEnergy() { return this->energyMin; };
48    /** @returns if the ProjectileWeapon can be charged */
49    inline bool isChageable() { return this->bChargeable; };
50
51    void setTarget(PNode* target);
52
53    /** @brief This is called, when the ProjectileWeapon is Emitted */
54    virtual void activate() = 0;
55    /** @brief This is called, when the ProjectileWeapon is being destroyed, or deleted */
56    virtual void deactivate() = 0;
57
58    virtual void destroy (WorldEntity* killer);
59
60    virtual void collidesWith (WorldEntity* target, const Vector& location);  //!< collision handler; used against SpaceShip as most target will be
61
62
63    virtual void tick (float dt);
64    /** @brief convenience function
65     * @param dt the Time passed
66     * @returns true if the ProjectileWeapon is past its lifeTime, false if it shall still live */
67    inline bool tickLifeCycle(float dt ) { this->lifeCycle += dt/this->lifeSpan;  return(unlikely(this->lifeCycle >= 1)); }
68
69    inline float getPhysDamage() { return this->physDamage; };
70    inline float getElecDamage() { return this->elecDamage; };
71
72    inline void setPhysDamage( float dmg) {this->physDamage = dmg; };
73    inline void setElecDamage( float dmg) {this->elecDamage = dmg; };
74
75    inline void setRotationAxis ( Vector axis ) { this->rotationAxis = axis; };
76    inline void setRotationSpeed ( float speed ) { this->rotationSpeed = speed; };
77    inline const Vector & getRotationAxis () const { return this->rotationAxis; };
78    inline float getRotationSpeed () { return this->rotationSpeed; };     //!< Added for completeness
79
80    inline void setAngle () { this->angle = 0; };
81    inline void setAngle ( float angle ) { this->angle = angle; };
82    inline float getAngle () { return this->angle; };
83
84    inline void updateAngle ( float dt ) { this->angle += this->rotationSpeed * dt; };
85
86    inline void setFragments( int frag ) { this->fragments = frag; };
87    inline int getFragments () { return this->fragments; };
88
89//     virtual void blow ();
90
91  protected:
92    // energy
93    float                   energyMin;                //!< The minimal Energy a ProjectileWeapon needs to be emitted.
94    bool                    bChargeable;              //!< if the ProjectileWeapon is Charegeable
95
96    float                   lifeCycle;                //!< The percentage of the Lifetime done [0-1]
97    float                   lifeSpan;                 //!< The entire lifespan of the Shoot. in seconds
98
99    float                   physDamage;               //!< damage to shield and armor
100    float                   elecDamage;               //!< damage to elctronic
101    float                   turningSpeed;             //!< degrees per tick
102
103    Vector                  flightDirection;          //!< DOF direction in which the shoot flighs
104
105    float                   angle;                    //!< Spinning Projectile, needed to ajust dispersal pattern
106    float                   rotationSpeed;            //!< rotation speed
107    Vector                  rotationAxis;           //!< rotation axis
108
109    int                     fragments;                //!< Number of fragements created by the blow
110
111    Vector                  velocity;                 //!< velocity of the projectile_weapon.
112
113    PNode*                  target;                   //!< A target for guided Weapons.
114
115    virtual void            blow();
116
117//     FastFactory             ff;
118//     static FastFactory*               fastFactory;
119
120    OrxSound::SoundSource  soundSource;
121  private:
122    OrxSound::SoundBuffer  explosionBuffer;
123    OrxSound::SoundBuffer  engineBuffer;
124};
125
126#endif /* _PROJECTILE_WEAPON_H */
Note: See TracBrowser for help on using the repository browser.