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.

123 lines
3.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: area portal entity: toggles visibility areas on/off
  4. //
  5. // NOTE: These are not really brush entities. They are brush entities from a
  6. // designer/worldcraft perspective, but by the time they reach the game, the
  7. // brush model is gone and this is, in effect, a point entity.
  8. //
  9. // $NoKeywords: $
  10. //=============================================================================//
  11. #include "cbase.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. class CFuncOccluder : public CBaseEntity
  15. {
  16. public:
  17. DECLARE_CLASS( CFuncOccluder, CBaseEntity );
  18. CFuncOccluder();
  19. virtual void Spawn( void );
  20. virtual int UpdateTransmitState( void );
  21. // Input handlers
  22. void InputActivate( inputdata_t &inputdata );
  23. void InputDeactivate( inputdata_t &inputdata );
  24. void InputToggle( inputdata_t &inputdata );
  25. DECLARE_DATADESC();
  26. DECLARE_SERVERCLASS();
  27. private:
  28. CNetworkVar( bool, m_bActive );
  29. CNetworkVar( int, m_nOccluderIndex );
  30. };
  31. LINK_ENTITY_TO_CLASS( func_occluder, CFuncOccluder );
  32. IMPLEMENT_SERVERCLASS_ST_NOBASE(CFuncOccluder, DT_FuncOccluder)
  33. SendPropBool( SENDINFO(m_bActive) ),
  34. SendPropInt(SENDINFO(m_nOccluderIndex), 10, SPROP_UNSIGNED ),
  35. END_SEND_TABLE()
  36. BEGIN_DATADESC( CFuncOccluder )
  37. DEFINE_KEYFIELD( m_bActive, FIELD_BOOLEAN, "StartActive" ),
  38. // NOTE: This keyfield is computed + inserted by VBSP
  39. DEFINE_KEYFIELD( m_nOccluderIndex, FIELD_INTEGER, "occludernumber" ),
  40. // Inputs
  41. DEFINE_INPUTFUNC( FIELD_VOID, "Deactivate", InputDeactivate ),
  42. DEFINE_INPUTFUNC( FIELD_VOID, "Activate", InputActivate ),
  43. DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ),
  44. END_DATADESC()
  45. //------------------------------------------------------------------------------
  46. // Occluder :
  47. //------------------------------------------------------------------------------
  48. CFuncOccluder::CFuncOccluder()
  49. {
  50. m_bActive = true;
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. //-----------------------------------------------------------------------------
  55. void CFuncOccluder::Spawn( void )
  56. {
  57. Precache( );
  58. m_takedamage = DAMAGE_NO;
  59. SetSolid( SOLID_NONE );
  60. SetMoveType( MOVETYPE_NONE );
  61. // set size and link into world.
  62. SetModel( STRING( GetModelName() ) );
  63. }
  64. //------------------------------------------------------------------------------
  65. // Purpose :
  66. //------------------------------------------------------------------------------
  67. void CFuncOccluder::InputDeactivate( inputdata_t &inputdata )
  68. {
  69. m_bActive = false;
  70. }
  71. //------------------------------------------------------------------------------
  72. // Purpose :
  73. //------------------------------------------------------------------------------
  74. void CFuncOccluder::InputActivate( inputdata_t &inputdata )
  75. {
  76. m_bActive = true;
  77. }
  78. //------------------------------------------------------------------------------
  79. // Purpose :
  80. //------------------------------------------------------------------------------
  81. void CFuncOccluder::InputToggle( inputdata_t &inputdata )
  82. {
  83. m_bActive = !m_bActive;
  84. }
  85. //------------------------------------------------------------------------------
  86. // We always want to transmit these bad boys
  87. //------------------------------------------------------------------------------
  88. int CFuncOccluder::UpdateTransmitState()
  89. {
  90. // ALWAYS transmit to all clients.
  91. return SetTransmitState( FL_EDICT_ALWAYS );
  92. }