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 "c_te_particlesystem.h"
  9. #include "IEffects.h"
  10. #include "tier1/KeyValues.h"
  11. #include "toolframework_client.h"
  12. // memdbgon must be the last include file in a .cpp file!!!
  13. #include "tier0/memdbgon.h"
  14. //-----------------------------------------------------------------------------
  15. // Purpose: Sparks TE
  16. //-----------------------------------------------------------------------------
  17. class C_TESparks : public C_TEParticleSystem
  18. {
  19. public:
  20. DECLARE_CLASS( C_TESparks, C_TEParticleSystem );
  21. DECLARE_CLIENTCLASS();
  22. C_TESparks( void );
  23. virtual ~C_TESparks( void );
  24. virtual void PostDataUpdate( DataUpdateType_t updateType );
  25. virtual void Precache( void );
  26. int m_nMagnitude;
  27. int m_nTrailLength;
  28. Vector m_vecDir;
  29. };
  30. //-----------------------------------------------------------------------------
  31. // Purpose:
  32. //-----------------------------------------------------------------------------
  33. C_TESparks::C_TESparks( void )
  34. {
  35. }
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. //-----------------------------------------------------------------------------
  39. C_TESparks::~C_TESparks( void )
  40. {
  41. }
  42. void C_TESparks::Precache( void )
  43. {
  44. }
  45. //-----------------------------------------------------------------------------
  46. // Recording
  47. //-----------------------------------------------------------------------------
  48. static inline void RecordSparks( const Vector &start, int nMagnitude, int nTrailLength, const Vector &direction )
  49. {
  50. if ( !ToolsEnabled() )
  51. return;
  52. if ( clienttools->IsInRecordingMode() )
  53. {
  54. KeyValues *msg = new KeyValues( "TempEntity" );
  55. msg->SetInt( "te", TE_SPARKS );
  56. msg->SetString( "name", "TE_Sparks" );
  57. msg->SetFloat( "time", gpGlobals->curtime );
  58. msg->SetFloat( "originx", start.x );
  59. msg->SetFloat( "originy", start.y );
  60. msg->SetFloat( "originz", start.z );
  61. msg->SetFloat( "directionx", direction.x );
  62. msg->SetFloat( "directiony", direction.y );
  63. msg->SetFloat( "directionz", direction.z );
  64. msg->SetInt( "magnitude", nMagnitude );
  65. msg->SetInt( "traillength", nTrailLength );
  66. ToolFramework_PostToolMessage( HTOOLHANDLE_INVALID, msg );
  67. msg->deleteThis();
  68. }
  69. }
  70. //-----------------------------------------------------------------------------
  71. // Purpose:
  72. //-----------------------------------------------------------------------------
  73. void C_TESparks::PostDataUpdate( DataUpdateType_t updateType )
  74. {
  75. g_pEffects->Sparks( m_vecOrigin, m_nMagnitude, m_nTrailLength, &m_vecDir );
  76. RecordSparks( m_vecOrigin, m_nMagnitude, m_nTrailLength, m_vecDir );
  77. }
  78. void TE_Sparks( IRecipientFilter& filter, float delay,
  79. const Vector* pos, int nMagnitude, int nTrailLength, const Vector *pDir )
  80. {
  81. g_pEffects->Sparks( *pos, nMagnitude, nTrailLength, pDir );
  82. RecordSparks( *pos, nMagnitude, nTrailLength, *pDir );
  83. }
  84. IMPLEMENT_CLIENTCLASS_EVENT_DT(C_TESparks, DT_TESparks, CTESparks)
  85. RecvPropInt( RECVINFO( m_nMagnitude ) ),
  86. RecvPropInt( RECVINFO( m_nTrailLength ) ),
  87. RecvPropVector( RECVINFO( m_vecDir ) ),
  88. END_RECV_TABLE()