summaryrefslogtreecommitdiff
path: root/game/client/tf2/c_gasoline_blob.h
blob: 101dfca0a7481bfc499186901cb2a3096d64f282 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef C_GASOLINE_BLOB_H
#define C_GASOLINE_BLOB_H
#ifdef _WIN32
#pragma once
#endif


#include "c_baseentity.h"
#include "particles_simple.h"
#include "particle_util.h"


class C_GasolineBlob;

class CGasolineEmitter : public CSimpleEmitter
{
public:

	static CSmartPtr<CGasolineEmitter>	Create( C_GasolineBlob *pBlob );

	void				UpdateFire( float frametime );


private:

						CGasolineEmitter() : CSimpleEmitter( "Gasoline" ){}
						CGasolineEmitter( const CGasolineEmitter & );

	
	C_GasolineBlob		*m_pBlob;

	PMaterialHandle		m_hFireMaterial;
	PMaterialHandle		m_hUnlitMaterial;
	TimedEvent			m_Timer;
};


class C_GasolineBlob : public C_BaseEntity
{
friend class CGasolineEmitter;

public:
	DECLARE_CLASS( C_GasolineBlob, C_BaseEntity );
	DECLARE_CLIENTCLASS();


					C_GasolineBlob();
	virtual			~C_GasolineBlob();

	bool			IsLit() const;
	bool			IsStopped() const;
	const Vector&	GetSurfaceNormal() const;
	float			GetLitStartTime() const;


// Overrides.
public:

	virtual void	OnDataChanged( DataUpdateType_t type );
	virtual void	ClientThink();
	virtual int		DrawModel( int flags );
	virtual bool	ShouldDraw();


private:

	// Returns true if the two blobs relate their sound, meaning one blob won't play
	// its sound if the other one is playing it.
	bool			IsSoundRelatedTo( const C_GasolineBlob *pBlob ) const;

	bool			IsPlayingBurningSound() const;

	// Starts the burning sound if no other flames are playing the sound nearby.
	void			CheckStartSound();

	// Make the burning sound.
	void			StartSound();
	void			StopSound();


private:

	bool			m_bSoundOn;
	float			m_flPuddleSize;
	float			m_flPuddleFade;

	CSmartPtr<CGasolineEmitter>	m_pEmitter;

	float			m_flLitStartTime;

	float			m_flCreateTime;
	float			m_flMaxLifetime;

	Vector			m_vSurfaceNormal;

	int				m_BlobFlags;		// Combination of BLOBFLAG_ defines.
};


#endif // C_GASOLINE_BLOB_H