source-engine/game/shared/particle_property.h

129 lines
5.1 KiB
C
Raw Normal View History

2023-10-03 14:23:56 +00:00
//====== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. =======
2020-04-22 16:56:21 +00:00
//
// Purpose:
//
//=============================================================================
#ifndef PARTICLEPROPERTY_H
#define PARTICLEPROPERTY_H
#ifdef _WIN32
#pragma once
#endif
#include "smartptr.h"
#include "globalvars_base.h"
#include "particles_new.h"
#include "particle_parse.h"
//-----------------------------------------------------------------------------
// Forward declarations
//-----------------------------------------------------------------------------
class CBaseEntity;
class CNewParticleEffect;
struct ParticleControlPoint_t
{
ParticleControlPoint_t()
{
iControlPoint = 0;
iAttachType = PATTACH_ABSORIGIN_FOLLOW;
iAttachmentPoint = 0;
vecOriginOffset = vec3_origin;
2023-10-03 14:23:56 +00:00
matOffset.Invalidate();
2020-04-22 16:56:21 +00:00
}
int iControlPoint;
ParticleAttachment_t iAttachType;
int iAttachmentPoint;
Vector vecOriginOffset;
2023-10-03 14:23:56 +00:00
matrix3x4_t matOffset;
2020-04-22 16:56:21 +00:00
EHANDLE hEntity;
};
struct ParticleEffectList_t
{
ParticleEffectList_t()
{
pParticleEffect = NULL;
}
CUtlVector<ParticleControlPoint_t> pControlPoints;
CSmartPtr<CNewParticleEffect> pParticleEffect;
};
extern int GetAttachTypeFromString( const char *pszString );
//-----------------------------------------------------------------------------
// Encapsulates particle handling for an entity
//-----------------------------------------------------------------------------
class CParticleProperty
{
DECLARE_CLASS_NOBASE( CParticleProperty );
DECLARE_EMBEDDED_NETWORKVAR();
DECLARE_PREDICTABLE();
DECLARE_DATADESC();
public:
CParticleProperty();
~CParticleProperty();
void Init( CBaseEntity *pEntity );
CBaseEntity *GetOuter( void ) { return m_pOuter; }
2023-10-03 14:23:56 +00:00
int GetAllParticleEffectRenderables( IClientRenderable **pOutput, int iMaxOutput ); //gets a list of all renderables used by this particle property
2020-04-22 16:56:21 +00:00
// Effect Creation
CNewParticleEffect *Create( const char *pszParticleName, ParticleAttachment_t iAttachType, const char *pszAttachmentName );
2023-10-03 14:23:56 +00:00
CNewParticleEffect *Create( const char *pszParticleName, ParticleAttachment_t iAttachType, int iAttachmentPoint = -1, Vector vecOriginOffset = vec3_origin, matrix3x4_t *vecOffsetMatrix = NULL );
CNewParticleEffect *CreatePrecached( int nPrecacheIndex, ParticleAttachment_t iAttachType, int iAttachmentPoint = -1, Vector vecOriginOffset = vec3_origin, matrix3x4_t *vecOffsetMatrix = NULL );
void AddControlPoint( CNewParticleEffect *pEffect, int iPoint, C_BaseEntity *pEntity, ParticleAttachment_t iAttachType, const char *pszAttachmentName = NULL, Vector vecOriginOffset = vec3_origin, matrix3x4_t *vecOffsetMatrix = NULL );
void AddControlPoint( int iEffectIndex, int iPoint, C_BaseEntity *pEntity, ParticleAttachment_t iAttachType, int iAttachmentPoint = -1, Vector vecOriginOffset = vec3_origin, matrix3x4_t *vecOffsetMatrix = NULL );
2020-04-22 16:56:21 +00:00
inline void SetControlPointParent( CNewParticleEffect *pEffect, int whichControlPoint, int parentIdx );
void SetControlPointParent( int iEffectIndex, int whichControlPoint, int parentIdx );
// Commands
2023-10-03 14:23:56 +00:00
void StopEmission( CNewParticleEffect *pEffect = NULL, bool bWakeOnStop = false, bool bDestroyAsleepSystems = false, bool bForceRemoveInstantly = false, bool bPlayEndCap = false );
2020-04-22 16:56:21 +00:00
void StopEmissionAndDestroyImmediately( CNewParticleEffect *pEffect = NULL );
// kill all particle systems involving a given entity for their control points
2023-10-03 14:23:56 +00:00
void StopParticlesInvolving( CBaseEntity *pEntity, bool bForceRemoveInstantly = false );
void StopParticlesNamed( const char *pszEffectName, bool bForceRemoveInstantly = false, int nSplitScreenPlayerSlot = -1 ); ///< kills all particles using the given definition name
2020-04-22 16:56:21 +00:00
// Particle System hooks
void OnParticleSystemUpdated( CNewParticleEffect *pEffect, float flTimeDelta );
void OnParticleSystemDeleted( CNewParticleEffect *pEffect );
#ifdef CLIENT_DLL
void OwnerSetDormantTo( bool bDormant );
#endif
// Used to replace a particle effect with a different one; attaches the control point updating to the new one
void ReplaceParticleEffect( CNewParticleEffect *pOldEffect, CNewParticleEffect *pNewEffect );
// Debugging
void DebugPrintEffects( void );
2023-10-03 14:23:56 +00:00
bool IsValidEffect( const CNewParticleEffect *pEffect ); //is this effect still alive?
int FindEffect( CNewParticleEffect *pEffect );
int FindEffect( const char *pEffectName );
2020-04-22 16:56:21 +00:00
private:
2023-10-03 14:23:56 +00:00
CNewParticleEffect *Create( CParticleSystemDefinition *pDef, ParticleAttachment_t iAttachType, int iAttachmentPoint, Vector vecOriginOffset, matrix3x4_t *matOffset = NULL );
2020-04-22 16:56:21 +00:00
int GetParticleAttachment( C_BaseEntity *pEntity, const char *pszAttachmentName, const char *pszParticleName );
void UpdateParticleEffect( ParticleEffectList_t *pEffect, bool bInitializing = false, int iOnlyThisControlPoint = -1 );
void UpdateControlPoint( ParticleEffectList_t *pEffect, int iPoint, bool bInitializing );
2023-10-03 14:23:56 +00:00
inline CNewParticleEffect *GetParticleEffectFromIdx( int idx );
2020-04-22 16:56:21 +00:00
private:
CBaseEntity *m_pOuter;
CUtlVector<ParticleEffectList_t> m_ParticleEffects;
int m_iDormancyChangedAtFrame;
friend class CBaseEntity;
};
#include "particle_property_inlines.h"
#endif // PARTICLEPROPERTY_H