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.

68 lines
2.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. extern bool g_bMeasureParticlePerformance;
  8. extern bool g_bDisplayParticlePerformance;
  9. void ResetParticlePerformanceCounters( void );
  10. //-----------------------------------------------------------------------------
  11. // Purpose:
  12. //-----------------------------------------------------------------------------
  13. class C_ParticlePerformanceMonitor : public C_BaseEntity
  14. {
  15. DECLARE_CLASS( C_ParticlePerformanceMonitor, C_BaseEntity );
  16. public:
  17. DECLARE_CLIENTCLASS();
  18. C_ParticlePerformanceMonitor();
  19. ~C_ParticlePerformanceMonitor();
  20. virtual void OnDataChanged( DataUpdateType_t updateType );
  21. private:
  22. bool m_bDisplayPerf;
  23. bool m_bMeasurePerf;
  24. private:
  25. C_ParticlePerformanceMonitor( const C_ParticlePerformanceMonitor & );
  26. };
  27. IMPLEMENT_CLIENTCLASS_DT( C_ParticlePerformanceMonitor, DT_ParticlePerformanceMonitor, CParticlePerformanceMonitor )
  28. RecvPropInt( RECVINFO(m_bMeasurePerf) ),
  29. RecvPropInt( RECVINFO(m_bDisplayPerf) ),
  30. END_RECV_TABLE()
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. //-----------------------------------------------------------------------------
  34. C_ParticlePerformanceMonitor::C_ParticlePerformanceMonitor( void )
  35. {
  36. m_bDisplayPerf = false;
  37. m_bMeasurePerf = false;
  38. }
  39. //-----------------------------------------------------------------------------
  40. // Purpose:
  41. //-----------------------------------------------------------------------------
  42. C_ParticlePerformanceMonitor::~C_ParticlePerformanceMonitor( void )
  43. {
  44. g_bMeasureParticlePerformance = false;
  45. g_bDisplayParticlePerformance = false;
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. void C_ParticlePerformanceMonitor::OnDataChanged( DataUpdateType_t updateType )
  51. {
  52. BaseClass::OnDataChanged(updateType);
  53. if ( m_bMeasurePerf && ( ! g_bMeasureParticlePerformance ) )
  54. ResetParticlePerformanceCounters();
  55. g_bMeasureParticlePerformance = m_bMeasurePerf;
  56. g_bDisplayParticlePerformance = m_bDisplayPerf;
  57. }