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.3 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 world decal tempentity
  19. //-----------------------------------------------------------------------------
  20. class CTEWorldDecal : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTEWorldDecal, CBaseTempEntity );
  24. CTEWorldDecal( const char *name );
  25. virtual ~CTEWorldDecal( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVector( m_vecOrigin );
  30. CNetworkVar( int, m_nIndex );
  31. };
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. // Input : *name -
  35. //-----------------------------------------------------------------------------
  36. CTEWorldDecal::CTEWorldDecal( const char *name ) :
  37. CBaseTempEntity( name )
  38. {
  39. m_vecOrigin.Init();
  40. m_nIndex = 0;
  41. }
  42. //-----------------------------------------------------------------------------
  43. // Purpose:
  44. //-----------------------------------------------------------------------------
  45. CTEWorldDecal::~CTEWorldDecal( void )
  46. {
  47. }
  48. //-----------------------------------------------------------------------------
  49. // Purpose:
  50. // Input : *current_origin -
  51. // *current_angles -
  52. //-----------------------------------------------------------------------------
  53. void CTEWorldDecal::Test( const Vector& current_origin, const QAngle& current_angles )
  54. {
  55. // Fill in data
  56. m_nIndex = 0;
  57. m_vecOrigin = current_origin;
  58. Vector vecEnd;
  59. Vector forward;
  60. m_vecOrigin.GetForModify()[2] += 24;
  61. AngleVectors( current_angles, &forward );
  62. forward[2] = 0.0;
  63. VectorNormalize( forward );
  64. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  65. VectorMA( m_vecOrigin, 1024.0, forward, vecEnd );
  66. trace_t tr;
  67. UTIL_TraceLine( m_vecOrigin, vecEnd, MASK_SOLID_BRUSHONLY, NULL, COLLISION_GROUP_NONE, &tr );
  68. m_vecOrigin = tr.endpos;
  69. CBroadcastRecipientFilter filter;
  70. Create( filter, 0.0 );
  71. }
  72. IMPLEMENT_SERVERCLASS_ST(CTEWorldDecal, DT_TEWorldDecal)
  73. #if defined( TF_DLL )
  74. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD_MP_INTEGRAL ),
  75. #else
  76. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  77. #endif
  78. SendPropInt( SENDINFO(m_nIndex), 9, SPROP_UNSIGNED ),
  79. END_SEND_TABLE()
  80. // Singleton to fire TEWorldDecal objects
  81. static CTEWorldDecal g_TEWorldDecal( "World Decal" );
  82. //-----------------------------------------------------------------------------
  83. // Purpose:
  84. // Input : msg_dest -
  85. // delay -
  86. // *origin -
  87. // *recipient -
  88. // *pos -
  89. // index -
  90. //-----------------------------------------------------------------------------
  91. void TE_WorldDecal( IRecipientFilter& filter, float delay,
  92. const Vector* pos, int index )
  93. {
  94. g_TEWorldDecal.m_vecOrigin = *pos;
  95. g_TEWorldDecal.m_nIndex = index;
  96. // Send it over the wire
  97. g_TEWorldDecal.Create( filter, delay );
  98. }