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.

137 lines
3.8 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. extern int g_sModelIndexBubbles;// holds the index for the bubbles model
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Dispatches bubbles
  20. //-----------------------------------------------------------------------------
  21. class CTEBubbles : public CBaseTempEntity
  22. {
  23. public:
  24. DECLARE_CLASS( CTEBubbles, CBaseTempEntity );
  25. CTEBubbles( const char *name );
  26. virtual ~CTEBubbles( void );
  27. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  28. DECLARE_SERVERCLASS();
  29. public:
  30. CNetworkVector( m_vecMins );
  31. CNetworkVector( m_vecMaxs );
  32. CNetworkVar( float, m_fHeight );
  33. CNetworkVar( int, m_nModelIndex );
  34. CNetworkVar( int, m_nCount );
  35. CNetworkVar( float, m_fSpeed );
  36. };
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. // Input : *name -
  40. //-----------------------------------------------------------------------------
  41. CTEBubbles::CTEBubbles( const char *name ) :
  42. CBaseTempEntity( name )
  43. {
  44. m_vecMins.Init();
  45. m_vecMaxs.Init();
  46. m_fHeight = 0.0;
  47. m_nModelIndex = 0;
  48. m_nCount = 0;
  49. m_fSpeed = 0;
  50. }
  51. //-----------------------------------------------------------------------------
  52. // Purpose:
  53. //-----------------------------------------------------------------------------
  54. CTEBubbles::~CTEBubbles( void )
  55. {
  56. }
  57. //-----------------------------------------------------------------------------
  58. // Purpose:
  59. // Input : *current_origin -
  60. // *current_angles -
  61. //-----------------------------------------------------------------------------
  62. void CTEBubbles::Test( const Vector& current_origin, const QAngle& current_angles )
  63. {
  64. // Fill in data
  65. m_vecMins = current_origin;
  66. Vector forward;
  67. m_vecMins.GetForModify()[2] += 24;
  68. AngleVectors( current_angles, &forward );
  69. forward[2] = 0.0;
  70. VectorNormalize( forward );
  71. VectorMA( m_vecMins, 100.0, forward, m_vecMins.GetForModify() );
  72. m_vecMaxs = m_vecMins + Vector( 256, 256, 256 );
  73. m_fSpeed = 2;
  74. m_nCount = 50;
  75. m_fHeight = 256;
  76. m_nModelIndex = g_sModelIndexBubbles;
  77. CBroadcastRecipientFilter filter;
  78. Create( filter, 0.0 );
  79. }
  80. IMPLEMENT_SERVERCLASS_ST(CTEBubbles, DT_TEBubbles)
  81. SendPropVector( SENDINFO(m_vecMins), -1, SPROP_COORD),
  82. SendPropVector( SENDINFO(m_vecMaxs), -1, SPROP_COORD),
  83. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  84. SendPropFloat( SENDINFO(m_fHeight ), 17, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  85. SendPropInt( SENDINFO(m_nCount), 8, SPROP_UNSIGNED ),
  86. SendPropFloat( SENDINFO(m_fSpeed ), 17, 0, MIN_COORD_INTEGER, MAX_COORD_INTEGER ),
  87. END_SEND_TABLE()
  88. // Singleton to fire TEBubbles objects
  89. static CTEBubbles g_TEBubbles( "Bubbles" );
  90. //-----------------------------------------------------------------------------
  91. // Purpose:
  92. // Input : msg_dest -
  93. // delay -
  94. // *origin -
  95. // *recipient -
  96. // *mins -
  97. // *maxs -
  98. // height -
  99. // modelindex -
  100. // count -
  101. // speed -
  102. //-----------------------------------------------------------------------------
  103. void TE_Bubbles( IRecipientFilter& filter, float delay,
  104. const Vector* mins, const Vector* maxs, float height, int modelindex, int count, float speed )
  105. {
  106. g_TEBubbles.m_vecMins = *mins;
  107. g_TEBubbles.m_vecMaxs = *maxs;
  108. g_TEBubbles.m_fHeight = height;
  109. g_TEBubbles.m_nModelIndex = modelindex;
  110. g_TEBubbles.m_nCount = count;
  111. g_TEBubbles.m_fSpeed = speed;
  112. // Send it over the wire
  113. g_TEBubbles.Create( filter, delay );
  114. }