Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/presentation/src/world_entities/projectiles/projectile_weapon.h @ 10746

Last change on this file since 10746 was 10618, checked in by bknecht, 18 years ago

merged cleanup into trunk (only improvements)

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