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.

112 lines
3.2 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. //
  8. //-----------------------------------------------------------------------------
  9. // $Log: $
  10. //
  11. // $NoKeywords: $
  12. //=============================================================================//
  13. #include "cbase.h"
  14. #include "te_particlesystem.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Dispatches energy splashes
  19. //-----------------------------------------------------------------------------
  20. class CTEEnergySplash : public CBaseTempEntity
  21. {
  22. DECLARE_CLASS( CTEEnergySplash, CBaseTempEntity );
  23. public:
  24. CTEEnergySplash( const char *name );
  25. virtual ~CTEEnergySplash( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVector( m_vecPos );
  30. CNetworkVector( m_vecDir );
  31. CNetworkVar( bool, m_bExplosive );
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Purpose:
  35. // Input : *name -
  36. //-----------------------------------------------------------------------------
  37. CTEEnergySplash::CTEEnergySplash( const char *name ) :
  38. CBaseTempEntity( name )
  39. {
  40. m_vecPos.Init();
  41. m_vecDir.Init();
  42. m_bExplosive = false;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. CTEEnergySplash::~CTEEnergySplash( void )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. // Input : *current_origin -
  53. // *current_angles -
  54. //-----------------------------------------------------------------------------
  55. void CTEEnergySplash::Test( const Vector& current_origin, const QAngle& current_angles )
  56. {
  57. // Fill in data
  58. m_vecPos = current_origin;
  59. AngleVectors( current_angles, &m_vecDir.GetForModify() );
  60. Vector forward;
  61. m_vecPos.GetForModify()[2] += 24;
  62. forward = m_vecDir;
  63. forward[2] = 0.0;
  64. VectorNormalize( forward );
  65. VectorMA( m_vecPos, 100.0, forward, m_vecPos.GetForModify() );
  66. CBroadcastRecipientFilter filter;
  67. Create( filter, 0.0 );
  68. }
  69. IMPLEMENT_SERVERCLASS_ST_NOBASE( CTEEnergySplash, DT_TEEnergySplash)
  70. SendPropVector( SENDINFO(m_vecPos), -1, SPROP_COORD),
  71. SendPropVector( SENDINFO(m_vecDir), -1, SPROP_COORD),
  72. SendPropInt( SENDINFO(m_bExplosive), 1, SPROP_UNSIGNED),
  73. END_SEND_TABLE()
  74. // Singleton to fire TEEnergySplash objects
  75. static CTEEnergySplash g_TEEnergySplash( "Energy Splash" );
  76. //-----------------------------------------------------------------------------
  77. // Purpose:
  78. // Input : msg_dest -
  79. // delay -
  80. // *origin -
  81. // *recipient -
  82. // *pos -
  83. // scale -
  84. //-----------------------------------------------------------------------------
  85. void TE_EnergySplash( IRecipientFilter& filter, float delay,
  86. const Vector* pos, const Vector* dir, bool bExplosive )
  87. {
  88. g_TEEnergySplash.m_vecPos = *pos;
  89. g_TEEnergySplash.m_vecDir = *dir;
  90. g_TEEnergySplash.m_bExplosive = bExplosive;
  91. // Send it over the wire
  92. g_TEEnergySplash.Create( filter, delay );
  93. }