4 protected const int BLEEDING_REPEAT_DELAY = 2500;
5 protected const float BLEEDINGEFFECT_OPACITY_FADEOUT_1_DURATION = 0.2;
6 protected const float BLEEDINGEFFECT_PROGRESSION_FADEOUT_1_DURATION = 0.2;
7 protected const float BLEEDINGEFFECT_OPACITY_FADEOUT_2_DURATION = 0.3;
8 protected const float BLEEDINGEFFECT_PROGRESSION_FADEOUT_2_DURATION = 3;
9 protected const float BLEEDINGEFFECT_OPACITY_FADEIN_1_DURATION = 1;
10 protected const float BLEEDINGEFFECT_PROGRESSION_FADEIN_1_DURATION = 4.5;
13 protected const float BLACKOUT_OPACITY_MULTIPLIER = 0.20;
16 private static float s_fSaturation;
19 protected ImageWidget m_wBloodEffect1;
20 protected ImageWidget m_wBloodEffect2;
21 protected ImageWidget m_wBlackOut;
22 private int m_iEffectNo = 1;
27 protected ChimeraCharacter m_pCharacterEntity;
29 protected bool m_bBleedingEffect;
30 protected bool m_bIsBleeding;
31 protected bool m_bPlayHeartBeat;
35 override void DisplayStartDraw(IEntity owner)
37 m_wBloodEffect1 = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"BloodVignette1"));
38 m_wBloodEffect2 = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"BloodVignette2"));
39 m_wBlackOut = ImageWidget.Cast(
m_wRoot.FindAnyWidget(
"BlackOut"));
43 override void DisplayControlledEntityChanged(IEntity from, IEntity to)
47 m_pCharacterEntity = ChimeraCharacter.Cast(to);
48 if (!m_pCharacterEntity)
52 if (!m_pDamageManager)
59 m_pDamageManager.GetOnDamageOverTimeAdded().Insert(OnDamageOverTimeAdded);
60 m_pDamageManager.GetOnDamageOverTimeRemoved().Insert(OnDamageOverTimeRemoved);
63 if (m_pDamageManager.IsDamagedOverTime(
EDamageType.BLEEDING))
70 m_bIsBleeding = m_pDamageManager.IsDamagedOverTime(
EDamageType.BLEEDING);
71 if (!m_bBleedingEffect && m_bIsBleeding && m_pDamageManager.GetState() !=
EDamageState.DESTROYED)
72 CreateEffectOverTime(
true);
74 m_bBleedingEffect = m_bIsBleeding;
80 m_bIsBleeding = m_pDamageManager.IsDamagedOverTime(
EDamageType.BLEEDING);
84 ClearEffectOverTime(
false);
85 GetGame().GetCallqueue().Remove(CreateEffectOverTime);
86 GetGame().GetCallqueue().Remove(ClearEffectOverTime);
88 m_bBleedingEffect =
false;
92 protected override void DisplayOnSuspended()
94 m_bPlayHeartBeat =
false;
98 protected override void DisplayOnResumed()
100 m_bPlayHeartBeat =
true;
104 void CreateEffectOverTime(
bool repeat)
106 if (!m_wBloodEffect1 || !m_wBloodEffect2 || !m_pBloodHZ)
109 float effectStrength = 1;
110 const float REDUCEDSTRENGTH = 0.7;
111 bool playHeartBeat = m_bPlayHeartBeat;
113 if (m_pBloodHZ.GetDamageOverTime(
EDamageType.BLEEDING) < 5)
115 effectStrength *= REDUCEDSTRENGTH;
116 playHeartBeat =
false;
119 m_wBloodEffect1.SetSaturation(1);
120 m_wBloodEffect2.SetSaturation(1);
122 if (m_iEffectNo == 1)
124 AnimateWidget.Opacity(m_wBloodEffect1, effectStrength, BLEEDINGEFFECT_OPACITY_FADEIN_1_DURATION);
125 AnimateWidget.AlphaMask(m_wBloodEffect1, effectStrength * 0.5, BLEEDINGEFFECT_PROGRESSION_FADEIN_1_DURATION);
126 AnimateWidget.Opacity(m_wBloodEffect2, 0, BLEEDINGEFFECT_OPACITY_FADEOUT_2_DURATION);
127 AnimateWidget.AlphaMask(m_wBloodEffect2, 0, BLEEDINGEFFECT_PROGRESSION_FADEOUT_2_DURATION);
129 else if (m_iEffectNo == 2)
131 AnimateWidget.Opacity(m_wBloodEffect1, 0, BLEEDINGEFFECT_OPACITY_FADEOUT_2_DURATION);
132 AnimateWidget.AlphaMask(m_wBloodEffect1, 0, BLEEDINGEFFECT_PROGRESSION_FADEOUT_2_DURATION);
133 AnimateWidget.Opacity(m_wBloodEffect2, effectStrength, BLEEDINGEFFECT_OPACITY_FADEIN_1_DURATION);
134 AnimateWidget.AlphaMask(m_wBloodEffect2, effectStrength * 0.5, BLEEDINGEFFECT_PROGRESSION_FADEIN_1_DURATION);
137 BlackoutEffect(effectStrength);
140 if (playHeartBeat && m_pDamageManager.GetDefaultHitZone().GetDamageState() !=
EDamageState.DESTROYED)
142 SCR_UISoundEntity.SetSignalValueStr(
"BloodLoss", 1 - m_pBloodHZ.GetHealthScaled());
146 GetGame().GetCallqueue().CallLater(ClearEffectOverTime, 1000,
false, repeat, m_iEffectNo);
150 void ClearEffectOverTime(
bool repeat)
152 if (m_iEffectNo == 1)
157 AnimateWidget.Opacity(m_wBloodEffect1, 0, BLEEDINGEFFECT_PROGRESSION_FADEOUT_1_DURATION);
158 AnimateWidget.AlphaMask(m_wBloodEffect1, 0, BLEEDINGEFFECT_OPACITY_FADEOUT_1_DURATION);
159 AnimateWidget.Opacity(m_wBloodEffect2, 0, BLEEDINGEFFECT_PROGRESSION_FADEOUT_1_DURATION);
160 AnimateWidget.AlphaMask(m_wBloodEffect2, 0, BLEEDINGEFFECT_OPACITY_FADEOUT_1_DURATION);
164 if (repeat && m_bBleedingEffect)
165 GetGame().GetCallqueue().CallLater(CreateEffectOverTime, BLEEDING_REPEAT_DELAY,
false, repeat);
169 void BlackoutEffect(
float effectStrength)
174 if (effectStrength > 0)
176 m_wBlackOut.SetOpacity(1);
177 effectStrength *= BLACKOUT_OPACITY_MULTIPLIER;
178 AnimateWidget.AlphaMask(m_wBlackOut, effectStrength, BLEEDINGEFFECT_PROGRESSION_FADEIN_1_DURATION);
182 AnimateWidget.AlphaMask(m_wBlackOut, 0, BLEEDINGEFFECT_OPACITY_FADEOUT_1_DURATION);
187 protected override void ClearEffects()
189 m_bBleedingEffect = 0;
193 AnimateWidget.StopAllAnimations(m_wBloodEffect1);
194 m_wBloodEffect1.SetOpacity(0);
195 m_wBloodEffect1.SetMaskProgress(0);
200 AnimateWidget.StopAllAnimations(m_wBloodEffect2);
201 m_wBloodEffect2.SetOpacity(0);
202 m_wBloodEffect2.SetMaskProgress(0);
207 AnimateWidget.StopAllAnimations(m_wBlackOut);
208 m_wBlackOut.SetOpacity(0);
209 m_wBlackOut.SetMaskProgress(0);
212 GetGame().GetCallqueue().Remove(CreateEffectOverTime);
213 GetGame().GetCallqueue().Remove(ClearEffectOverTime);
215 if (!m_pDamageManager)
218 m_pDamageManager.GetOnDamageOverTimeAdded().Remove(OnDamageOverTimeAdded);
219 m_pDamageManager.GetOnDamageOverTimeRemoved().Remove(OnDamageOverTimeRemoved);