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.

115 lines
2.4 KiB

  1. //========= Copyright 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( float, m_fDisappearDist );
  25. // CBaseEntity overrides.
  26. public:
  27. virtual void Spawn();
  28. bool CreateVPhysics();
  29. virtual void Activate();
  30. virtual bool KeyValue( const char *szKeyName, const char *szValue );
  31. };
  32. IMPLEMENT_SERVERCLASS_ST(CFunc_LOD, DT_Func_LOD)
  33. SendPropFloat(SENDINFO(m_fDisappearDist), 0, SPROP_NOSCALE),
  34. END_SEND_TABLE()
  35. LINK_ENTITY_TO_CLASS(func_lod, CFunc_LOD);
  36. //---------------------------------------------------------
  37. // Save/Restore
  38. //---------------------------------------------------------
  39. BEGIN_DATADESC( CFunc_LOD )
  40. DEFINE_FIELD( m_fDisappearDist, FIELD_FLOAT ),
  41. END_DATADESC()
  42. // ------------------------------------------------------------------------------------- //
  43. // CFunc_LOD implementation.
  44. // ------------------------------------------------------------------------------------- //
  45. CFunc_LOD::CFunc_LOD()
  46. {
  47. }
  48. CFunc_LOD::~CFunc_LOD()
  49. {
  50. }
  51. void CFunc_LOD::Spawn()
  52. {
  53. // Bind to our bmodel.
  54. SetModel( STRING( GetModelName() ) );
  55. SetSolid( SOLID_BSP );
  56. BaseClass::Spawn();
  57. CreateVPhysics();
  58. }
  59. bool CFunc_LOD::CreateVPhysics()
  60. {
  61. VPhysicsInitStatic();
  62. return true;
  63. }
  64. void CFunc_LOD::Activate()
  65. {
  66. BaseClass::Activate();
  67. }
  68. bool CFunc_LOD::KeyValue( const char *szKeyName, const char *szValue )
  69. {
  70. if (FStrEq(szKeyName, "DisappearDist"))
  71. {
  72. m_fDisappearDist = (float)atof(szValue);
  73. }
  74. else if (FStrEq(szKeyName, "Solid"))
  75. {
  76. if (atoi(szValue) != 0)
  77. {
  78. AddSolidFlags( FSOLID_NOT_SOLID );
  79. }
  80. }
  81. else
  82. {
  83. return BaseClass::KeyValue(szKeyName, szValue);
  84. }
  85. return true;
  86. }