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.

143 lines
3.9 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: Displays a dynamic light
  19. //-----------------------------------------------------------------------------
  20. class CTEDynamicLight : public CBaseTempEntity
  21. {
  22. public:
  23. DECLARE_CLASS( CTEDynamicLight, CBaseTempEntity );
  24. CTEDynamicLight( const char *name );
  25. virtual ~CTEDynamicLight( void );
  26. virtual void Test( const Vector& current_origin, const QAngle& current_angles );
  27. DECLARE_SERVERCLASS();
  28. public:
  29. CNetworkVector( m_vecOrigin );
  30. CNetworkVar( float, m_fRadius );
  31. CNetworkVar( int, r );
  32. CNetworkVar( int, g );
  33. CNetworkVar( int, b );
  34. CNetworkVar( int, exponent );
  35. CNetworkVar( float, m_fTime );
  36. CNetworkVar( float, m_fDecay );
  37. };
  38. //-----------------------------------------------------------------------------
  39. // Purpose:
  40. // Input : *name -
  41. //-----------------------------------------------------------------------------
  42. CTEDynamicLight::CTEDynamicLight( const char *name ) :
  43. CBaseTempEntity( name )
  44. {
  45. m_vecOrigin.Init();
  46. r = 0;
  47. g = 0;
  48. b = 0;
  49. exponent = 0;
  50. m_fRadius = 0.0;
  51. m_fTime = 0.0;
  52. m_fDecay = 0.0;
  53. }
  54. //-----------------------------------------------------------------------------
  55. // Purpose:
  56. //-----------------------------------------------------------------------------
  57. CTEDynamicLight::~CTEDynamicLight( void )
  58. {
  59. }
  60. //-----------------------------------------------------------------------------
  61. // Purpose:
  62. // Input : *current_origin -
  63. // *current_angles -
  64. //-----------------------------------------------------------------------------
  65. void CTEDynamicLight::Test( const Vector& current_origin, const QAngle& current_angles )
  66. {
  67. // Fill in data
  68. r = 255;
  69. g = 255;
  70. b = 63;
  71. m_vecOrigin = current_origin;
  72. m_fRadius = 200;
  73. m_fTime = 2.0;
  74. m_fDecay = 0.0;
  75. Vector forward;
  76. m_vecOrigin.GetForModify()[2] += 24;
  77. AngleVectors( current_angles, &forward );
  78. forward[2] = 0.0;
  79. VectorNormalize( forward );
  80. VectorMA( m_vecOrigin, 50.0, forward, m_vecOrigin.GetForModify() );
  81. CBroadcastRecipientFilter filter;
  82. Create( filter, 0.0 );
  83. }
  84. IMPLEMENT_SERVERCLASS_ST(CTEDynamicLight, DT_TEDynamicLight)
  85. SendPropVector( SENDINFO(m_vecOrigin), -1, SPROP_COORD),
  86. SendPropInt( SENDINFO(r), 8, SPROP_UNSIGNED ),
  87. SendPropInt( SENDINFO(g), 8, SPROP_UNSIGNED ),
  88. SendPropInt( SENDINFO(b), 8, SPROP_UNSIGNED ),
  89. SendPropInt( SENDINFO(exponent), 8, 0 ),
  90. SendPropFloat( SENDINFO(m_fRadius), 8, SPROP_ROUNDUP, 0, 2560.0 ),
  91. SendPropFloat( SENDINFO(m_fTime), 8, SPROP_ROUNDDOWN, 0, 25.6 ),
  92. SendPropFloat( SENDINFO(m_fDecay), 8, SPROP_ROUNDDOWN, 0, 2560.0 ),
  93. END_SEND_TABLE()
  94. // Singleton
  95. static CTEDynamicLight g_TEDynamicLight( "Dynamic Light" );
  96. //-----------------------------------------------------------------------------
  97. // Purpose:
  98. // Input : msg_dest -
  99. // delay -
  100. // *origin -
  101. // *recipient -
  102. // *org -
  103. // r -
  104. // g -
  105. // b -
  106. // radius -
  107. // time -
  108. // decay -
  109. //-----------------------------------------------------------------------------
  110. void TE_DynamicLight( IRecipientFilter& filter, float delay,
  111. const Vector* org, int r, int g, int b, int exponent, float radius, float time, float decay )
  112. {
  113. // Set up parameters
  114. g_TEDynamicLight.m_vecOrigin = *org;
  115. g_TEDynamicLight.r = r;
  116. g_TEDynamicLight.g = g;
  117. g_TEDynamicLight.b = b;
  118. g_TEDynamicLight.exponent = exponent;
  119. g_TEDynamicLight.m_fRadius = radius;
  120. g_TEDynamicLight.m_fTime = time;
  121. g_TEDynamicLight.m_fDecay = decay;
  122. // Create it
  123. g_TEDynamicLight.Create( filter, delay );
  124. }