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.

131 lines
3.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 "basetempentity.h"
  15. // memdbgon must be the last include file in a .cpp file!!!
  16. #include "tier0/memdbgon.h"
  17. //-----------------------------------------------------------------------------
  18. // Purpose: Dispatches decal tempentity
  19. //-----------------------------------------------------------------------------
  20. class CTEDecal : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTEDecal, CBaseTempEntity );
  24. CTEDecal( const char *name );
  25. virtual ~CTEDecal( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVector( m_vecOrigin );
  30. CNetworkVector( m_vecStart );
  31. CNetworkVar( int, m_nEntity );
  32. CNetworkVar( int, m_nHitbox );
  33. CNetworkVar( int, m_nIndex );
  34. };
  35. //-----------------------------------------------------------------------------
  36. // Purpose:
  37. // Input : *name -
  38. //-----------------------------------------------------------------------------
  39. CTEDecal::CTEDecal( const char *name ) :
  40. CBaseTempEntity( name )
  41. {
  42. m_vecOrigin.Init();
  43. m_nEntity = 0;
  44. m_nIndex = 0;
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose:
  48. //-----------------------------------------------------------------------------
  49. CTEDecal::~CTEDecal( void )
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. // Input : *current_origin -
  55. // *current_angles -
  56. //-----------------------------------------------------------------------------
  57. void CTEDecal::Test( const Vector& current_origin, const QAngle& current_angles )
  58. {
  59. // Fill in data
  60. m_nEntity = 0;
  61. m_nIndex = 0;
  62. m_vecOrigin = current_origin;
  63. Vector vecEnd;
  64. Vector forward;
  65. m_vecOrigin.GetForModify()[2] += 24;
  66. AngleVectors( current_angles, &forward );
  67. forward[2] = 0.0;
  68. VectorNormalize( forward );
  69. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  70. VectorMA( m_vecOrigin, 1024.0, forward, vecEnd );
  71. trace_t tr;
  72. UTIL_TraceLine( m_vecOrigin, vecEnd, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr );
  73. m_vecOrigin = tr.endpos;
  74. CBroadcastRecipientFilter filter;
  75. Create( filter, 0.0 );
  76. }
  77. IMPLEMENT_SERVERCLASS_ST(CTEDecal, DT_TEDecal)
  78. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  79. SendPropVector( SENDINFO(m_vecStart), -1, SPROP_COORD),
  80. SendPropInt( SENDINFO(m_nEntity), MAX_EDICT_BITS, SPROP_UNSIGNED ),
  81. SendPropInt( SENDINFO(m_nHitbox), 16, SPROP_UNSIGNED ), // this is the max number of static props that can be decalled
  82. SendPropInt( SENDINFO(m_nIndex), 9, SPROP_UNSIGNED ),
  83. END_SEND_TABLE()
  84. // Singleton to fire TEDecal objects
  85. static CTEDecal g_TEDecal( "Entity Decal" );
  86. //-----------------------------------------------------------------------------
  87. // Purpose:
  88. // Input : msg_dest -
  89. // delay -
  90. // *origin -
  91. // *recipient -
  92. // *pos -
  93. // entity -
  94. // index -
  95. //-----------------------------------------------------------------------------
  96. void TE_Decal( IRecipientFilter& filter, float delay,
  97. const Vector* pos, const Vector* start, int entity, int hitbox, int index )
  98. {
  99. Assert( pos && start );
  100. g_TEDecal.m_vecOrigin = *pos;
  101. g_TEDecal.m_vecStart = *start;
  102. g_TEDecal.m_nEntity = entity;
  103. g_TEDecal.m_nHitbox = hitbox;
  104. g_TEDecal.m_nIndex = index;
  105. // Send it over the wire
  106. g_TEDecal.Create( filter, delay );
  107. }