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.

158 lines
4.4 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "dlight.h"
  9. #include "iefx.h"
  10. // memdbgon must be the last include file in a .cpp file!!!
  11. #include "tier0/memdbgon.h"
  12. //##################################################################
  13. //
  14. // PlasmaBeamNode - generates plasma embers
  15. //
  16. //##################################################################
  17. class C_SpotlightEnd : public C_BaseEntity
  18. {
  19. public:
  20. DECLARE_CLASS( C_SpotlightEnd, C_BaseEntity );
  21. DECLARE_CLIENTCLASS();
  22. DECLARE_INTERPOLATION();
  23. C_SpotlightEnd();
  24. public:
  25. void OnDataChanged(DataUpdateType_t updateType);
  26. bool ShouldDraw();
  27. void ClientThink( void );
  28. virtual bool ShouldInterpolate();
  29. // Vector m_vSpotlightOrg;
  30. // Vector m_vSpotlightDir;
  31. float m_flLightScale;
  32. float m_Radius;
  33. private:
  34. dlight_t* m_pDynamicLight;
  35. //dlight_t* m_pModelLight;
  36. };
  37. //------------------------------------------------------------------------------
  38. // Purpose :
  39. // Input :
  40. // Output :
  41. //------------------------------------------------------------------------------
  42. C_SpotlightEnd::C_SpotlightEnd(void) : /*m_pModelLight(0), */m_pDynamicLight(0)
  43. {
  44. m_flLightScale = 100;
  45. }
  46. //------------------------------------------------------------------------------
  47. // Purpose :
  48. // Input :
  49. // Output :
  50. //------------------------------------------------------------------------------
  51. void C_SpotlightEnd::OnDataChanged(DataUpdateType_t updateType)
  52. {
  53. if ( updateType == DATA_UPDATE_CREATED )
  54. {
  55. SetNextClientThink(CLIENT_THINK_ALWAYS);
  56. }
  57. }
  58. //------------------------------------------------------------------------------
  59. // Purpose :
  60. // Input :
  61. // Output :
  62. //------------------------------------------------------------------------------
  63. bool C_SpotlightEnd::ShouldDraw()
  64. {
  65. return false;
  66. }
  67. //-----------------------------------------------------------------------------
  68. // Purpose: YWB: This is a hack, BaseClass::Interpolate skips this entity because model == NULL
  69. // We could do something like model = (model_t *)0x00000001, but that's probably more evil.
  70. // Input : currentTime -
  71. // Output : Returns true on success, false on failure.
  72. //-----------------------------------------------------------------------------
  73. bool C_SpotlightEnd::ShouldInterpolate()
  74. {
  75. return true;
  76. }
  77. //------------------------------------------------------------------------------
  78. // Purpose :
  79. // Input :
  80. // Output :
  81. //------------------------------------------------------------------------------
  82. void C_SpotlightEnd::ClientThink(void)
  83. {
  84. // If light scale is zero, don't draw light
  85. if ( m_flLightScale <= 0 )
  86. return;
  87. color24 c = GetRenderColor();
  88. float a = GetRenderAlpha() / 255.0f;
  89. ColorRGBExp32 color;
  90. color.r = c.r * a;
  91. color.g = c.g * a;
  92. color.b = c.b * a;
  93. color.exponent = 0;
  94. if ( color.r == 0 && color.g == 0 && color.b == 0 )
  95. return;
  96. // Deal with the environment light
  97. if ( !m_pDynamicLight || (m_pDynamicLight->key != index) )
  98. {
  99. m_pDynamicLight = effects->CL_AllocDlight( index );
  100. assert (m_pDynamicLight);
  101. }
  102. //m_pDynamicLight->flags = DLIGHT_NO_MODEL_ILLUMINATION;
  103. m_pDynamicLight->radius = m_flLightScale*3.0f;
  104. m_pDynamicLight->origin = GetAbsOrigin() + Vector(0,0,5);
  105. m_pDynamicLight->die = gpGlobals->curtime + 0.05f;
  106. m_pDynamicLight->color = color;
  107. /*
  108. // For bumped lighting
  109. VectorCopy (m_vSpotlightDir, m_pDynamicLight->m_Direction);
  110. // Deal with the model light
  111. if ( !m_pModelLight || (m_pModelLight->key != -index) )
  112. {
  113. m_pModelLight = effects->CL_AllocDlight( -index );
  114. assert (m_pModelLight);
  115. }
  116. m_pModelLight->radius = m_Radius;
  117. m_pModelLight->flags = DLIGHT_NO_WORLD_ILLUMINATION;
  118. m_pModelLight->color.r = c.r * c.a;
  119. m_pModelLight->color.g = c.g * c.a;
  120. m_pModelLight->color.b = c.b * c.a;
  121. m_pModelLight->color.exponent = 1;
  122. m_pModelLight->origin = m_vSpotlightOrg;
  123. m_pModelLight->m_InnerAngle = 6;
  124. m_pModelLight->m_OuterAngle = 8;
  125. m_pModelLight->die = gpGlobals->curtime + 0.05;
  126. VectorCopy( m_vSpotlightDir, m_pModelLight->m_Direction );
  127. */
  128. SetNextClientThink( CLIENT_THINK_ALWAYS );
  129. }
  130. IMPLEMENT_CLIENTCLASS_DT(C_SpotlightEnd, DT_SpotlightEnd, CSpotlightEnd)
  131. RecvPropFloat (RECVINFO(m_flLightScale)),
  132. RecvPropFloat (RECVINFO(m_Radius)),
  133. // RecvPropVector (RECVINFO(m_vSpotlightOrg)),
  134. // RecvPropVector (RECVINFO(m_vSpotlightDir)),
  135. END_RECV_TABLE()