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.

96 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #include "cbase.h"
  7. // memdbgon must be the last include file in a .cpp file!!!
  8. #include "tier0/memdbgon.h"
  9. //-----------------------------------------------------------------------------
  10. class CTFGlow : public CBaseEntity
  11. {
  12. public:
  13. DECLARE_CLASS( CTFGlow, CBaseEntity );
  14. DECLARE_SERVERCLASS();
  15. DECLARE_DATADESC();
  16. virtual void Spawn() OVERRIDE;
  17. virtual int UpdateTransmitState() OVERRIDE;
  18. void InputEnable( inputdata_t &inputdata );
  19. void InputDisable( inputdata_t &inputdata );
  20. void InputSetGlowColor( inputdata_t &inputdata );
  21. private:
  22. CNetworkVar( int, m_iMode );
  23. CNetworkVar( color32, m_glowColor );
  24. CNetworkVar( bool, m_bDisabled );
  25. CNetworkHandle( CBaseEntity, m_hTarget );
  26. };
  27. //-----------------------------------------------------------------------------
  28. BEGIN_DATADESC( CTFGlow )
  29. DEFINE_KEYFIELD( m_iMode, FIELD_INTEGER, "Mode" ),
  30. DEFINE_KEYFIELD( m_glowColor, FIELD_COLOR32, "GlowColor" ),
  31. DEFINE_KEYFIELD( m_bDisabled, FIELD_BOOLEAN, "StartDisabled" ),
  32. DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),
  33. DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ),
  34. DEFINE_INPUTFUNC( FIELD_COLOR32, "SetGlowColor", InputSetGlowColor ),
  35. END_DATADESC()
  36. //-----------------------------------------------------------------------------
  37. IMPLEMENT_SERVERCLASS_ST( CTFGlow, DT_TFGlow )
  38. SendPropInt( SENDINFO( m_glowColor ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ),
  39. SendPropBool( SENDINFO( m_bDisabled ) ),
  40. SendPropEHandle( SENDINFO( m_hTarget ) ),
  41. SendPropInt( SENDINFO( m_iMode ), -1, SPROP_UNSIGNED ),
  42. END_SEND_TABLE()
  43. //-----------------------------------------------------------------------------
  44. LINK_ENTITY_TO_CLASS( tf_glow, CTFGlow );
  45. //-----------------------------------------------------------------------------
  46. void CTFGlow::Spawn()
  47. {
  48. CBaseEntity *pEnt = gEntList.FindEntityByName( nullptr, m_target );
  49. if ( !pEnt )
  50. {
  51. Warning( "tf_glow: failed to find target %s\n", m_target.ToCStr() );
  52. UTIL_Remove( this );
  53. return;
  54. }
  55. m_hTarget = pEnt;
  56. if ( gEntList.FindEntityByName( pEnt, m_target ) )
  57. {
  58. Warning( "tf_glow: only one target is supported (%s)\n", m_target.ToCStr() );
  59. }
  60. }
  61. //-----------------------------------------------------------------------------
  62. void CTFGlow::InputEnable( inputdata_t &inputdata )
  63. {
  64. m_bDisabled = false; // clients will take action
  65. }
  66. //-----------------------------------------------------------------------------
  67. void CTFGlow::InputDisable( inputdata_t &inputdata )
  68. {
  69. m_bDisabled = true; // clients will take action
  70. }
  71. //-----------------------------------------------------------------------------
  72. void CTFGlow::InputSetGlowColor( inputdata_t &inputdata )
  73. {
  74. m_glowColor = inputdata.value.Color32(); // clients will take action
  75. }
  76. //-----------------------------------------------------------------------------
  77. int CTFGlow::UpdateTransmitState()
  78. {
  79. return SetTransmitState( FL_EDICT_ALWAYS );
  80. }