headtorchlight.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. class HeadtorchLight extends SpotLightBase
  2. {
  3. private static float m_DefaultBrightness = 3;
  4. private static float m_DefaultRadius = 20;
  5. void HeadtorchLight()
  6. {
  7. SetVisibleDuringDaylight( true );
  8. SetRadiusTo( m_DefaultRadius );
  9. SetSpotLightAngle( 95 );
  10. SetCastShadow( true );
  11. FadeIn( 0.06 );
  12. SetBrightnessTo( m_DefaultBrightness );
  13. SetAmbientColor( 0.92, 0.85, 0.58 );
  14. SetDiffuseColor( 0.92, 0.85, 0.58 );
  15. SetFadeOutTime( 0.1 );
  16. //SetDisableShadowsWithinRadius(0.25); // Idea for optimization: Uncomment this to disable shadows from Headtorch while it's on player's head during 1P view.
  17. }
  18. void SetColorToWhite()
  19. {
  20. SetAmbientColor( 0.92, 0.85, 0.86 );
  21. SetDiffuseColor( 0.92, 0.85, 0.86 );
  22. }
  23. void SetColorToRed()
  24. {
  25. SetAmbientColor( 1.0, 0.2, 0.2 );
  26. SetDiffuseColor( 1.0, 0.2, 0.2 );
  27. }
  28. void SetIntensity( float coef, float time )
  29. {
  30. FadeBrightnessTo( m_DefaultBrightness * coef, time );
  31. FadeRadiusTo( m_DefaultRadius * coef, time );
  32. }
  33. void PerformVisibilityCheck(EntityAI owner)
  34. {
  35. if (!owner.IsFlagSet(EntityFlags.VISIBLE) && IsEnabled())
  36. {
  37. SetEnabled(false);
  38. }
  39. else if (owner.IsFlagSet(EntityFlags.VISIBLE) && !IsEnabled())
  40. {
  41. SetEnabled(true);
  42. }
  43. }
  44. }