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.

123 lines
3.4 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. //-----------------------------------------------------------------------------
  18. // Purpose: Dispatches decal tempentity
  19. //-----------------------------------------------------------------------------
  20. class CTEPlayerDecal : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTEPlayerDecal, CBaseTempEntity );
  24. CTEPlayerDecal( const char *name );
  25. virtual ~CTEPlayerDecal( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVar( int, m_nPlayer );
  30. CNetworkVector( m_vecOrigin );
  31. CNetworkVar( int, m_nEntity );
  32. };
  33. //-----------------------------------------------------------------------------
  34. // Purpose:
  35. // Input : *name -
  36. //-----------------------------------------------------------------------------
  37. CTEPlayerDecal::CTEPlayerDecal( const char *name ) :
  38. CBaseTempEntity( name )
  39. {
  40. m_nPlayer = 0;
  41. m_vecOrigin.Init();
  42. m_nEntity = 0;
  43. }
  44. //-----------------------------------------------------------------------------
  45. // Purpose:
  46. //-----------------------------------------------------------------------------
  47. CTEPlayerDecal::~CTEPlayerDecal( void )
  48. {
  49. }
  50. //-----------------------------------------------------------------------------
  51. // Purpose:
  52. // Input : *current_origin -
  53. // *current_angles -
  54. //-----------------------------------------------------------------------------
  55. void CTEPlayerDecal::Test( const Vector& current_origin, const QAngle& current_angles )
  56. {
  57. // Fill in data
  58. m_nPlayer = 1;
  59. m_nEntity = 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(CTEPlayerDecal, DT_TEPlayerDecal)
  76. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  77. SendPropInt( SENDINFO(m_nEntity), MAX_EDICT_BITS, SPROP_UNSIGNED ),
  78. SendPropInt( SENDINFO(m_nPlayer), Q_log2( MAX_PLAYERS ), SPROP_UNSIGNED ),
  79. END_SEND_TABLE()
  80. // Singleton to fire TEPlayerDecal objects
  81. static CTEPlayerDecal g_TEPlayerDecal( "Player Decal" );
  82. //-----------------------------------------------------------------------------
  83. // Purpose:
  84. // Input : msg_dest -
  85. // delay -
  86. // *origin -
  87. // *recipient -
  88. // *pos -
  89. // player -
  90. // entity -
  91. // index -
  92. //-----------------------------------------------------------------------------
  93. void TE_PlayerDecal( IRecipientFilter& filter, float delay,
  94. const Vector* pos, int player, int entity )
  95. {
  96. g_TEPlayerDecal.m_vecOrigin = *pos;
  97. g_TEPlayerDecal.m_nPlayer = player;
  98. g_TEPlayerDecal.m_nEntity = entity;
  99. // Send it over the wire
  100. g_TEPlayerDecal.Create( filter, delay );
  101. }