aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/client/fx_trail.cpp
blob: 9a090e6543f74aad947210151e6d51701421d274 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================//

#include "cbase.h"
#include "fx_trail.h"

C_ParticleTrail::C_ParticleTrail( void )
{
}

C_ParticleTrail::~C_ParticleTrail( void )
{
	if ( m_pParticleMgr )
	{
		m_pParticleMgr->RemoveEffect( &m_ParticleEffect );
	}
}

//-----------------------------------------------------------------------------
// Purpose: Gets the attachment point to spawn at
//-----------------------------------------------------------------------------
void C_ParticleTrail::GetAimEntOrigin( IClientEntity *pAttachedTo, Vector *pAbsOrigin, QAngle *pAbsAngles )
{
	C_BaseEntity *pEnt = pAttachedTo->GetBaseEntity();

	if ( pEnt && (m_nAttachment > 0) )
	{
		pEnt->GetAttachment( m_nAttachment, *pAbsOrigin, *pAbsAngles );
		return;
	}

	BaseClass::GetAimEntOrigin( pAttachedTo, pAbsOrigin, pAbsAngles );
}

//-----------------------------------------------------------------------------
// Purpose: Turn on the emission of particles 
//-----------------------------------------------------------------------------
void C_ParticleTrail::SetEmit( bool bEmit )
{
	m_bEmit = bEmit;
}

//-----------------------------------------------------------------------------
// Purpose: Set the spawn rate of the effect
//-----------------------------------------------------------------------------
void C_ParticleTrail::SetSpawnRate( float rate )
{
	m_SpawnRate = rate;
	m_ParticleSpawn.Init( rate );
}

//-----------------------------------------------------------------------------
// Purpose: First sent down from the server
//-----------------------------------------------------------------------------
void C_ParticleTrail::OnDataChanged(DataUpdateType_t updateType)
{
	C_BaseEntity::OnDataChanged(updateType);

	if ( updateType == DATA_UPDATE_CREATED )
	{
		Start( ParticleMgr(), NULL );
	}
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_ParticleTrail::Start( CParticleMgr *pParticleMgr, IPrototypeArgAccess *pArgs )
{
	if( pParticleMgr->AddEffect( &m_ParticleEffect, this ) == false )
		return;

	m_pParticleMgr = pParticleMgr;
}