| 1 | /* | 
|---|
| 2 | * file bsp_weapon.h | 
|---|
| 3 | * A weapon that shoots both at player and environment (pnode and bsp). | 
|---|
| 4 | */ | 
|---|
| 5 |  | 
|---|
| 6 | #ifndef _BSP_WEAPON_H | 
|---|
| 7 | #define _BSP_WEAPON_H | 
|---|
| 8 |  | 
|---|
| 9 | #include "world_entity.h" | 
|---|
| 10 | #include "aiming_system.h" | 
|---|
| 11 | #include "effects/explosion.h" | 
|---|
| 12 |  | 
|---|
| 13 | #include <list> | 
|---|
| 14 |  | 
|---|
| 15 | #include "particles/box_emitter.h" | 
|---|
| 16 | #include "particles/sprite_particles.h" | 
|---|
| 17 |  | 
|---|
| 18 | class MuzzleFlash : public WorldEntity | 
|---|
| 19 | { | 
|---|
| 20 |   ObjectListDeclaration(MuzzleFlash); | 
|---|
| 21 |   public: | 
|---|
| 22 |     void explode (float lifetime); | 
|---|
| 23 |  | 
|---|
| 24 |     MuzzleFlash (); | 
|---|
| 25 |     virtual ~MuzzleFlash (); | 
|---|
| 26 |  | 
|---|
| 27 |     virtual void activate(); | 
|---|
| 28 |     virtual void deactivate(); | 
|---|
| 29 |  | 
|---|
| 30 |     virtual void tick (float time); | 
|---|
| 31 |     virtual void draw() const; | 
|---|
| 32 |  | 
|---|
| 33 |     void setLifeTime( float lifeTime ){ this->lifeTime = lifeTime; } | 
|---|
| 34 |      | 
|---|
| 35 |     void drawParticles(){ if (explosionParticles) explosionParticles->draw(); } | 
|---|
| 36 |  | 
|---|
| 37 |   protected: | 
|---|
| 38 |     //static FastFactory*        fastFactory; | 
|---|
| 39 |  | 
|---|
| 40 |     float                      lifeTime; | 
|---|
| 41 |     float                      lifeCycle; | 
|---|
| 42 |  | 
|---|
| 43 |     SpriteParticles*    explosionParticles; | 
|---|
| 44 |     BoxEmitter*                emitter; | 
|---|
| 45 |  | 
|---|
| 46 | }; | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|
| 49 | class BspWeapon : public WorldEntity | 
|---|
| 50 |         { | 
|---|
| 51 |                 ObjectListDeclaration(BspWeapon); | 
|---|
| 52 |         public: | 
|---|
| 53 |                 BspWeapon (); | 
|---|
| 54 |                 BspWeapon (const  TiXmlElement* root); | 
|---|
| 55 |                 virtual ~BspWeapon(); | 
|---|
| 56 |  | 
|---|
| 57 |                 void init(); | 
|---|
| 58 |                 void loadParams(const TiXmlElement* root); | 
|---|
| 59 |                 void fire(bool fire){ bFire = fire; } | 
|---|
| 60 |                 virtual void tick(float dt); | 
|---|
| 61 |                 virtual void draw() const; | 
|---|
| 62 |  | 
|---|
| 63 |  | 
|---|
| 64 |         private: | 
|---|
| 65 |  | 
|---|
| 66 |                 void shoot(); | 
|---|
| 67 |                 float range; | 
|---|
| 68 |                 void setRange( float r ){ this->range = r; } | 
|---|
| 69 |                 float damage; | 
|---|
| 70 |                 void setDamage( float d ){ this->damage = d; } | 
|---|
| 71 |                 float fireRate; | 
|---|
| 72 |                 void setFireRate( float r ){ this->fireRate = r; } | 
|---|
| 73 |                 bool alwaysHits; | 
|---|
| 74 |                 void setAlwaysHits( bool r ){ this->alwaysHits = r; } | 
|---|
| 75 |                 void addPoint(float x, float y, float z); | 
|---|
| 76 |                  | 
|---|
| 77 |     std::list<MuzzleFlash*> gunFire; | 
|---|
| 78 |  | 
|---|
| 79 |                 float bRate; | 
|---|
| 80 |                 bool bFire; | 
|---|
| 81 |  | 
|---|
| 82 |                 AimingSystem* aimingSystem; | 
|---|
| 83 |         }; | 
|---|
| 84 |  | 
|---|
| 85 | #endif | 
|---|