Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

133 lines
3.2 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // This file defines the C_TEParticleSystem class, which handles most of the
  9. // interfacing with the particle manager, simulation, and rendering.
  10. // NOTE: most tempents are singletons.
  11. #ifndef C_TE_PARTICLESYSTEM_H
  12. #define C_TE_PARTICLESYSTEM_H
  13. #include "particlemgr.h"
  14. #include "c_basetempentity.h"
  15. #include "particles_simple.h"
  16. #define SIMSHIFT 10
  17. typedef enum {
  18. pt_static,
  19. pt_grav,
  20. pt_slowgrav,
  21. pt_fire,
  22. pt_explode,
  23. pt_explode2,
  24. pt_blob,
  25. pt_blob2,
  26. pt_vox_slowgrav,
  27. pt_vox_grav,
  28. pt_snow,
  29. pt_rain,
  30. pt_clientcustom // Must have callback function specified
  31. } ptype_t;
  32. class C_TEParticleSystem : public C_BaseTempEntity
  33. {
  34. public:
  35. DECLARE_CLASS( C_TEParticleSystem, C_BaseTempEntity );
  36. DECLARE_CLIENTCLASS();
  37. C_TEParticleSystem();
  38. public:
  39. // particle effect sort origin
  40. Vector m_vecOrigin;
  41. };
  42. // This is the class that legacy tempents use to emit particles.
  43. // They use it in this pattern:
  44. // CTEParticleRenderer *pRen = CTEParticleRenderer::Create();
  45. // pRen->AddParticle....
  46. // pRen->Release();
  47. class CTEParticleRenderer : public CParticleEffect
  48. {
  49. public:
  50. DECLARE_CLASS( CTEParticleRenderer, CParticleEffect );
  51. virtual ~CTEParticleRenderer();
  52. // Create a CTEParticleRenderer. Pass in your sort origin (m_vecOrigin).
  53. static CSmartPtr<CTEParticleRenderer> Create( const char *pDebugName, const Vector &vOrigin );
  54. StandardParticle_t* AddParticle();
  55. CParticleMgr* GetParticleMgr();
  56. void SetParticleType( StandardParticle_t *pParticle, ptype_t type );
  57. ptype_t GetParticleType( StandardParticle_t *pParticle );
  58. // Get/set lifetime. Note: lifetime here is a counter. You set it to a value and it
  59. // counts down and disappears after that long.
  60. void SetParticleLifetime( StandardParticle_t *pParticle, float lifetime );
  61. float GetParticleLifetime( StandardParticle_t *pParticle );
  62. // IParticleEffect overrides.
  63. public:
  64. virtual void RenderParticles( CParticleRenderIterator *pIterator );
  65. virtual void SimulateParticles( CParticleSimulateIterator *pIterator );
  66. private:
  67. explicit CTEParticleRenderer( const char *pDebugName );
  68. CTEParticleRenderer( const CTEParticleRenderer & ); // = delete; not defined, not accessible
  69. int m_nActiveParticles;
  70. float m_ParticleSize;
  71. PMaterialHandle m_MaterialHandle;
  72. };
  73. // ------------------------------------------------------------------------ //
  74. // Inlines.
  75. // ------------------------------------------------------------------------ //
  76. inline void CTEParticleRenderer::SetParticleType(StandardParticle_t *pParticle, ptype_t type)
  77. {
  78. pParticle->m_EffectData = (unsigned char)type;
  79. }
  80. inline ptype_t CTEParticleRenderer::GetParticleType(StandardParticle_t *pParticle)
  81. {
  82. return (ptype_t)pParticle->m_EffectData;
  83. }
  84. // Get/set lifetime. Note that
  85. inline void CTEParticleRenderer::SetParticleLifetime(StandardParticle_t *pParticle, float lifetime)
  86. {
  87. pParticle->m_Lifetime = lifetime;
  88. }
  89. inline float CTEParticleRenderer::GetParticleLifetime(StandardParticle_t *pParticle)
  90. {
  91. return pParticle->m_Lifetime;
  92. }
  93. #endif