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 ( OM_LIST list ); |
---|
54 | BspWeapon (const TiXmlElement* root); |
---|
55 | virtual ~BspWeapon(); |
---|
56 | |
---|
57 | void init( OM_LIST list ); |
---|
58 | void loadParams(const TiXmlElement* root); |
---|
59 | void fire(bool fire){ this->bFire = fire; } |
---|
60 | virtual void tick(float dt); |
---|
61 | virtual void draw() const; |
---|
62 | |
---|
63 | void setAlwaysHits( bool r ){ this->alwaysHits = r; } |
---|
64 | void setDamage( float d ){ this->damage = d; } |
---|
65 | private: |
---|
66 | |
---|
67 | void shoot(); |
---|
68 | float range; |
---|
69 | void setRange( float r ){ this->range = r; } |
---|
70 | float damage; |
---|
71 | float fireRate; |
---|
72 | void setFireRate( float r ){ this->fireRate = r; } |
---|
73 | bool alwaysHits; |
---|
74 | void addPoint(float x, float y, float z); |
---|
75 | |
---|
76 | OrxSound::SoundSource soundSource_shoot; |
---|
77 | OrxSound::SoundBuffer soundBuffer_shoot;; |
---|
78 | |
---|
79 | std::list<MuzzleFlash*> gunFire; |
---|
80 | |
---|
81 | float bRate; |
---|
82 | bool bFire; |
---|
83 | #ifdef DEBUG_AIMING |
---|
84 | float debugDist; |
---|
85 | #endif |
---|
86 | |
---|
87 | AimingSystem* aimingSystem; |
---|
88 | }; |
---|
89 | |
---|
90 | #endif |
---|