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.

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