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.

130 lines
3.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Implements the server side of a steam jet particle system entity.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "steamjet.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //Networking
  12. IMPLEMENT_SERVERCLASS_ST(CSteamJet, DT_SteamJet)
  13. SendPropFloat(SENDINFO(m_SpreadSpeed), 0, SPROP_NOSCALE),
  14. SendPropFloat(SENDINFO(m_Speed), 0, SPROP_NOSCALE),
  15. SendPropFloat(SENDINFO(m_StartSize), 0, SPROP_NOSCALE),
  16. SendPropFloat(SENDINFO(m_EndSize), 0, SPROP_NOSCALE),
  17. SendPropFloat(SENDINFO(m_Rate), 0, SPROP_NOSCALE),
  18. SendPropFloat(SENDINFO(m_JetLength), 0, SPROP_NOSCALE),
  19. SendPropInt(SENDINFO(m_bEmit), 1, SPROP_UNSIGNED),
  20. SendPropInt(SENDINFO(m_bFaceLeft), 1, SPROP_UNSIGNED), // For support of legacy env_steamjet, which faced left instead of forward.
  21. SendPropInt(SENDINFO(m_nType), 32, SPROP_UNSIGNED),
  22. SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED ),
  23. SendPropFloat(SENDINFO(m_flRollSpeed), 0, SPROP_NOSCALE),
  24. END_SEND_TABLE()
  25. LINK_ENTITY_TO_CLASS( env_steam, CSteamJet );
  26. LINK_ENTITY_TO_CLASS( env_steamjet, CSteamJet ); // For support of legacy env_steamjet, which faced left instead of forward.
  27. //Save/restore
  28. BEGIN_DATADESC( CSteamJet )
  29. //Keyvalue fields
  30. DEFINE_KEYFIELD( m_StartSize, FIELD_FLOAT, "StartSize" ),
  31. DEFINE_KEYFIELD( m_EndSize, FIELD_FLOAT, "EndSize" ),
  32. DEFINE_KEYFIELD( m_InitialState, FIELD_BOOLEAN, "InitialState" ),
  33. DEFINE_KEYFIELD( m_nType, FIELD_INTEGER, "Type" ),
  34. DEFINE_KEYFIELD( m_flRollSpeed, FIELD_FLOAT, "RollSpeed" ),
  35. //Regular fields
  36. DEFINE_FIELD( m_bEmit, FIELD_INTEGER ),
  37. DEFINE_FIELD( m_bFaceLeft, FIELD_BOOLEAN ),
  38. // Inputs
  39. DEFINE_INPUT( m_JetLength, FIELD_FLOAT, "JetLength" ),
  40. DEFINE_INPUT( m_SpreadSpeed, FIELD_FLOAT, "SpreadSpeed" ),
  41. DEFINE_INPUT( m_Speed, FIELD_FLOAT, "Speed" ),
  42. DEFINE_INPUT( m_Rate, FIELD_FLOAT, "Rate" ),
  43. DEFINE_INPUTFUNC( FIELD_VOID, "TurnOn", InputTurnOn ),
  44. DEFINE_INPUTFUNC( FIELD_VOID, "TurnOff", InputTurnOff ),
  45. DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ),
  46. END_DATADESC()
  47. CSteamJet::CSteamJet( void )
  48. {
  49. m_flRollSpeed = 8.0f;
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose: Called before spawning, after key values have been set.
  53. //-----------------------------------------------------------------------------
  54. void CSteamJet::Spawn( void )
  55. {
  56. Precache();
  57. //
  58. // Legacy env_steamjet pointed left instead of forward.
  59. //
  60. if ( FClassnameIs( this, "env_steamjet" ))
  61. {
  62. m_bFaceLeft = true;
  63. }
  64. if ( m_InitialState )
  65. {
  66. m_bEmit = true;
  67. }
  68. }
  69. void CSteamJet::Precache( void )
  70. {
  71. PrecacheMaterial( "particle/particle_smokegrenade" );
  72. PrecacheMaterial( "sprites/heatwave" );
  73. }
  74. void CSteamJet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
  75. {
  76. if (!pActivator->IsPlayer())
  77. {
  78. if (useType == USE_ON)
  79. {
  80. m_bEmit = true;
  81. }
  82. else if (useType == USE_OFF)
  83. {
  84. m_bEmit = false;
  85. }
  86. }
  87. }
  88. //-----------------------------------------------------------------------------
  89. // Purpose: Input handler for toggling the steam jet on/off.
  90. //-----------------------------------------------------------------------------
  91. void CSteamJet::InputToggle(inputdata_t &data)
  92. {
  93. m_bEmit = !m_bEmit;
  94. }
  95. //-----------------------------------------------------------------------------
  96. // Purpose: Input handler for turning on the steam jet.
  97. //-----------------------------------------------------------------------------
  98. void CSteamJet::InputTurnOn(inputdata_t &data)
  99. {
  100. m_bEmit = true;
  101. }
  102. //-----------------------------------------------------------------------------
  103. // Purpose: Input handler for turning off the steam jet.
  104. //-----------------------------------------------------------------------------
  105. void CSteamJet::InputTurnOff(inputdata_t &data)
  106. {
  107. m_bEmit = false;
  108. }