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.

136 lines
4.7 KiB

  1. //========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "baseentity.h"
  9. #include "sendproxy.h"
  10. #include "sun_shared.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. #define LIGHTGLOW_MAXDIST_BITS 16
  14. #define LIGHTGLOW_MAXDIST_MAX_VALUE ((1 << LIGHTGLOW_MAXDIST_BITS)-1)
  15. #define LIGHTGLOW_OUTERMAXDIST_BITS 16
  16. #define LIGHTGLOW_OUTERMAXDIST_MAX_VALUE ((1 << LIGHTGLOW_OUTERMAXDIST_BITS)-1)
  17. class CLightGlow : public CBaseEntity
  18. {
  19. public:
  20. DECLARE_CLASS( CLightGlow, CBaseEntity );
  21. DECLARE_SERVERCLASS();
  22. DECLARE_DATADESC();
  23. CLightGlow();
  24. virtual void Spawn( void );
  25. virtual void Activate( void );
  26. virtual int UpdateTransmitState( void );
  27. void InputColor(inputdata_t &data);
  28. public:
  29. CNetworkVar( int, m_nHorizontalSize );
  30. CNetworkVar( int, m_nVerticalSize );
  31. CNetworkVar( int, m_nMinDist );
  32. CNetworkVar( int, m_nMaxDist );
  33. CNetworkVar( int, m_nOuterMaxDist );
  34. CNetworkVar( float, m_flGlowProxySize );
  35. CNetworkVar( float, m_flHDRColorScale );
  36. };
  37. extern void SendProxy_Angles( const SendProp *pProp, const void *pStruct, const void *pData, DVariant *pOut, int iElement, int objectID );
  38. IMPLEMENT_SERVERCLASS_ST_NOBASE( CLightGlow, DT_LightGlow )
  39. SendPropInt( SENDINFO(m_clrRender), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
  40. SendPropInt( SENDINFO(m_nHorizontalSize), 16, SPROP_UNSIGNED ),
  41. SendPropInt( SENDINFO(m_nVerticalSize), 16, SPROP_UNSIGNED ),
  42. SendPropInt( SENDINFO(m_nMinDist), 16, SPROP_UNSIGNED ),
  43. SendPropInt( SENDINFO(m_nMaxDist), LIGHTGLOW_MAXDIST_BITS, SPROP_UNSIGNED ),
  44. SendPropInt( SENDINFO(m_nOuterMaxDist), LIGHTGLOW_OUTERMAXDIST_BITS, SPROP_UNSIGNED ),
  45. SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED ),
  46. SendPropVector(SENDINFO(m_vecOrigin), -1, SPROP_COORD ),
  47. SendPropQAngles (SENDINFO(m_angRotation), 13, 0, SendProxy_Angles ),
  48. SendPropEHandle (SENDINFO_NAME(m_hMoveParent, moveparent)),
  49. SendPropFloat( SENDINFO(m_flGlowProxySize ), 6, SPROP_ROUNDUP, 0.0f, 64.0f ),
  50. SendPropFloat( SENDINFO_NAME( m_flHDRColorScale, HDRColorScale ), 0, SPROP_NOSCALE, 0.0f, 100.0f ),
  51. END_SEND_TABLE()
  52. LINK_ENTITY_TO_CLASS( env_lightglow, CLightGlow );
  53. BEGIN_DATADESC( CLightGlow )
  54. DEFINE_KEYFIELD( m_nVerticalSize, FIELD_INTEGER, "VerticalGlowSize" ),
  55. DEFINE_KEYFIELD( m_nHorizontalSize, FIELD_INTEGER, "HorizontalGlowSize" ),
  56. DEFINE_KEYFIELD( m_nMinDist, FIELD_INTEGER, "MinDist" ),
  57. DEFINE_KEYFIELD( m_nMaxDist, FIELD_INTEGER, "MaxDist" ),
  58. DEFINE_KEYFIELD( m_nOuterMaxDist, FIELD_INTEGER, "OuterMaxDist" ),
  59. DEFINE_KEYFIELD( m_flGlowProxySize, FIELD_FLOAT, "GlowProxySize" ),
  60. DEFINE_KEYFIELD( m_flHDRColorScale, FIELD_FLOAT, "HDRColorScale" ),
  61. DEFINE_INPUTFUNC( FIELD_COLOR32, "Color", InputColor ),
  62. END_DATADESC()
  63. //-----------------------------------------------------------------------------
  64. // Constructor
  65. //-----------------------------------------------------------------------------
  66. CLightGlow::CLightGlow( void )
  67. {
  68. m_nHorizontalSize = 0.0f;
  69. m_nVerticalSize = 0.0f;
  70. m_nMinDist = 0.0f;
  71. m_nMaxDist = 0.0f;
  72. m_flGlowProxySize = 2.0f;
  73. }
  74. //-----------------------------------------------------------------------------
  75. // Purpose:
  76. //-----------------------------------------------------------------------------
  77. void CLightGlow::Spawn( void )
  78. {
  79. BaseClass::Spawn();
  80. // No model but we still need to force this!
  81. AddEFlags( EFL_FORCE_CHECK_TRANSMIT );
  82. }
  83. //-----------------------------------------------------------------------------
  84. // Purpose: Always transmit light glows to clients to avoid spikes as we enter
  85. // or leave PVS. Done because we often have many glows in an area.
  86. //-----------------------------------------------------------------------------
  87. int CLightGlow::UpdateTransmitState( void )
  88. {
  89. return SetTransmitState( FL_EDICT_ALWAYS );
  90. }
  91. //-----------------------------------------------------------------------------
  92. // Purpose:
  93. //-----------------------------------------------------------------------------
  94. void CLightGlow::Activate()
  95. {
  96. BaseClass::Activate();
  97. if ( m_nMaxDist > LIGHTGLOW_MAXDIST_MAX_VALUE )
  98. {
  99. Warning( "env_lightglow maxdist too large (%d should be %d).\n", m_nMaxDist.Get(), LIGHTGLOW_MAXDIST_MAX_VALUE );
  100. m_nMaxDist = LIGHTGLOW_MAXDIST_MAX_VALUE;
  101. }
  102. if ( m_nOuterMaxDist > LIGHTGLOW_OUTERMAXDIST_MAX_VALUE )
  103. {
  104. Warning( "env_lightglow outermaxdist too large (%d should be %d).\n", m_nOuterMaxDist.Get(), LIGHTGLOW_OUTERMAXDIST_MAX_VALUE );
  105. m_nOuterMaxDist = LIGHTGLOW_OUTERMAXDIST_MAX_VALUE;
  106. }
  107. }
  108. void CLightGlow::InputColor(inputdata_t &inputdata)
  109. {
  110. m_clrRender = inputdata.value.Color32();
  111. }