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.

143 lines
4.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 "basetempentity.h"
  15. #include "te_basebeam.h"
  16. // memdbgon must be the last include file in a .cpp file!!!
  17. #include "tier0/memdbgon.h"
  18. extern short g_sModelIndexSmoke; // (in combatweapon.cpp) holds the index for the smoke cloud
  19. //-----------------------------------------------------------------------------
  20. // Purpose: Dispatches a beam ring between two entities
  21. //-----------------------------------------------------------------------------
  22. class CTEBeamPoints : public CTEBaseBeam
  23. {
  24. public:
  25. DECLARE_CLASS( CTEBeamPoints, CTEBaseBeam );
  26. DECLARE_SERVERCLASS();
  27. CTEBeamPoints( const char *name );
  28. virtual ~CTEBeamPoints( void );
  29. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  30. public:
  31. CNetworkVector( m_vecStartPoint );
  32. CNetworkVector( m_vecEndPoint );
  33. };
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. // Input : *name -
  37. //-----------------------------------------------------------------------------
  38. CTEBeamPoints::CTEBeamPoints( const char *name ) :
  39. CTEBaseBeam( name )
  40. {
  41. m_vecStartPoint.Init();
  42. m_vecEndPoint.Init();
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. CTEBeamPoints::~CTEBeamPoints( void )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. // Input : *current_origin -
  53. // *current_angles -
  54. //-----------------------------------------------------------------------------
  55. void CTEBeamPoints::Test( const Vector& current_origin, const QAngle& current_angles )
  56. {
  57. m_nModelIndex = g_sModelIndexSmoke;
  58. m_nStartFrame = 0;
  59. m_nFrameRate = 10;
  60. m_fLife = 2.0;
  61. m_fWidth = 1.0;
  62. m_fAmplitude = 1;
  63. r = 0;
  64. g = 63;
  65. b = 127;
  66. a = 150;
  67. m_nSpeed = 1;
  68. m_vecStartPoint = current_origin;
  69. Vector forward, right;
  70. m_vecStartPoint += Vector( 0, 0, 30 );
  71. AngleVectors( current_angles, &forward, &right, 0 );
  72. forward[2] = 0.0;
  73. VectorNormalize( forward );
  74. VectorMA( m_vecStartPoint, 75.0, forward, m_vecStartPoint.GetForModify() );
  75. VectorMA( m_vecStartPoint, 25.0, right, m_vecEndPoint.GetForModify() );
  76. VectorMA( m_vecStartPoint, -25.0, right, m_vecStartPoint.GetForModify() );
  77. CBroadcastRecipientFilter filter;
  78. Create( filter, 0.0 );
  79. }
  80. IMPLEMENT_SERVERCLASS_ST( CTEBeamPoints, DT_TEBeamPoints)
  81. SendPropVector( SENDINFO(m_vecStartPoint), -1, SPROP_COORD ),
  82. SendPropVector( SENDINFO(m_vecEndPoint), -1, SPROP_COORD ),
  83. END_SEND_TABLE()
  84. // Singleton to fire TEBeamPoints objects
  85. static CTEBeamPoints g_TEBeamPoints( "BeamPoints" );
  86. //-----------------------------------------------------------------------------
  87. // Purpose:
  88. // Input : msg_dest -
  89. // delay -
  90. // *origin -
  91. // *recipient -
  92. // *start -
  93. // *end -
  94. // modelindex -
  95. // startframe -
  96. // framerate -
  97. // msg_dest -
  98. // delay -
  99. // origin -
  100. // recipient -
  101. //-----------------------------------------------------------------------------
  102. void TE_BeamPoints( IRecipientFilter& filter, float delay,
  103. const Vector* start, const Vector* end, int modelindex, int haloindex, int startframe, int framerate,
  104. float life, float width, float endWidth, int fadeLength, float amplitude, int r, int g, int b, int a, int speed )
  105. {
  106. g_TEBeamPoints.m_vecStartPoint = *start;
  107. g_TEBeamPoints.m_vecEndPoint = *end;
  108. g_TEBeamPoints.m_nModelIndex = modelindex;
  109. g_TEBeamPoints.m_nHaloIndex = haloindex;
  110. g_TEBeamPoints.m_nStartFrame = startframe;
  111. g_TEBeamPoints.m_nFrameRate = framerate;
  112. g_TEBeamPoints.m_fLife = life;
  113. g_TEBeamPoints.m_fWidth = width;
  114. g_TEBeamPoints.m_fEndWidth = endWidth;
  115. g_TEBeamPoints.m_nFadeLength = fadeLength;
  116. g_TEBeamPoints.m_fAmplitude = amplitude;
  117. g_TEBeamPoints.m_nSpeed = speed;
  118. g_TEBeamPoints.r = r;
  119. g_TEBeamPoints.g = g;
  120. g_TEBeamPoints.b = b;
  121. g_TEBeamPoints.a = a;
  122. // Send it over the wire
  123. g_TEBeamPoints.Create( filter, delay );
  124. }