Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DrowningScreenEffect.c
Go to the documentation of this file.
2{
3 // Play Animation of drowningVignette
4 protected const float DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION = 0.2;
6
7 // Fade out animation of drowningVignette
8 protected const float DROWNINGEFFECT_OPACITY_FADEIN_1_DURATION = 1;
10
11 // Play Animation of BlackoutEffect()
12 protected const float BLACKOUT_OPACITY_MULTIPLIER = 0.70;
13
14 protected const float DROWNINGEFFECT_STRENGTH = 1.0;
15
16 // Widgets
19
20 // Character
22
23
24 //------------------------------------------------------------------------------------------------
25 override void DisplayStartDraw(IEntity owner)
26 {
27 m_wDrowningEffect = ImageWidget.Cast(m_wRoot.FindAnyWidget("DrowningVignette"));
28 m_wBlackOut = ImageWidget.Cast(m_wRoot.FindAnyWidget("DrowningBlackOut"));
29 }
30
31 //------------------------------------------------------------------------------------------------
33 {
35 RemoveInvokers(from);
36
39 return;
40
43 return;
44
45 if (m_CharController.m_OnPlayerDrowning)
46 m_CharController.m_OnPlayerDrowning.Insert(CreateEffect);
47
48 if (m_CharController.m_OnPlayerStopDrowning)
49 m_CharController.m_OnPlayerStopDrowning.Insert(ClearEffect);
50
52 if (damageMan)
53 damageMan.GetOnDamageStateChanged().Insert(OnDeath);
54
55 // In case player started drowning before invokers were established, check if already drowning
56 if (m_CharController.IsCharacterDrowning())
57 CreateEffect(10, 4);
58 }
59
60 //------------------------------------------------------------------------------------------------
61 protected void CreateEffect(float maxDrowningDuration, float drowningTimeStartFX)
62 {
64 return;
65
66 // Add a couple seconds to drowningDuration so the widget still animates when death occurs
67 float drowningDuration = (maxDrowningDuration - drowningTimeStartFX) + 2;
68 if (drowningDuration <= 0)
69 drowningDuration = 1;
70
71 m_wDrowningEffect.SetSaturation(1);
72 m_wDrowningEffect.SetMaskTransitionWidth(0.8);
73
74 AnimateEffectVisibility(m_wDrowningEffect, DROWNINGEFFECT_STRENGTH, DROWNINGEFFECT_STRENGTH * 0.6, 1 / drowningDuration, 1 / drowningDuration);
75
76 BlackoutEffect(DROWNINGEFFECT_STRENGTH, drowningDuration);
77 }
78
79 //------------------------------------------------------------------------------------------------
86
87 //------------------------------------------------------------------------------------------------
88 protected void BlackoutEffect(float effectStrength, float drowningDuration)
89 {
90 if (!m_wBlackOut)
91 return;
92
93 if (effectStrength <= 0 || drowningDuration <= 0)
94 {
96 return;
97 }
98
99 m_wBlackOut.SetOpacity(1);
100 effectStrength *= BLACKOUT_OPACITY_MULTIPLIER;
101 AnimateWidget.AlphaMask(m_wBlackOut, effectStrength, 1 / drowningDuration);
102 }
103
104 //------------------------------------------------------------------------------------------------
105 protected void OnDeath(EDamageState state)
106 {
107 if (state != EDamageState.DESTROYED)
108 return;
109
110 ClearEffect();
111 }
112
113 //------------------------------------------------------------------------------------------------
114 protected override void ClearEffects()
115 {
118
119 if (m_wBlackOut)
121 }
122
123 //------------------------------------------------------------------------------------------------
124 protected void RemoveInvokers(IEntity prevEntity)
125 {
126 if (!prevEntity)
127 return;
128
129 m_pCharacterEntity = ChimeraCharacter.Cast(prevEntity);
131 return;
132
134 if (!m_CharController)
135 return;
136
137 if (m_CharController.m_OnPlayerDrowning)
138 m_CharController.m_OnPlayerDrowning.Remove(CreateEffect);
139
140 if (m_CharController.m_OnPlayerStopDrowning)
141 m_CharController.m_OnPlayerStopDrowning.Remove(ClearEffect);
142 }
143}
SCR_CharacterControllerComponent m_CharController
Widget m_wRoot
static WidgetAnimationAlphaMask AlphaMask(Widget widget, float targetValue, float speed)
void AnimateEffectVisibility(notnull ImageWidget effectWidget, float opacity, float alpha, float opacitySpeed=1.0, float alphaSpeed=1.0, bool updateVisibility=true)
void HideSingleEffect(notnull ImageWidget effectWidget)
const float DROWNINGEFFECT_OPACITY_FADEIN_1_DURATION
void BlackoutEffect(float effectStrength, float drowningDuration)
const float DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION
void OnDeath(EDamageState state)
const float DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION
void RemoveInvokers(IEntity prevEntity)
void CreateEffect(float maxDrowningDuration, float drowningTimeStartFX)
const float DROWNINGEFFECT_PROGRESSION_FADEIN_1_DURATION
override void DisplayStartDraw(IEntity owner)
override void DisplayControlledEntityChanged(IEntity from, IEntity to)
EDamageState