4 protected const float DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION = 0.2;
5 protected const float DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION = 0.2;
8 protected const float DROWNINGEFFECT_OPACITY_FADEIN_1_DURATION = 1;
9 protected const float DROWNINGEFFECT_PROGRESSION_FADEIN_1_DURATION = 4.5;
12 protected const float BLACKOUT_OPACITY_MULTIPLIER = 0.70;
15 protected ImageWidget m_wDrowningEffect;
16 protected ImageWidget m_wBlackOut;
19 protected ChimeraCharacter m_pCharacterEntity;
23 override void DisplayStartDraw(IEntity owner)
25 m_wDrowningEffect = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"DrowningVignette"));
26 m_wBlackOut = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"BlackOut"));
30 override void DisplayControlledEntityChanged(IEntity from, IEntity to)
35 m_pCharacterEntity = ChimeraCharacter.Cast(to);
36 if (!m_pCharacterEntity)
50 damageMan.GetOnDamageStateChanged().Insert(OnDeath);
58 void CreateEffect(
float maxDrowningDuration,
float drowningTimeStartFX)
60 if (!m_wDrowningEffect)
63 float effectStrength = 1;
66 float drowningDuration = (maxDrowningDuration - drowningTimeStartFX) + 2;
67 if (drowningDuration <= 0)
70 m_wDrowningEffect.SetSaturation(1);
71 m_wDrowningEffect.SetMaskTransitionWidth(0.8);
73 AnimateWidget.Opacity(m_wDrowningEffect, effectStrength, 1 / drowningDuration);
74 AnimateWidget.AlphaMask(m_wDrowningEffect, effectStrength * 0.6, 1 / drowningDuration);
76 BlackoutEffect(effectStrength, drowningDuration);
82 AnimateWidget.Opacity(m_wDrowningEffect, 0, DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION);
83 AnimateWidget.AlphaMask(m_wDrowningEffect, 0, DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION);
89 void BlackoutEffect(
float effectStrength,
float drowningDuration)
94 if (effectStrength <= 0 || drowningDuration <= 0 )
96 AnimateWidget.AlphaMask(m_wBlackOut, 0, DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION);
100 m_wBlackOut.SetOpacity(1);
101 effectStrength *= BLACKOUT_OPACITY_MULTIPLIER;
102 AnimateWidget.AlphaMask(m_wBlackOut, effectStrength, 1 / drowningDuration);
115 protected override void ClearEffects()
117 if (m_wDrowningEffect)
119 AnimateWidget.StopAllAnimations(m_wDrowningEffect);
120 m_wDrowningEffect.SetOpacity(0);
121 m_wDrowningEffect.SetMaskProgress(0);
126 AnimateWidget.StopAllAnimations(m_wBlackOut);
127 m_wBlackOut.SetOpacity(0);
128 m_wBlackOut.SetMaskProgress(0);
133 protected void RemoveInvokers(IEntity prevEntity)
138 m_pCharacterEntity = ChimeraCharacter.Cast(prevEntity);
139 if (!m_pCharacterEntity)