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.

120 lines
2.7 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "cbase.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. class CFunc_LOD : public CBaseEntity
  12. {
  13. DECLARE_DATADESC();
  14. DECLARE_CLASS( CFunc_LOD, CBaseEntity );
  15. public:
  16. DECLARE_SERVERCLASS();
  17. CFunc_LOD();
  18. virtual ~CFunc_LOD();
  19. // When the viewer is between:
  20. // (0 and m_fNonintrusiveDist): the bmodel is forced to be visible
  21. // (m_fNonintrusiveDist and m_fDisappearDist): the bmodel is trying to appear or disappear nonintrusively
  22. // (waits until it's out of the view frustrum or until there's a lot of motion)
  23. // (m_fDisappearDist+): the bmodel is forced to be invisible
  24. CNetworkVar( int, m_nDisappearMinDist );
  25. CNetworkVar( int, m_nDisappearMaxDist );
  26. // CBaseEntity overrides.
  27. public:
  28. virtual void Spawn();
  29. bool CreateVPhysics();
  30. virtual void Activate();
  31. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  32. };
  33. IMPLEMENT_SERVERCLASS_ST(CFunc_LOD, DT_Func_LOD)
  34. SendPropInt( SENDINFO(m_nDisappearMinDist), 16, SPROP_UNSIGNED ),
  35. SendPropInt( SENDINFO(m_nDisappearMaxDist), 16, SPROP_UNSIGNED ),
  36. END_SEND_TABLE()
  37. LINK_ENTITY_TO_CLASS(func_lod, CFunc_LOD);
  38. //---------------------------------------------------------
  39. // Save/Restore
  40. //---------------------------------------------------------
  41. BEGIN_DATADESC( CFunc_LOD )
  42. DEFINE_KEYFIELD( m_nDisappearMinDist, FIELD_INTEGER, "DisappearMinDist" ),
  43. DEFINE_KEYFIELD( m_nDisappearMaxDist, FIELD_INTEGER, "DisappearMaxDist" ),
  44. END_DATADESC()
  45. // ------------------------------------------------------------------------------------- //
  46. // CFunc_LOD implementation.
  47. // ------------------------------------------------------------------------------------- //
  48. CFunc_LOD::CFunc_LOD()
  49. {
  50. }
  51. CFunc_LOD::~CFunc_LOD()
  52. {
  53. }
  54. void CFunc_LOD::Spawn()
  55. {
  56. // Bind to our bmodel.
  57. SetModel( STRING( GetModelName() ) );
  58. SetSolid( SOLID_BSP );
  59. BaseClass::Spawn();
  60. CreateVPhysics();
  61. }
  62. bool CFunc_LOD::CreateVPhysics()
  63. {
  64. VPhysicsInitStatic();
  65. return true;
  66. }
  67. void CFunc_LOD::Activate()
  68. {
  69. BaseClass::Activate();
  70. }
  71. bool CFunc_LOD::KeyValue( const char *szKeyName, const char *szValue )
  72. {
  73. // NOTE: Backward compat
  74. if ( FStrEq(szKeyName, "DisappearDist") )
  75. {
  76. m_nDisappearMinDist = atoi(szValue);
  77. m_nDisappearMaxDist = m_nDisappearMinDist + 800;
  78. }
  79. else if (FStrEq(szKeyName, "Solid"))
  80. {
  81. if (atoi(szValue) != 0)
  82. {
  83. AddSolidFlags( FSOLID_NOT_SOLID );
  84. }
  85. }
  86. else
  87. {
  88. return BaseClass::KeyValue(szKeyName, szValue);
  89. }
  90. return true;
  91. }