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.

121 lines
3.4 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. //-----------------------------------------------------------------------------
  18. // Purpose: Dispatches Sprite tempentity
  19. //-----------------------------------------------------------------------------
  20. class CTESprite : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTESprite, CBaseTempEntity );
  24. CTESprite( const char *name );
  25. virtual ~CTESprite( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. virtual void Precache( void );
  28. DECLARE_SERVERCLASS();
  29. public:
  30. CNetworkVector( m_vecOrigin );
  31. CNetworkVar( int, m_nModelIndex );
  32. CNetworkVar( float, m_fScale );
  33. CNetworkVar( int, m_nBrightness );
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. // Input : *name -
  38. //-----------------------------------------------------------------------------
  39. CTESprite::CTESprite( const char *name ) :
  40. CBaseTempEntity( name )
  41. {
  42. m_vecOrigin.Init();
  43. m_nModelIndex = 0;
  44. m_fScale = 0;
  45. m_nBrightness = 0;
  46. }
  47. //-----------------------------------------------------------------------------
  48. // Purpose:
  49. //-----------------------------------------------------------------------------
  50. CTESprite::~CTESprite( void )
  51. {
  52. }
  53. //-----------------------------------------------------------------------------
  54. // Purpose:
  55. //-----------------------------------------------------------------------------
  56. void CTESprite::Precache( void )
  57. {
  58. CBaseEntity::PrecacheModel("sprites/gunsmoke.vmt");
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose:
  62. // Input : *current_origin -
  63. // *current_angles -
  64. //-----------------------------------------------------------------------------
  65. void CTESprite::Test( const Vector& current_origin, const QAngle& current_angles )
  66. {
  67. // Fill in data
  68. m_nModelIndex = CBaseEntity::PrecacheModel("sprites/gunsmoke.vmt");
  69. m_fScale = 0.8;
  70. m_nBrightness = 200;
  71. m_vecOrigin = current_origin;
  72. Vector forward, right;
  73. m_vecOrigin.GetForModify()[2] += 24;
  74. AngleVectors( current_angles, &forward, &right, NULL );
  75. forward[2] = 0.0;
  76. VectorNormalize( forward );
  77. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  78. VectorMA( m_vecOrigin, -25.0, right, m_vecOrigin.GetForModify() );
  79. CBroadcastRecipientFilter filter;
  80. Create( filter, 0.0 );
  81. }
  82. IMPLEMENT_SERVERCLASS_ST(CTESprite, DT_TESprite)
  83. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  84. SendPropModelIndex( SENDINFO(m_nModelIndex) ),
  85. SendPropFloat( SENDINFO(m_fScale ), 8, SPROP_ROUNDDOWN, 0.0, 25.6 ),
  86. SendPropInt( SENDINFO(m_nBrightness), 8, SPROP_UNSIGNED ),
  87. END_SEND_TABLE()
  88. // Singleton to fire TESprite objects
  89. static CTESprite g_TESprite( "Sprite" );
  90. void TE_Sprite( IRecipientFilter& filter, float delay,
  91. const Vector *pos, int modelindex, float size, int brightness )
  92. {
  93. g_TESprite.m_vecOrigin = *pos;
  94. g_TESprite.m_nModelIndex = modelindex;
  95. g_TESprite.m_fScale = size;
  96. g_TESprite.m_nBrightness = brightness;
  97. // Send it over the wire
  98. g_TESprite.Create( filter, delay );
  99. }