Counter Strike : Global Offensive Source Code
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.

134 lines
3.6 KiB

  1. //========= Copyright � 1996-2005, 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. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. #define MAX_SPLINE_POINTS 16
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Dispatches beam spline tempentity
  20. //-----------------------------------------------------------------------------
  21. class CTEBeamSpline : public CBaseTempEntity
  22. {
  23. public:
  24. DECLARE_CLASS( CTEBeamSpline, CBaseTempEntity );
  25. CTEBeamSpline( const char *name );
  26. virtual ~CTEBeamSpline( void );
  27. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  28. DECLARE_SERVERCLASS();
  29. public:
  30. CNetworkArray( Vector, m_vecPoints, MAX_SPLINE_POINTS );
  31. CNetworkVar( int, m_nPoints );
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Purpose:
  35. // Input : *name -
  36. //-----------------------------------------------------------------------------
  37. CTEBeamSpline::CTEBeamSpline( const char *name ) :
  38. CBaseTempEntity( name )
  39. {
  40. int i;
  41. for ( i = 0; i < MAX_SPLINE_POINTS; i++ )
  42. {
  43. m_vecPoints.GetForModify( i ).Init();
  44. }
  45. m_nPoints = 0;
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. CTEBeamSpline::~CTEBeamSpline( void )
  51. {
  52. }
  53. //-----------------------------------------------------------------------------
  54. // Purpose:
  55. // Input : *current_origin -
  56. // *current_angles -
  57. //-----------------------------------------------------------------------------
  58. void CTEBeamSpline::Test( const Vector& current_origin, const QAngle& current_angles )
  59. {
  60. // Fill in data
  61. m_nPoints = 6;
  62. Vector m_vecStart = current_origin;
  63. Vector forward, right;
  64. m_vecStart[2] += 24;
  65. AngleVectors( current_angles, &forward, &right, 0 );
  66. forward[2] = 0.0;
  67. VectorNormalize( forward );
  68. VectorMA( m_vecStart, 100.0, forward, m_vecStart );
  69. VectorMA( m_vecStart, -128.0, right, m_vecStart );
  70. for ( int i = 0; i < m_nPoints; i++ )
  71. {
  72. m_vecPoints.Set( i, m_vecStart );
  73. VectorMA( m_vecStart, 128/m_nPoints, right, m_vecStart );
  74. VectorMA( m_vecStart, 30.0/m_nPoints, forward, m_vecStart );
  75. }
  76. CBroadcastRecipientFilter filter;
  77. Create( filter, 0.0 );
  78. }
  79. IMPLEMENT_SERVERCLASS_ST_NOBASE(CTEBeamSpline, DT_TEBeamSpline)
  80. SendPropInt( SENDINFO( m_nPoints ), 5, SPROP_UNSIGNED ),
  81. SendPropArray(
  82. SendPropVector( SENDINFO_ARRAY(m_vecPoints), -1, SPROP_COORD),
  83. m_vecPoints)
  84. END_SEND_TABLE()
  85. // Singleton to fire TEBeamSpline objects
  86. static CTEBeamSpline g_TEBeamSpline( "BeamSpline" );
  87. //-----------------------------------------------------------------------------
  88. // Purpose:
  89. // Input : msg_dest -
  90. // delay -
  91. // *origin -
  92. // *recipient -
  93. // points -
  94. // *points -
  95. //-----------------------------------------------------------------------------
  96. void TE_BeamSpline( IRecipientFilter& filter, float delay,
  97. int points, Vector* rgPoints )
  98. {
  99. int i;
  100. g_TEBeamSpline.m_nPoints = points;
  101. for ( i = 0; i < points; i++ )
  102. {
  103. g_TEBeamSpline.m_vecPoints.Set( i, rgPoints[ i ] );
  104. }
  105. for ( ; i < MAX_SPLINE_POINTS; i++ )
  106. {
  107. g_TEBeamSpline.m_vecPoints.GetForModify( i ).Init();
  108. }
  109. // Send it over the wire
  110. g_TEBeamSpline.Create( filter, delay );
  111. }