Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions src/game/client/c_particle_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class C_ParticleSystem : public C_BaseEntity
int m_iEffectIndex;
bool m_bActive;
bool m_bOldActive;
bool m_bDestroyImmediately;
float m_flStartTime; // Time at which the effect started

enum { kMAXCONTROLPOINTS = 63 }; ///< actually one less than the total number of cpoints since 0 is assumed to be me
Expand All @@ -56,6 +57,7 @@ BEGIN_RECV_TABLE_NOBASE( C_ParticleSystem, DT_ParticleSystem )

RecvPropInt( RECVINFO( m_iEffectIndex ) ),
RecvPropBool( RECVINFO( m_bActive ) ),
RecvPropBool( RECVINFO( m_bDestroyImmediately ) ),
RecvPropFloat( RECVINFO( m_flStartTime ) ),

RecvPropArray3( RECVINFO_ARRAY(m_hControlPointEnts), RecvPropEHandle( RECVINFO( m_hControlPointEnts[0] ) ) ),
Expand Down Expand Up @@ -109,8 +111,15 @@ void C_ParticleSystem::PostDataUpdate( DataUpdateType_t updateType )
}
else
{
ParticleProp()->StopEmission();
}
if ( m_bDestroyImmediately )
{
ParticleProp()->StopEmissionAndDestroyImmediately();
}
else
{
ParticleProp()->StopEmission();
}
}
}
}
}
Expand Down Expand Up @@ -273,9 +282,30 @@ void ParticleEffectStopCallback( const CEffectData &data )
C_BaseEntity *pEnt = C_BaseEntity::Instance( data.m_hEntity );
if ( pEnt )
{
pEnt->ParticleProp()->StopEmission();
}
pEnt->ParticleProp()->StopEmission();
}
}
}

DECLARE_CLIENT_EFFECT( "ParticleEffectStop", ParticleEffectStopCallback );


//======================================================================================================================
// PARTICLE SYSTEM STOP AND DESTROY EFFECT
//======================================================================================================================
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void ParticleEffectDestroyImmediatelyCallback( const CEffectData& data )
{
if ( data.m_hEntity.Get() )
{
C_BaseEntity* pEnt = C_BaseEntity::Instance( data.m_hEntity );
if ( pEnt )
{
pEnt->ParticleProp()->StopEmissionAndDestroyImmediately();
}
}
}

DECLARE_CLIENT_EFFECT( "ParticleEffectDestroyImmediately", ParticleEffectDestroyImmediatelyCallback );
13 changes: 13 additions & 0 deletions src/game/server/particle_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CParticleSystem, DT_ParticleSystem)

SendPropInt( SENDINFO(m_iEffectIndex), MAX_PARTICLESYSTEMS_STRING_BITS, SPROP_UNSIGNED ),
SendPropBool( SENDINFO(m_bActive) ),
SendPropBool( SENDINFO(m_bDestroyImmediately) ),
SendPropFloat( SENDINFO(m_flStartTime) ),

SendPropArray3( SENDINFO_ARRAY3(m_hControlPointEnts), SendPropEHandle( SENDINFO_ARRAY(m_hControlPointEnts) ) ),
Expand All @@ -38,6 +39,7 @@ BEGIN_DATADESC( CParticleSystem )
DEFINE_FIELD( m_bActive, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flStartTime, FIELD_TIME ),
DEFINE_KEYFIELD( m_iszEffectName, FIELD_STRING, "effect_name" ),
DEFINE_FIELD( m_bDestroyImmediately, FIELD_BOOLEAN ),
//DEFINE_FIELD( m_iEffectIndex, FIELD_INTEGER ), // Don't save. Refind after loading.

DEFINE_KEYFIELD( m_iszControlPointNames[0], FIELD_STRING, "cpoint1" ),
Expand Down Expand Up @@ -116,6 +118,7 @@ BEGIN_DATADESC( CParticleSystem )

DEFINE_INPUTFUNC( FIELD_VOID, "Start", InputStart ),
DEFINE_INPUTFUNC( FIELD_VOID, "Stop", InputStop ),
DEFINE_INPUTFUNC( FIELD_VOID, "DestroyImmediately", InputDestroyImmediately ),

DEFINE_THINKFUNC( StartParticleSystemThink ),

Expand Down Expand Up @@ -199,6 +202,7 @@ void CParticleSystem::StartParticleSystem( void )
{
m_flStartTime = gpGlobals->curtime;
m_bActive = true;
m_bDestroyImmediately = false;

// Setup our control points at this time (in case our targets weren't around at spawn time)
ReadControlPointEnts();
Expand Down Expand Up @@ -229,6 +233,15 @@ void CParticleSystem::InputStop( inputdata_t &inputdata )
StopParticleSystem();
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CParticleSystem::InputDestroyImmediately( inputdata_t& inputdata )
{
StopParticleSystem();
m_bDestroyImmediately = true;
}

//-----------------------------------------------------------------------------
// Purpose: Find each entity referred to by m_iszControlPointNames and
// resolve it into the corresponding slot in m_hControlPointEnts
Expand Down
2 changes: 2 additions & 0 deletions src/game/server/particle_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class CParticleSystem : public CBaseEntity

void InputStart( inputdata_t &inputdata );
void InputStop( inputdata_t &inputdata );
void InputDestroyImmediately( inputdata_t& inputdata );
void StartParticleSystemThink( void );

enum { kMAXCONTROLPOINTS = 63 }; ///< actually one less than the total number of cpoints since 0 is assumed to be me
Expand All @@ -47,6 +48,7 @@ class CParticleSystem : public CBaseEntity
string_t m_iszEffectName;

CNetworkVar( bool, m_bActive );
CNetworkVar( bool, m_bDestroyImmediately );
CNetworkVar( int, m_iEffectIndex )
CNetworkVar( float, m_flStartTime ); // Time at which this effect was started. This is used after restoring an active effect.

Expand Down