Team Fortress 2 Source Code as on 22/4/2020
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.

100 lines
2.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // Particle system entities can derive from this to handle some of the mundane
  9. // functionality of hooking into the engine's entity system.
  10. #ifndef PARTICLE_BASEEFFECT_H
  11. #define PARTICLE_BASEEFFECT_H
  12. #include "predictable_entity.h"
  13. #include "baseentity_shared.h"
  14. #if defined( CLIENT_DLL )
  15. #define CBaseParticleEntity C_BaseParticleEntity
  16. #include "particlemgr.h"
  17. #endif
  18. class CBaseParticleEntity : public CBaseEntity
  19. #if defined( CLIENT_DLL )
  20. , public IParticleEffect
  21. #endif
  22. {
  23. public:
  24. DECLARE_CLASS( CBaseParticleEntity, CBaseEntity );
  25. DECLARE_PREDICTABLE();
  26. DECLARE_NETWORKCLASS();
  27. CBaseParticleEntity();
  28. virtual ~CBaseParticleEntity();
  29. // CBaseEntity overrides.
  30. public:
  31. #if !defined( CLIENT_DLL )
  32. virtual int UpdateTransmitState( void );
  33. #else
  34. // Default IParticleEffect overrides.
  35. public:
  36. virtual bool ShouldSimulate() const { return m_bSimulate; }
  37. virtual void SetShouldSimulate( bool bSim ) { m_bSimulate = bSim; }
  38. virtual void SimulateParticles( CParticleSimulateIterator *pIterator );
  39. virtual void RenderParticles( CParticleRenderIterator *pIterator );
  40. virtual const Vector & GetSortOrigin();
  41. public:
  42. CParticleEffectBinding m_ParticleEffect;
  43. #endif
  44. virtual void Activate();
  45. virtual void Think();
  46. #if defined( CLIENT_DLL )
  47. // NOTE: Ths enclosed particle effect binding will do all the drawing
  48. virtual bool ShouldDraw() { return false; }
  49. int AllocateToolParticleEffectId();
  50. int GetToolParticleEffectId() const;
  51. private:
  52. int m_nToolParticleEffectId;
  53. bool m_bSimulate;
  54. #endif
  55. public:
  56. void FollowEntity(CBaseEntity *pEntity);
  57. // UTIL_Remove will be called after the specified amount of time.
  58. // If you pass in -1, the entity will never go away automatically.
  59. void SetLifetime(float lifetime);
  60. private:
  61. CBaseParticleEntity( const CBaseParticleEntity & ); // not defined, not accessible
  62. };
  63. #if defined( CLIENT_DLL )
  64. inline int CBaseParticleEntity::GetToolParticleEffectId() const
  65. {
  66. return m_nToolParticleEffectId;
  67. }
  68. inline int CBaseParticleEntity::AllocateToolParticleEffectId()
  69. {
  70. m_nToolParticleEffectId = ParticleMgr()->AllocateToolParticleEffectId();
  71. return m_nToolParticleEffectId;
  72. }
  73. #endif // CLIENT_DLL
  74. #endif