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.

121 lines
3.5 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 BSP decal tempentity
  19. //-----------------------------------------------------------------------------
  20. class CTEProjectedDecal : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTEProjectedDecal, CBaseTempEntity );
  24. CTEProjectedDecal( const char *name );
  25. virtual ~CTEProjectedDecal( 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. CNetworkVar( float, m_flDistance );
  32. CNetworkQAngle( m_angRotation );
  33. };
  34. //-----------------------------------------------------------------------------
  35. // Purpose:
  36. // Input : *name -
  37. //-----------------------------------------------------------------------------
  38. CTEProjectedDecal::CTEProjectedDecal( const char *name ) :
  39. CBaseTempEntity( name )
  40. {
  41. m_vecOrigin.Init();
  42. m_angRotation.Init();
  43. m_flDistance = 64.0f;
  44. m_nIndex = 0;
  45. }
  46. //-----------------------------------------------------------------------------
  47. // Purpose:
  48. //-----------------------------------------------------------------------------
  49. CTEProjectedDecal::~CTEProjectedDecal( void )
  50. {
  51. }
  52. //-----------------------------------------------------------------------------
  53. // Purpose:
  54. // Input : *current_origin -
  55. // *current_angles -
  56. //-----------------------------------------------------------------------------
  57. void CTEProjectedDecal::Test( const Vector& current_origin, const QAngle& current_angles )
  58. {
  59. // Fill in data
  60. m_flDistance = 1024.0f;
  61. m_nIndex = 0;
  62. m_vecOrigin = current_origin;
  63. m_angRotation = current_angles;
  64. Vector vecEnd;
  65. Vector forward;
  66. m_vecOrigin.GetForModify()[2] += 24;
  67. AngleVectors( current_angles, &forward );
  68. forward[2] = 0.0;
  69. VectorNormalize( forward );
  70. VectorMA( m_vecOrigin, 24.0, forward, m_vecOrigin.GetForModify() );
  71. CBroadcastRecipientFilter filter;
  72. Create( filter, 0.0 );
  73. }
  74. IMPLEMENT_SERVERCLASS_ST(CTEProjectedDecal, DT_TEProjectedDecal)
  75. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  76. SendPropQAngles( SENDINFO(m_angRotation), 10 ),
  77. SendPropFloat( SENDINFO(m_flDistance), 10, SPROP_ROUNDUP, 0, 1024 ),
  78. SendPropInt( SENDINFO(m_nIndex), 9, SPROP_UNSIGNED ),
  79. END_SEND_TABLE()
  80. // Singleton to fire TEBSPDecal objects
  81. static CTEProjectedDecal g_TEProjectedDecal( "Projected 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_ProjectDecal( IRecipientFilter& filter, float delay,
  94. const Vector* pos, const QAngle *angles, float distance, int index )
  95. {
  96. g_TEProjectedDecal.m_vecOrigin = *pos;
  97. g_TEProjectedDecal.m_angRotation = *angles;
  98. g_TEProjectedDecal.m_flDistance = distance;
  99. g_TEProjectedDecal.m_nIndex = index;
  100. // Send it over the wire
  101. g_TEProjectedDecal.Create( filter, delay );
  102. }