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.

129 lines
3.8 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. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. extern short g_sModelIndexSmoke; // (in combatweapon.cpp) holds the index for the smoke cloud
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Dispatches Sprite tempentity
  20. //-----------------------------------------------------------------------------
  21. class CTEGlowSprite : public CBaseTempEntity
  22. {
  23. public:
  24. DECLARE_CLASS( CTEGlowSprite, CBaseTempEntity );
  25. CTEGlowSprite( const char *name );
  26. virtual ~CTEGlowSprite( void );
  27. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  28. DECLARE_SERVERCLASS();
  29. public:
  30. CNetworkVector( m_vecOrigin );
  31. CNetworkVar( int, m_nModelIndex );
  32. CNetworkVar( float, m_fScale );
  33. CNetworkVar( float, m_fLife );
  34. CNetworkVar( int, m_nBrightness );
  35. };
  36. //-----------------------------------------------------------------------------
  37. // Purpose:
  38. // Input : *name -
  39. //-----------------------------------------------------------------------------
  40. CTEGlowSprite::CTEGlowSprite( const char *name ) :
  41. CBaseTempEntity( name )
  42. {
  43. m_vecOrigin.Init();
  44. m_nModelIndex = 0;
  45. m_fScale = 0;
  46. m_fLife = 0;
  47. m_nBrightness = 0;
  48. }
  49. //-----------------------------------------------------------------------------
  50. // Purpose:
  51. //-----------------------------------------------------------------------------
  52. CTEGlowSprite::~CTEGlowSprite( void )
  53. {
  54. }
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. // Input : *current_origin -
  58. // *current_angles -
  59. //-----------------------------------------------------------------------------
  60. void CTEGlowSprite::Test( const Vector& current_origin, const QAngle& current_angles )
  61. {
  62. // Fill in data
  63. m_nModelIndex = g_sModelIndexSmoke;
  64. m_fScale = 0.8;
  65. m_nBrightness = 200;
  66. m_fLife = 2.0;
  67. m_vecOrigin = current_origin;
  68. Vector forward, right;
  69. m_vecOrigin.GetForModify()[2] += 24;
  70. AngleVectors( current_angles, &forward, &right, NULL );
  71. forward[2] = 0.0;
  72. VectorNormalize( forward );
  73. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  74. VectorMA( m_vecOrigin, -25.0, right, m_vecOrigin.GetForModify() );
  75. CBroadcastRecipientFilter filter;
  76. Create( filter, 0.0 );
  77. }
  78. IMPLEMENT_SERVERCLASS_ST(CTEGlowSprite, DT_TEGlowSprite)
  79. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  80. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  81. SendPropFloat( SENDINFO(m_fScale ), 8, SPROP_ROUNDDOWN, 0.0, 25.6 ),
  82. SendPropFloat( SENDINFO(m_fLife ), 8, SPROP_ROUNDDOWN, 0.0, 25.6 ),
  83. SendPropInt( SENDINFO(m_nBrightness), 8, SPROP_UNSIGNED ),
  84. END_SEND_TABLE()
  85. // Singleton to fire TEGlowSprite objects
  86. static CTEGlowSprite g_TEGlowSprite( "GlowSprite" );
  87. //-----------------------------------------------------------------------------
  88. // Purpose:
  89. // Input : msg_dest -
  90. // delay -
  91. // *origin -
  92. // *recipient -
  93. // *pos -
  94. // modelindex -
  95. // life -
  96. // size -
  97. // brightness -
  98. //-----------------------------------------------------------------------------
  99. void TE_GlowSprite( IRecipientFilter& filter, float delay,
  100. const Vector* pos, int modelindex, float life, float size, int brightness )
  101. {
  102. g_TEGlowSprite.m_vecOrigin = *pos;
  103. g_TEGlowSprite.m_nModelIndex = modelindex;
  104. g_TEGlowSprite.m_fLife = life;
  105. g_TEGlowSprite.m_fScale = size;
  106. g_TEGlowSprite.m_nBrightness = brightness;
  107. // Send it over the wire
  108. g_TEGlowSprite.Create( filter, delay );
  109. }