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.

105 lines
3.2 KiB

  1. //========= Copyright 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. };
  35. BEGIN_DATADESC( CFuncSmokeVolume )
  36. // Save/restore Keyvalue fields
  37. DEFINE_KEYFIELD( m_Color1, FIELD_COLOR32, "Color1" ),
  38. DEFINE_KEYFIELD( m_Color2, FIELD_COLOR32, "Color2" ),
  39. // DEFINE_ARRAY( m_MaterialName, FIELD_STRING, 255 ),
  40. DEFINE_KEYFIELD( m_String_tMaterialName, FIELD_STRING, "Material" ),
  41. DEFINE_KEYFIELD( m_ParticleDrawWidth, FIELD_FLOAT, "ParticleDrawWidth" ),
  42. DEFINE_KEYFIELD( m_ParticleSpacingDistance, FIELD_FLOAT, "ParticleSpacingDistance" ),
  43. DEFINE_KEYFIELD( m_DensityRampSpeed, FIELD_FLOAT, "DensityRampSpeed" ),
  44. DEFINE_KEYFIELD( m_RotationSpeed, FIELD_FLOAT, "RotationSpeed" ),
  45. DEFINE_KEYFIELD( m_MovementSpeed, FIELD_FLOAT, "MovementSpeed" ),
  46. DEFINE_KEYFIELD( m_Density, FIELD_FLOAT, "Density" ),
  47. // inputs
  48. DEFINE_INPUT( m_RotationSpeed, FIELD_FLOAT, "SetRotationSpeed"),
  49. DEFINE_INPUT( m_MovementSpeed, FIELD_FLOAT, "SetMovementSpeed"),
  50. DEFINE_INPUT( m_Density, FIELD_FLOAT, "SetDensity"),
  51. END_DATADESC()
  52. IMPLEMENT_SERVERCLASS_ST( CFuncSmokeVolume, DT_FuncSmokeVolume )
  53. SendPropInt( SENDINFO( m_Color1 ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ),
  54. SendPropInt( SENDINFO( m_Color2 ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ),
  55. SendPropString( SENDINFO( m_MaterialName ) ),
  56. SendPropFloat( SENDINFO( m_ParticleDrawWidth ), 0, SPROP_NOSCALE ),
  57. SendPropFloat( SENDINFO( m_ParticleSpacingDistance ), 0, SPROP_NOSCALE ),
  58. SendPropFloat( SENDINFO( m_DensityRampSpeed ), 0, SPROP_NOSCALE ),
  59. SendPropFloat( SENDINFO( m_RotationSpeed ), 0, SPROP_NOSCALE ),
  60. SendPropFloat( SENDINFO( m_MovementSpeed ), 0, SPROP_NOSCALE ),
  61. SendPropFloat( SENDINFO( m_Density ), 0, SPROP_NOSCALE ),
  62. SendPropInt( SENDINFO(m_spawnflags), 8, SPROP_UNSIGNED )
  63. END_SEND_TABLE()
  64. LINK_ENTITY_TO_CLASS( func_smokevolume, CFuncSmokeVolume );
  65. CFuncSmokeVolume::CFuncSmokeVolume()
  66. {
  67. m_Density = 1.0f;
  68. }
  69. void CFuncSmokeVolume::SetDensity( float density )
  70. {
  71. m_Density = density;
  72. }
  73. void CFuncSmokeVolume::Spawn()
  74. {
  75. memset( m_MaterialName.GetForModify(), 0, sizeof( m_MaterialName ) );
  76. // Bind to our bmodel.
  77. SetModel( STRING( GetModelName() ) );
  78. BaseClass::Spawn();
  79. }
  80. void CFuncSmokeVolume::Activate( void )
  81. {
  82. BaseClass::Activate();
  83. Q_strncpy( m_MaterialName.GetForModify(), STRING( m_String_tMaterialName ), 255 );
  84. }