summaryrefslogtreecommitdiff
path: root/game/client/c_te_particlesystem.h
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/client/c_te_particlesystem.h
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'game/client/c_te_particlesystem.h')
-rw-r--r--game/client/c_te_particlesystem.h133
1 files changed, 133 insertions, 0 deletions
diff --git a/game/client/c_te_particlesystem.h b/game/client/c_te_particlesystem.h
new file mode 100644
index 0000000..7bd7b4b
--- /dev/null
+++ b/game/client/c_te_particlesystem.h
@@ -0,0 +1,133 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+
+// This file defines the C_TEParticleSystem class, which handles most of the
+// interfacing with the particle manager, simulation, and rendering.
+
+// NOTE: most tempents are singletons.
+
+#ifndef C_TE_PARTICLESYSTEM_H
+#define C_TE_PARTICLESYSTEM_H
+
+
+#include "particlemgr.h"
+#include "c_basetempentity.h"
+#include "particles_simple.h"
+
+
+#define SIMSHIFT 10
+
+
+typedef enum {
+ pt_static,
+ pt_grav,
+ pt_slowgrav,
+ pt_fire,
+ pt_explode,
+ pt_explode2,
+ pt_blob,
+ pt_blob2,
+ pt_vox_slowgrav,
+ pt_vox_grav,
+ pt_snow,
+ pt_rain,
+ pt_clientcustom // Must have callback function specified
+} ptype_t;
+
+
+
+class C_TEParticleSystem : public C_BaseTempEntity
+{
+public:
+
+ DECLARE_CLASS( C_TEParticleSystem, C_BaseTempEntity );
+ DECLARE_CLIENTCLASS();
+
+ C_TEParticleSystem();
+
+
+public:
+
+ // particle effect sort origin
+ Vector m_vecOrigin;
+};
+
+
+// This is the class that legacy tempents use to emit particles.
+// They use it in this pattern:
+// CTEParticleRenderer *pRen = CTEParticleRenderer::Create();
+// pRen->AddParticle....
+// pRen->Release();
+
+class CTEParticleRenderer : public CParticleEffect
+{
+public:
+ DECLARE_CLASS( CTEParticleRenderer, CParticleEffect );
+ virtual ~CTEParticleRenderer();
+
+ // Create a CTEParticleRenderer. Pass in your sort origin (m_vecOrigin).
+ static CSmartPtr<CTEParticleRenderer> Create( const char *pDebugName, const Vector &vOrigin );
+
+ StandardParticle_t* AddParticle();
+
+ CParticleMgr* GetParticleMgr();
+
+ void SetParticleType( StandardParticle_t *pParticle, ptype_t type );
+ ptype_t GetParticleType( StandardParticle_t *pParticle );
+
+ // Get/set lifetime. Note: lifetime here is a counter. You set it to a value and it
+ // counts down and disappears after that long.
+ void SetParticleLifetime( StandardParticle_t *pParticle, float lifetime );
+ float GetParticleLifetime( StandardParticle_t *pParticle );
+
+
+// IParticleEffect overrides.
+public:
+ virtual void RenderParticles( CParticleRenderIterator *pIterator );
+ virtual void SimulateParticles( CParticleSimulateIterator *pIterator );
+
+private:
+ CTEParticleRenderer( const char *pDebugName );
+ CTEParticleRenderer( const CTEParticleRenderer & ); // not defined, not accessible
+
+ int m_nActiveParticles;
+ float m_ParticleSize;
+ PMaterialHandle m_MaterialHandle;
+};
+
+
+
+// ------------------------------------------------------------------------ //
+// Inlines.
+// ------------------------------------------------------------------------ //
+inline void CTEParticleRenderer::SetParticleType(StandardParticle_t *pParticle, ptype_t type)
+{
+ pParticle->m_EffectData = (unsigned char)type;
+}
+
+inline ptype_t CTEParticleRenderer::GetParticleType(StandardParticle_t *pParticle)
+{
+ return (ptype_t)pParticle->m_EffectData;
+}
+
+// Get/set lifetime. Note that
+inline void CTEParticleRenderer::SetParticleLifetime(StandardParticle_t *pParticle, float lifetime)
+{
+ pParticle->m_Lifetime = lifetime;
+}
+
+inline float CTEParticleRenderer::GetParticleLifetime(StandardParticle_t *pParticle)
+{
+ return pParticle->m_Lifetime;
+}
+
+
+#endif
+
+
+