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.

101 lines
2.7 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "te_particlesystem.h"
  9. // memdbgon must be the last include file in a .cpp file!!!
  10. #include "tier0/memdbgon.h"
  11. //-----------------------------------------------------------------------------
  12. // Purpose: Dispatches sparks
  13. //-----------------------------------------------------------------------------
  14. class CTESparks : public CTEParticleSystem
  15. {
  16. public:
  17. DECLARE_CLASS( CTESparks, CTEParticleSystem );
  18. DECLARE_SERVERCLASS();
  19. CTESparks( const char *name );
  20. virtual ~CTESparks( void );
  21. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  22. CNetworkVar( int, m_nMagnitude );
  23. CNetworkVar( int, m_nTrailLength );
  24. CNetworkVector( m_vecDir );
  25. };
  26. //-----------------------------------------------------------------------------
  27. // Purpose:
  28. // Input : *name -
  29. //-----------------------------------------------------------------------------
  30. CTESparks::CTESparks( const char *name ) :
  31. BaseClass( name )
  32. {
  33. }
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. //-----------------------------------------------------------------------------
  37. CTESparks::~CTESparks( void )
  38. {
  39. }
  40. //-----------------------------------------------------------------------------
  41. // Purpose:
  42. // Input : *current_origin -
  43. // *current_angles -
  44. //-----------------------------------------------------------------------------
  45. void CTESparks::Test( const Vector& current_origin, const QAngle& current_angles )
  46. {
  47. // Fill in data
  48. m_vecOrigin = current_origin;
  49. Vector forward;
  50. m_vecOrigin.GetForModify()[2] += 24;
  51. AngleVectors( current_angles, &forward );
  52. forward[2] = 0.0;
  53. VectorNormalize( forward );
  54. m_vecOrigin += forward * 100;
  55. CBroadcastRecipientFilter filter;
  56. Create( filter, 0.0 );
  57. }
  58. IMPLEMENT_SERVERCLASS_ST(CTESparks, DT_TESparks)
  59. SendPropInt( SENDINFO( m_nMagnitude ), 4, SPROP_UNSIGNED ),
  60. SendPropInt( SENDINFO( m_nTrailLength ), 4, SPROP_UNSIGNED ),
  61. SendPropVector( SENDINFO( m_vecDir ), -1, SPROP_COORD ),
  62. END_SEND_TABLE()
  63. // Singleton to fire TESparks objects
  64. static CTESparks g_TESparks( "Sparks" );
  65. void TE_Sparks( IRecipientFilter& filter, float delay,
  66. const Vector *pos, int nMagnitude, int nTrailLength, const Vector *pDir )
  67. {
  68. g_TESparks.m_vecOrigin = *pos;
  69. g_TESparks.m_nMagnitude = nMagnitude;
  70. g_TESparks.m_nTrailLength = nTrailLength;
  71. if ( pDir )
  72. {
  73. g_TESparks.m_vecDir = *pDir;
  74. }
  75. else
  76. {
  77. g_TESparks.m_vecDir = vec3_origin;
  78. }
  79. // Send it over the wire
  80. g_TESparks.Create( filter, delay );
  81. }