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.

95 lines
2.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: an entity which turns on and off counting and display of the particle
  4. // performance metric
  5. //
  6. //=============================================================================
  7. #include "cbase.h"
  8. #include "baseentity.h"
  9. #include "entityoutput.h"
  10. #include "convar.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. //-----------------------------------------------------------------------------
  14. // Purpose: Entity that particle performance measuring
  15. //-----------------------------------------------------------------------------
  16. class CParticlePerformanceMonitor : public CPointEntity
  17. {
  18. DECLARE_CLASS( CParticlePerformanceMonitor, CPointEntity );
  19. public:
  20. DECLARE_DATADESC();
  21. DECLARE_SERVERCLASS();
  22. void Spawn( void );
  23. int UpdateTransmitState( void );
  24. // Inputs
  25. void InputTurnOnDisplay( inputdata_t &inputdata );
  26. void InputTurnOffDisplay( inputdata_t &inputdata );
  27. void InputStartMeasuring( inputdata_t &inputdata );
  28. void InputStopMeasuring( inputdata_t &inputdata );
  29. private:
  30. CNetworkVar( bool, m_bDisplayPerf );
  31. CNetworkVar( bool, m_bMeasurePerf );
  32. };
  33. LINK_ENTITY_TO_CLASS( env_particle_performance_monitor, CParticlePerformanceMonitor );
  34. BEGIN_DATADESC( CParticlePerformanceMonitor )
  35. DEFINE_FIELD( m_bDisplayPerf, FIELD_BOOLEAN ),
  36. DEFINE_FIELD( m_bMeasurePerf, FIELD_BOOLEAN ),
  37. // Inputs
  38. DEFINE_INPUTFUNC( FIELD_VOID, "TurnOnDisplay", InputTurnOnDisplay ),
  39. DEFINE_INPUTFUNC( FIELD_VOID, "TurnOffDisplay", InputTurnOffDisplay ),
  40. DEFINE_INPUTFUNC( FIELD_VOID, "StartMeasuring", InputStartMeasuring ),
  41. DEFINE_INPUTFUNC( FIELD_VOID, "StopMeasuring", InputStopMeasuring ),
  42. END_DATADESC()
  43. IMPLEMENT_SERVERCLASS_ST( CParticlePerformanceMonitor, DT_ParticlePerformanceMonitor )
  44. SendPropInt( SENDINFO(m_bDisplayPerf), 1, SPROP_UNSIGNED ),
  45. SendPropInt( SENDINFO(m_bMeasurePerf), 1, SPROP_UNSIGNED ),
  46. END_SEND_TABLE()
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. void CParticlePerformanceMonitor::Spawn( void )
  51. {
  52. SetSolid( SOLID_NONE );
  53. SetMoveType( MOVETYPE_NONE );
  54. m_bDisplayPerf = false;
  55. m_bMeasurePerf = false;
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. //-----------------------------------------------------------------------------
  60. int CParticlePerformanceMonitor::UpdateTransmitState()
  61. {
  62. return SetTransmitState( FL_EDICT_ALWAYS );
  63. }
  64. void CParticlePerformanceMonitor::InputTurnOnDisplay( inputdata_t &inputdata )
  65. {
  66. m_bDisplayPerf = true;
  67. }
  68. void CParticlePerformanceMonitor::InputTurnOffDisplay( inputdata_t &inputdata )
  69. {
  70. m_bDisplayPerf = false;
  71. }
  72. void CParticlePerformanceMonitor::InputStartMeasuring( inputdata_t &inputdata )
  73. {
  74. m_bMeasurePerf = true;
  75. }
  76. void CParticlePerformanceMonitor::InputStopMeasuring( inputdata_t &inputdata )
  77. {
  78. m_bMeasurePerf = false;
  79. }