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.

118 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Shadow control entity.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. // memdbgon must be the last include file in a .cpp file!!!
  9. #include "tier0/memdbgon.h"
  10. //------------------------------------------------------------------------------
  11. // FIXME: This really should inherit from something more lightweight
  12. //------------------------------------------------------------------------------
  13. //------------------------------------------------------------------------------
  14. // Purpose : Water LOD control entity
  15. //------------------------------------------------------------------------------
  16. class CWaterLODControl : public CBaseEntity
  17. {
  18. public:
  19. DECLARE_CLASS( CWaterLODControl, CBaseEntity );
  20. CWaterLODControl();
  21. void Spawn( void );
  22. bool KeyValue( const char *szKeyName, const char *szValue );
  23. int UpdateTransmitState();
  24. void SetCheapWaterStartDistance( inputdata_t &inputdata );
  25. void SetCheapWaterEndDistance( inputdata_t &inputdata );
  26. virtual int ObjectCaps( void ) { return BaseClass::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
  27. DECLARE_SERVERCLASS();
  28. DECLARE_DATADESC();
  29. private:
  30. CNetworkVar( float, m_flCheapWaterStartDistance );
  31. CNetworkVar( float, m_flCheapWaterEndDistance );
  32. };
  33. LINK_ENTITY_TO_CLASS(water_lod_control, CWaterLODControl);
  34. BEGIN_DATADESC( CWaterLODControl )
  35. DEFINE_KEYFIELD( m_flCheapWaterStartDistance, FIELD_FLOAT, "cheapwaterstartdistance" ),
  36. DEFINE_KEYFIELD( m_flCheapWaterEndDistance, FIELD_FLOAT, "cheapwaterenddistance" ),
  37. // Inputs
  38. DEFINE_INPUT( m_flCheapWaterStartDistance, FIELD_FLOAT, "SetCheapWaterStartDistance" ),
  39. DEFINE_INPUT( m_flCheapWaterEndDistance, FIELD_FLOAT, "SetCheapWaterEndDistance" ),
  40. END_DATADESC()
  41. IMPLEMENT_SERVERCLASS_ST_NOBASE(CWaterLODControl, DT_WaterLODControl)
  42. SendPropFloat(SENDINFO(m_flCheapWaterStartDistance), 0, SPROP_NOSCALE ),
  43. SendPropFloat(SENDINFO(m_flCheapWaterEndDistance), 0, SPROP_NOSCALE ),
  44. END_SEND_TABLE()
  45. CWaterLODControl::CWaterLODControl()
  46. {
  47. m_flCheapWaterStartDistance = 1000.0f;
  48. m_flCheapWaterEndDistance = 2000.0f;
  49. }
  50. //------------------------------------------------------------------------------
  51. // Purpose : Send even though we don't have a model
  52. //------------------------------------------------------------------------------
  53. int CWaterLODControl::UpdateTransmitState()
  54. {
  55. // ALWAYS transmit to all clients.
  56. return SetTransmitState( FL_EDICT_ALWAYS );
  57. }
  58. bool CWaterLODControl::KeyValue( const char *szKeyName, const char *szValue )
  59. {
  60. if ( FStrEq( szKeyName, "cheapwaterstartdistance" ) )
  61. {
  62. m_flCheapWaterStartDistance = atof( szValue );
  63. return true;
  64. }
  65. if ( FStrEq( szKeyName, "cheapwaterenddistance" ) )
  66. {
  67. m_flCheapWaterEndDistance = atof( szValue );
  68. return true;
  69. }
  70. return BaseClass::KeyValue( szKeyName, szValue );
  71. }
  72. //------------------------------------------------------------------------------
  73. // Purpose :
  74. //------------------------------------------------------------------------------
  75. void CWaterLODControl::Spawn( void )
  76. {
  77. Precache();
  78. SetSolid( SOLID_NONE );
  79. }
  80. //------------------------------------------------------------------------------
  81. // Input values
  82. //------------------------------------------------------------------------------
  83. void CWaterLODControl::SetCheapWaterStartDistance( inputdata_t &inputdata )
  84. {
  85. m_flCheapWaterStartDistance = atof( inputdata.value.String() );
  86. }
  87. void CWaterLODControl::SetCheapWaterEndDistance( inputdata_t &inputdata )
  88. {
  89. m_flCheapWaterEndDistance = atof( inputdata.value.String() );
  90. }