5 protected const float STAMINAEFFECT_INITIAL_OPACITY_TARGET = 0.75;
6 protected const float STAMINAEFFECT_FADEIN_PROGRESSION_TARGET = 0.35;
7 protected const float STAMINAEFFECT_FADEIN_PROGRESSION_DURATION = 1;
8 protected const float STAMINA_CLEAREFFECT_DELAY = 2000;
9 protected const float STAMINA_EFFECT_THRESHOLD = 0.45;
11 [
Attribute( defvalue:
"0.1111", uiwidget: UIWidgets.EditBox,
desc:
"Blur intensity multiplier" )]
12 protected float m_fStaminaBlurMultiplier;
15 private static float s_fBlurriness;
16 private static bool s_bEnableRadialBlur;
17 protected const string RADIAL_BLUR_EMAT =
"{B011FE0AD21E2447}UI/Materials/ScreenEffects_BlurPP.emat";
20 private ImageWidget m_wSupression;
23 static const int RADIAL_BLUR_PRIORITY = 6;
26 protected int m_iStaminaSignal = -1;
27 protected bool m_bStaminaEffectActive;
30 protected SignalsManagerComponent m_pSignalsManager;
33 override void DisplayStartDraw(IEntity owner)
35 m_wSupression = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"SuppressionVignette"));
39 override void DisplayControlledEntityChanged(IEntity from, IEntity to)
41 ChimeraCharacter characterEntity = ChimeraCharacter.Cast(to);
46 m_pSignalsManager = SignalsManagerComponent.Cast(characterEntity.FindComponent(SignalsManagerComponent));
47 if (m_pSignalsManager)
48 m_iStaminaSignal = m_pSignalsManager.FindSignal(
"Exhaustion");
50 characterEntity.GetWorld().SetCameraPostProcessEffect(characterEntity.GetWorld().GetCurrentCameraId(), RADIAL_BLUR_PRIORITY,PostProcessEffectType.RadialBlur, RADIAL_BLUR_EMAT);
54 void FindStaminaValues()
56 if (!m_pSignalsManager || m_iStaminaSignal == -1)
59 float stamina = m_pSignalsManager.GetSignalValue(m_iStaminaSignal);
60 s_fBlurriness = m_wSupression.GetMaskProgress() * m_fStaminaBlurMultiplier;
62 if (stamina > STAMINA_EFFECT_THRESHOLD && !m_bStaminaEffectActive)
64 s_bEnableRadialBlur =
true;
67 else if (m_bStaminaEffectActive && stamina < STAMINA_EFFECT_THRESHOLD)
69 s_bEnableRadialBlur =
false;
70 GetGame().GetCallqueue().Remove(StaminaEffects);
71 GetGame().GetCallqueue().Remove(ClearStaminaEffect);
72 ClearStaminaEffect(
false);
73 m_bStaminaEffectActive =
false;
78 void StaminaEffects(
bool repeat)
83 m_bStaminaEffectActive =
true;
84 m_wSupression.SetOpacity(STAMINAEFFECT_INITIAL_OPACITY_TARGET);
85 AnimateWidget.AlphaMask(m_wSupression, STAMINAEFFECT_FADEIN_PROGRESSION_TARGET, STAMINAEFFECT_FADEIN_PROGRESSION_DURATION);
86 GetGame().GetCallqueue().CallLater(ClearStaminaEffect, STAMINA_CLEAREFFECT_DELAY,
false,
true);
90 void ClearStaminaEffect(
bool repeat)
95 AnimateWidget.AlphaMask(m_wSupression, 0, 1);
96 if (repeat && m_bStaminaEffectActive && m_wSupression && !m_wSupression.GetOpacity() == 0)
97 GetGame().GetCallqueue().CallLater(StaminaEffects, STAMINA_CLEAREFFECT_DELAY,
false, repeat);
101 protected override void DisplayOnSuspended()
103 s_bEnableRadialBlur =
false;
107 protected override void DisplayOnResumed()
109 s_bEnableRadialBlur =
true;
113 override void UpdateEffect(
float timeSlice)
115 if (m_pSignalsManager)
120 protected override void ClearEffects()
124 AnimateWidget.StopAllAnimations(m_wSupression);
125 m_wSupression.SetOpacity(0);
126 m_wSupression.SetMaskProgress(0);