pperdrowningeffect.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. class PPERequester_Drowning extends PPERequester_GameplayBase
  2. {
  3. private float m_EffectPhase = 0;
  4. private float m_Magnitude = 0;
  5. private float m_MinMagnitude = 0.3;
  6. private float m_MaxMagnitude = 0.3; // Actual Maximum is Min+Max
  7. private float m_Frequency = 5;
  8. private float m_Stamina01;
  9. override protected void OnStart(Param par = null)
  10. {
  11. super.OnStart(par);
  12. m_EffectPhase = 0;
  13. m_Magnitude = 0;
  14. }
  15. override protected void OnUpdate(float delta)
  16. {
  17. super.OnUpdate(delta);
  18. if (!m_IsRunning)
  19. return;
  20. m_EffectPhase += delta * m_Frequency / (m_Stamina01 + 1); // Start with lower frequency and increase it as it gets closer to danger
  21. float currentVal = (Math.Sin(m_EffectPhase) +1)/2; // Makes current val oscillate between 0 and 1 (normlization)
  22. currentVal = Easing.EaseInExpo(currentVal); // Ease it to tweak the effect
  23. currentVal *= currentVal * m_MaxMagnitude; // Scale the normalized value to make it proportional to the Max Magnitude
  24. currentVal += m_MinMagnitude;
  25. m_Magnitude = Math.Lerp(m_Magnitude, currentVal, delta * m_Frequency); // Learp to smooth the changes
  26. SetTargetValueFloat(PostProcessEffectType.Glow,PPEGlow.PARAM_VIGNETTE,true, m_Magnitude,PPEGodRays.L_0_GLASSES,PPOperators.ADD);
  27. SetTargetValueColor(PostProcessEffectType.Glow,PPEGlow.PARAM_VIGNETTECOLOR,{0.0,0.025,0.04, 0.0},PPEGlow.L_23_GLASSES,PPOperators.ADD);
  28. }
  29. void SetStamina01(float stamina01)
  30. {
  31. m_Stamina01 = stamina01;
  32. }
  33. }