aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/c_entitydissolve.h
blob: d440e0b62e3353cb8ef02463efa7620870618dd8 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//=============================================================================//

#ifndef C_ENTITY_DISSOLVE_H
#define C_ENTITY_DISSOLVE_H

#include "cbase.h"

//-----------------------------------------------------------------------------
// Entity Dissolve, client-side implementation
//-----------------------------------------------------------------------------
class C_EntityDissolve : public C_BaseEntity, public IMotionEvent
{
public:
	DECLARE_CLIENTCLASS();
	DECLARE_CLASS( C_EntityDissolve, C_BaseEntity );

	C_EntityDissolve( void );

	// Inherited from C_BaseEntity
	virtual void	GetRenderBounds( Vector& theMins, Vector& theMaxs );
	virtual int		DrawModel( int flags );
	virtual bool	ShouldDraw() { return true; }
	virtual void	OnDataChanged( DataUpdateType_t updateType );
	virtual void	UpdateOnRemove( void );

	virtual Vector	GetEffectColor( void ) { return m_vEffectColor; }
	virtual void	SetEffectColor( Vector v ) { m_vEffectColor = v; }

	// Inherited from IMotionEvent
	virtual simresult_e	Simulate( IPhysicsMotionController *pController, IPhysicsObject *pObject, float deltaTime, Vector &linear, AngularImpulse &angular );
	
	void			SetupEmitter( void );

	void			ClientThink( void );

	void			SetServerLinkState( bool state ) { m_bLinkedToServerEnt = state; }

	float	m_flStartTime;
	float	m_flFadeOutStart;
	float	m_flFadeOutLength;
	float	m_flFadeOutModelStart;
	float	m_flFadeOutModelLength;
	float	m_flFadeInStart;
	float	m_flFadeInLength;
	int		m_nDissolveType;
	float   m_flNextSparkTime;

	Vector	m_vEffectColor;

	Vector	m_vDissolverOrigin;
	int		m_nMagnitude;

	bool	m_bCoreExplode;

protected:

	float GetFadeInPercentage( void );		// Fade in amount (entity fading to black)
	float GetFadeOutPercentage( void );		// Fade out amount (particles fading away)
	float GetModelFadeOutPercentage( void );// Mode fade out amount

	// Compute the bounding box's center, size, and basis
	void ComputeRenderInfo( mstudiobbox_t *pHitBox, const matrix3x4_t &hitboxToWorld, 
								Vector *pVecAbsOrigin, Vector *pXVec, Vector *pYVec );
	void BuildTeslaEffect( mstudiobbox_t *pHitBox, const matrix3x4_t &hitboxToWorld, bool bRandom, float flYawOffset );

	void DoSparks( mstudiohitboxset_t *set, matrix3x4_t *hitboxbones[MAXSTUDIOBONES] );

private:

	CSmartPtr<CSimpleEmitter>	m_pEmitter;

	bool	m_bLinkedToServerEnt;
	IPhysicsMotionController	*m_pController;
};

#endif // C_ENTITY_DISSOLVE_H