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.

109 lines
2.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 "c_te_particlesystem.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Show Line TE
  19. //-----------------------------------------------------------------------------
  20. class C_TEShowLine : public C_TEParticleSystem
  21. {
  22. public:
  23. DECLARE_CLASS( C_TEShowLine, C_TEParticleSystem );
  24. DECLARE_CLIENTCLASS();
  25. C_TEShowLine( void );
  26. virtual ~C_TEShowLine( void );
  27. virtual void PostDataUpdate( DataUpdateType_t updateType );
  28. public:
  29. Vector m_vecEnd;
  30. };
  31. //-----------------------------------------------------------------------------
  32. // Purpose:
  33. //-----------------------------------------------------------------------------
  34. C_TEShowLine::C_TEShowLine( void )
  35. {
  36. m_vecEnd.Init();
  37. }
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. //-----------------------------------------------------------------------------
  41. C_TEShowLine::~C_TEShowLine( void )
  42. {
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. // Input : bool -
  47. //-----------------------------------------------------------------------------
  48. void C_TEShowLine::PostDataUpdate( DataUpdateType_t updateType )
  49. {
  50. Vector vec;
  51. float len;
  52. StandardParticle_t *p;
  53. int dec;
  54. static int tracercount;
  55. VectorSubtract (m_vecEnd, m_vecOrigin, vec);
  56. len = VectorNormalize (vec);
  57. dec = 3;
  58. VectorScale(vec, dec, vec);
  59. CSmartPtr<CTEParticleRenderer> pRen = CTEParticleRenderer::Create( "TEShowLine", m_vecOrigin );
  60. if( !pRen )
  61. return;
  62. while (len > 0)
  63. {
  64. len -= dec;
  65. p = pRen->AddParticle();
  66. if ( p )
  67. {
  68. p->m_Velocity.Init();
  69. pRen->SetParticleLifetime(p, 30);
  70. p->SetColor(0, 1, 1);
  71. p->SetAlpha(1);
  72. pRen->SetParticleType(p, pt_static);
  73. p->m_Pos = m_vecOrigin;
  74. m_vecOrigin += vec;
  75. }
  76. }
  77. }
  78. IMPLEMENT_CLIENTCLASS_EVENT_DT(C_TEShowLine, DT_TEShowLine, CTEShowLine)
  79. RecvPropVector( RECVINFO(m_vecEnd)),
  80. END_RECV_TABLE()
  81. void TE_ShowLine( IRecipientFilter& filter, float delay,
  82. const Vector* start, const Vector* end )
  83. {
  84. // Major hack to simulate receiving network message
  85. __g_C_TEShowLine.m_vecOrigin = *start;
  86. __g_C_TEShowLine.m_vecEnd = *end;
  87. __g_C_TEShowLine.PostDataUpdate( DATA_UPDATE_CREATED );
  88. }