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.

140 lines
4.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #include "cbase.h"
  10. #include "basetempentity.h"
  11. // memdbgon must be the last include file in a .cpp file!!!
  12. #include "tier0/memdbgon.h"
  13. extern int g_sModelIndexBubbles;// holds the index for the bubbles model
  14. enum
  15. {
  16. BUBBLE_TRAIL_COUNT_BITS = 8,
  17. BUBBLE_TRAIL_MAX_COUNT = ( (1 << BUBBLE_TRAIL_COUNT_BITS) - 1 ),
  18. };
  19. //-----------------------------------------------------------------------------
  20. // Purpose: Dispatches bubble trail
  21. //-----------------------------------------------------------------------------
  22. class CTEBubbleTrail : public CBaseTempEntity
  23. {
  24. public:
  25. DECLARE_CLASS( CTEBubbleTrail, CBaseTempEntity );
  26. CTEBubbleTrail( const char *name );
  27. virtual ~CTEBubbleTrail( void );
  28. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  29. DECLARE_SERVERCLASS();
  30. public:
  31. CNetworkVector( m_vecMins );
  32. CNetworkVector( m_vecMaxs );
  33. CNetworkVar( float, m_flWaterZ );
  34. CNetworkVar( int, m_nModelIndex );
  35. CNetworkVar( int, m_nCount );
  36. CNetworkVar( float, m_fSpeed );
  37. };
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. // Input : *name -
  41. //-----------------------------------------------------------------------------
  42. CTEBubbleTrail::CTEBubbleTrail( const char *name ) :
  43. CBaseTempEntity( name )
  44. {
  45. m_vecMins.Init();
  46. m_vecMaxs.Init();
  47. m_flWaterZ = 0.0;
  48. m_nModelIndex = 0;
  49. m_nCount = 0;
  50. m_fSpeed = 0;
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. //-----------------------------------------------------------------------------
  55. CTEBubbleTrail::~CTEBubbleTrail( void )
  56. {
  57. }
  58. //-----------------------------------------------------------------------------
  59. // Purpose:
  60. // Input : *current_origin -
  61. // *current_angles -
  62. //-----------------------------------------------------------------------------
  63. void CTEBubbleTrail::Test( const Vector& current_origin, const QAngle& current_angles )
  64. {
  65. // Fill in data
  66. m_vecMins = current_origin;
  67. Vector forward;
  68. m_vecMins.GetForModify()[2] += 24;
  69. AngleVectors( current_angles, &forward );
  70. forward[2] = 0.0;
  71. VectorNormalize( forward );
  72. VectorMA( m_vecMins, 100.0, forward, m_vecMins.GetForModify() );
  73. m_vecMaxs = m_vecMins + Vector( 256, 256, 256 );
  74. m_fSpeed = 8;
  75. m_nCount = 20;
  76. m_flWaterZ = 0;
  77. m_nModelIndex = g_sModelIndexBubbles;
  78. CBroadcastRecipientFilter filter;
  79. Create( filter, 0.0 );
  80. }
  81. IMPLEMENT_SERVERCLASS_ST(CTEBubbleTrail, DT_TEBubbleTrail)
  82. SendPropVector( SENDINFO(m_vecMins), -1, SPROP_COORD),
  83. SendPropVector( SENDINFO(m_vecMaxs), -1, SPROP_COORD),
  84. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  85. SendPropFloat( SENDINFO(m_flWaterZ ), 17, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  86. SendPropInt( SENDINFO(m_nCount), BUBBLE_TRAIL_COUNT_BITS, SPROP_UNSIGNED ),
  87. SendPropFloat( SENDINFO(m_fSpeed ), 17, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  88. END_SEND_TABLE()
  89. // Singleton to fire TEBubbleTrail objects
  90. static CTEBubbleTrail g_TEBubbleTrail( "Bubble Trail" );
  91. //-----------------------------------------------------------------------------
  92. // Purpose:
  93. // Input : msg_dest -
  94. // delay -
  95. // *origin -
  96. // *recipient -
  97. // *mins -
  98. // *maxs -
  99. // height -
  100. // modelindex -
  101. // count -
  102. // speed -
  103. //-----------------------------------------------------------------------------
  104. void TE_BubbleTrail( IRecipientFilter& filter, float delay,
  105. const Vector* mins, const Vector* maxs, float flWaterZ, int modelindex, int count, float speed )
  106. {
  107. g_TEBubbleTrail.m_vecMins = *mins;
  108. g_TEBubbleTrail.m_vecMaxs = *maxs;
  109. g_TEBubbleTrail.m_flWaterZ = flWaterZ;
  110. g_TEBubbleTrail.m_nModelIndex = modelindex;
  111. g_TEBubbleTrail.m_nCount = MIN( count, ( int ) BUBBLE_TRAIL_MAX_COUNT );
  112. g_TEBubbleTrail.m_fSpeed = speed;
  113. // Send it over the wire
  114. g_TEBubbleTrail.Create( filter, delay );
  115. }