pperspooky.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // PPE when player is in spooky area trigger
  2. class PPERequester_SpookyAreaTint extends PPERequester_GameplayBase
  3. {
  4. protected vector m_StartRGB = vector.Zero;
  5. protected float m_AccumulatedTime = 0;
  6. protected bool m_FadeIn = false;
  7. protected bool m_FadeOut = false;
  8. const float FADE_TIME = 3;
  9. // the end result is 1 - the value set here
  10. const float R_TARGET = 0.60; // 0.31 79 129 0.50
  11. const float G_TARGET = 0.28; // 0.80 204 184 0.72
  12. const float B_TARGET = 0.07; // 0.95 242 239 0.93
  13. override protected void OnStart( Param par = null )
  14. {
  15. super.OnStart( par );
  16. m_AccumulatedTime = 0;
  17. m_FadeIn = true;
  18. m_FadeOut = false;
  19. SetTargetValueFloat(PostProcessEffectType.FilmGrain,PPEFilmGrain.PARAM_SHARPNESS,false,10.0,PPEFilmGrain.L_1_TOXIC_TINT,PPOperators.HIGHEST);
  20. SetTargetValueFloat(PostProcessEffectType.FilmGrain,PPEFilmGrain.PARAM_GRAINSIZE,false,1.0,PPEFilmGrain.L_2_TOXIC_TINT,PPOperators.LOWEST);
  21. }
  22. override protected void OnUpdate( float delta )
  23. {
  24. super.OnUpdate( delta );
  25. if ( m_FadeIn && m_AccumulatedTime <= FADE_TIME )
  26. {
  27. m_AccumulatedTime += delta;
  28. m_StartRGB[0] = 1 - FadeColourMult( 0, 1, m_AccumulatedTime / FADE_TIME ) * R_TARGET;
  29. m_StartRGB[1] = 1 - FadeColourMult( 0, 1, m_AccumulatedTime / FADE_TIME ) * G_TARGET;
  30. m_StartRGB[2] = 1 - FadeColourMult( 0, 1, m_AccumulatedTime / FADE_TIME ) * B_TARGET;
  31. SetTargetValueColor(PostProcessEffectType.Glow,PPEGlow.PARAM_COLORIZATIONCOLOR,{m_StartRGB[0], m_StartRGB[1], m_StartRGB[2], 0.0},PPEGlow.L_23_TOXIC_TINT,PPOperators.MULTIPLICATIVE);
  32. }
  33. if ( m_FadeOut )
  34. {
  35. if (m_AccumulatedTime <= FADE_TIME)
  36. {
  37. m_AccumulatedTime += delta;
  38. m_StartRGB[0] = ( 1 - R_TARGET ) + FadeColourMult( 0, R_TARGET, m_AccumulatedTime / FADE_TIME );
  39. m_StartRGB[1] = ( 1 - G_TARGET ) + FadeColourMult( 0, G_TARGET, m_AccumulatedTime / FADE_TIME );
  40. m_StartRGB[2] = ( 1 - B_TARGET ) + FadeColourMult( 0, B_TARGET, m_AccumulatedTime / FADE_TIME );
  41. SetTargetValueColor(PostProcessEffectType.Glow,PPEGlow.PARAM_COLORIZATIONCOLOR,{m_StartRGB[0], m_StartRGB[1], m_StartRGB[2], 0.0},PPEGlow.L_23_TOXIC_TINT,PPOperators.MULTIPLICATIVE);
  42. }
  43. else
  44. {
  45. Stop(); //proper termination after a fadeout
  46. }
  47. }
  48. }
  49. override void OnStop(Param par = null)
  50. {
  51. m_FadeIn = false;
  52. m_FadeOut = false;
  53. Param1<bool> p;
  54. if (par && Class.CastTo(p,par))
  55. m_FadeOut = p.param1;
  56. m_AccumulatedTime = 0;
  57. super.OnStop(par);
  58. }
  59. // Lerped multiplier for RGBA values
  60. protected float FadeColourMult( float x, float y, float deltaT )
  61. {
  62. float output;
  63. output = Math.Lerp( x, y, deltaT );
  64. Easing.EaseInOutSine( output );
  65. return output;
  66. }
  67. }