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.

109 lines
3.5 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "baseparticleentity.h"
  9. #include "sendproxy.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. class CFuncSmokeVolume : public CBaseParticleEntity
  13. {
  14. public:
  15. DECLARE_CLASS( CFuncSmokeVolume, CBaseParticleEntity );
  16. DECLARE_SERVERCLASS();
  17. DECLARE_DATADESC();
  18. CFuncSmokeVolume();
  19. void Spawn();
  20. void Activate( void );
  21. // Set the times it fades out at.
  22. void SetDensity( float density );
  23. private:
  24. CNetworkVar( color32, m_Color1 );
  25. CNetworkVar( color32, m_Color2 );
  26. CNetworkString( m_MaterialName, 255 );
  27. string_t m_String_tMaterialName;
  28. CNetworkVar( float, m_ParticleDrawWidth );
  29. CNetworkVar( float, m_ParticleSpacingDistance );
  30. CNetworkVar( float, m_DensityRampSpeed );
  31. CNetworkVar( float, m_RotationSpeed );
  32. CNetworkVar( float, m_MovementSpeed );
  33. CNetworkVar( float, m_Density );
  34. CNetworkVar( float, m_maxDrawDistance );
  35. };
  36. BEGIN_DATADESC( CFuncSmokeVolume )
  37. // Save/restore Keyvalue fields
  38. DEFINE_KEYFIELD( m_Color1, FIELD_COLOR32, "Color1" ),
  39. DEFINE_KEYFIELD( m_Color2, FIELD_COLOR32, "Color2" ),
  40. // DEFINE_ARRAY( m_MaterialName, FIELD_STRING, 255 ),
  41. DEFINE_KEYFIELD( m_String_tMaterialName, FIELD_STRING, "Material" ),
  42. DEFINE_KEYFIELD( m_ParticleDrawWidth, FIELD_FLOAT, "ParticleDrawWidth" ),
  43. DEFINE_KEYFIELD( m_ParticleSpacingDistance, FIELD_FLOAT, "ParticleSpacingDistance" ),
  44. DEFINE_KEYFIELD( m_DensityRampSpeed, FIELD_FLOAT, "DensityRampSpeed" ),
  45. DEFINE_KEYFIELD( m_RotationSpeed, FIELD_FLOAT, "RotationSpeed" ),
  46. DEFINE_KEYFIELD( m_MovementSpeed, FIELD_FLOAT, "MovementSpeed" ),
  47. DEFINE_KEYFIELD( m_Density, FIELD_FLOAT, "Density" ),
  48. DEFINE_KEYFIELD( m_maxDrawDistance, FIELD_FLOAT, "MaxDrawDistance" ),
  49. // inputs
  50. DEFINE_INPUT( m_RotationSpeed, FIELD_FLOAT, "SetRotationSpeed"),
  51. DEFINE_INPUT( m_MovementSpeed, FIELD_FLOAT, "SetMovementSpeed"),
  52. DEFINE_INPUT( m_Density, FIELD_FLOAT, "SetDensity"),
  53. END_DATADESC()
  54. IMPLEMENT_SERVERCLASS_ST( CFuncSmokeVolume, DT_FuncSmokeVolume )
  55. SendPropInt( SENDINFO( m_Color1 ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
  56. SendPropInt( SENDINFO( m_Color2 ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt32 ),
  57. SendPropString( SENDINFO( m_MaterialName ) ),
  58. SendPropFloat( SENDINFO( m_ParticleDrawWidth ), 0, SPROP_NOSCALE ),
  59. SendPropFloat( SENDINFO( m_ParticleSpacingDistance ), 0, SPROP_NOSCALE ),
  60. SendPropFloat( SENDINFO( m_DensityRampSpeed ), 0, SPROP_NOSCALE ),
  61. SendPropFloat( SENDINFO( m_RotationSpeed ), 0, SPROP_NOSCALE ),
  62. SendPropFloat( SENDINFO( m_MovementSpeed ), 0, SPROP_NOSCALE ),
  63. SendPropFloat( SENDINFO( m_Density ), 0, SPROP_NOSCALE ),
  64. SendPropFloat( SENDINFO( m_maxDrawDistance ), 0, SPROP_NOSCALE ),
  65. SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED )
  66. END_SEND_TABLE()
  67. LINK_ENTITY_TO_CLASS( func_smokevolume, CFuncSmokeVolume );
  68. CFuncSmokeVolume::CFuncSmokeVolume()
  69. {
  70. m_Density = 1.0f;
  71. m_maxDrawDistance = 0.0f;
  72. }
  73. void CFuncSmokeVolume::SetDensity( float density )
  74. {
  75. m_Density = density;
  76. }
  77. void CFuncSmokeVolume::Spawn()
  78. {
  79. memset( m_MaterialName.GetForModify(), 0, sizeof( m_MaterialName ) );
  80. // Bind to our bmodel.
  81. SetModel( STRING( GetModelName() ) );
  82. BaseClass::Spawn();
  83. }
  84. void CFuncSmokeVolume::Activate( void )
  85. {
  86. BaseClass::Activate();
  87. Q_strncpy( m_MaterialName.GetForModify(), STRING( m_String_tMaterialName ), 255 );
  88. }