Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_DrowningScreenEffect.c
Go to the documentation of this file.
1
class
SCR_DrowningScreenEffect
:
SCR_BaseScreenEffect
2
{
3
// Play Animation of drowningVignette
4
protected
const
float
DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION
= 0.2;
5
protected
const
float
DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION
= 0.2;
6
7
// Fade out animation of drowningVignette
8
protected
const
float
DROWNINGEFFECT_OPACITY_FADEIN_1_DURATION
= 1;
9
protected
const
float
DROWNINGEFFECT_PROGRESSION_FADEIN_1_DURATION
= 4.5;
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
17
protected
ImageWidget
m_wDrowningEffect
;
18
protected
ImageWidget
m_wBlackOut
;
19
20
// Character
21
protected
ChimeraCharacter
m_pCharacterEntity
;
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
//------------------------------------------------------------------------------------------------
32
override
void
DisplayControlledEntityChanged
(
IEntity
from,
IEntity
to)
33
{
34
ClearEffects
();
35
RemoveInvokers
(from);
36
37
m_pCharacterEntity
=
ChimeraCharacter
.Cast(to);
38
if
(!
m_pCharacterEntity
)
39
return
;
40
41
SCR_CharacterControllerComponent
m_CharController
=
SCR_CharacterControllerComponent
.Cast(
m_pCharacterEntity
.GetCharacterController());
42
if
(!
m_CharController
)
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
51
SCR_CharacterDamageManagerComponent
damageMan =
SCR_CharacterDamageManagerComponent
.Cast(
m_pCharacterEntity
.GetDamageManager());
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
{
63
if
(!
m_wDrowningEffect
)
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
//------------------------------------------------------------------------------------------------
80
protected
void
ClearEffect
()
81
{
82
AnimateEffectVisibility
(
m_wDrowningEffect
, 0, 0,
DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION
,
DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION
);
83
84
BlackoutEffect
(0, 0);
85
}
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
{
95
AnimateWidget
.
AlphaMask
(
m_wBlackOut
, 0,
DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION
);
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
{
116
if
(
m_wDrowningEffect
)
117
HideSingleEffect
(
m_wDrowningEffect
);
118
119
if
(
m_wBlackOut
)
120
HideSingleEffect
(
m_wBlackOut
);
121
}
122
123
//------------------------------------------------------------------------------------------------
124
protected
void
RemoveInvokers
(
IEntity
prevEntity)
125
{
126
if
(!prevEntity)
127
return
;
128
129
m_pCharacterEntity
=
ChimeraCharacter
.Cast(prevEntity);
130
if
(!
m_pCharacterEntity
)
131
return
;
132
133
SCR_CharacterControllerComponent
m_CharController
=
SCR_CharacterControllerComponent
.Cast(
m_pCharacterEntity
.GetCharacterController());
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
}
m_CharController
SCR_CharacterControllerComponent m_CharController
Definition
SCR_ConsumableItemComponent.c:18
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::AlphaMask
static WidgetAnimationAlphaMask AlphaMask(Widget widget, float targetValue, float speed)
Definition
AnimateWidget.c:189
ChimeraCharacter
Definition
ChimeraCharacter.c:13
IEntity
Definition
IEntity.c:13
ImageWidget
Definition
ImageWidget.c:13
SCR_BaseScreenEffect
Definition
SCR_BaseScreenEffect.c:2
SCR_BaseScreenEffect::AnimateEffectVisibility
void AnimateEffectVisibility(notnull ImageWidget effectWidget, float opacity, float alpha, float opacitySpeed=1.0, float alphaSpeed=1.0, bool updateVisibility=true)
Definition
SCR_BaseScreenEffect.c:54
SCR_BaseScreenEffect::HideSingleEffect
void HideSingleEffect(notnull ImageWidget effectWidget)
Definition
SCR_BaseScreenEffect.c:69
SCR_CharacterControllerComponent
Definition
SCR_CharacterControllerComponent.c:36
SCR_CharacterDamageManagerComponent
Definition
SCR_CharacterDamageManagerComponent.c:19
SCR_DrowningScreenEffect
Definition
SCR_DrowningScreenEffect.c:2
SCR_DrowningScreenEffect::m_wBlackOut
ImageWidget m_wBlackOut
Definition
SCR_DrowningScreenEffect.c:18
SCR_DrowningScreenEffect::DROWNINGEFFECT_OPACITY_FADEIN_1_DURATION
const float DROWNINGEFFECT_OPACITY_FADEIN_1_DURATION
Definition
SCR_DrowningScreenEffect.c:8
SCR_DrowningScreenEffect::BLACKOUT_OPACITY_MULTIPLIER
const float BLACKOUT_OPACITY_MULTIPLIER
Definition
SCR_DrowningScreenEffect.c:12
SCR_DrowningScreenEffect::BlackoutEffect
void BlackoutEffect(float effectStrength, float drowningDuration)
Definition
SCR_DrowningScreenEffect.c:88
SCR_DrowningScreenEffect::m_pCharacterEntity
ChimeraCharacter m_pCharacterEntity
Definition
SCR_DrowningScreenEffect.c:21
SCR_DrowningScreenEffect::DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION
const float DROWNINGEFFECT_PROGRESSION_FADEOUT_1_DURATION
Definition
SCR_DrowningScreenEffect.c:5
SCR_DrowningScreenEffect::ClearEffect
void ClearEffect()
Definition
SCR_DrowningScreenEffect.c:80
SCR_DrowningScreenEffect::OnDeath
void OnDeath(EDamageState state)
Definition
SCR_DrowningScreenEffect.c:105
SCR_DrowningScreenEffect::DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION
const float DROWNINGEFFECT_OPACITY_FADEOUT_1_DURATION
Definition
SCR_DrowningScreenEffect.c:4
SCR_DrowningScreenEffect::RemoveInvokers
void RemoveInvokers(IEntity prevEntity)
Definition
SCR_DrowningScreenEffect.c:124
SCR_DrowningScreenEffect::DROWNINGEFFECT_STRENGTH
const float DROWNINGEFFECT_STRENGTH
Definition
SCR_DrowningScreenEffect.c:14
SCR_DrowningScreenEffect::CreateEffect
void CreateEffect(float maxDrowningDuration, float drowningTimeStartFX)
Definition
SCR_DrowningScreenEffect.c:61
SCR_DrowningScreenEffect::DROWNINGEFFECT_PROGRESSION_FADEIN_1_DURATION
const float DROWNINGEFFECT_PROGRESSION_FADEIN_1_DURATION
Definition
SCR_DrowningScreenEffect.c:9
SCR_DrowningScreenEffect::m_wDrowningEffect
ImageWidget m_wDrowningEffect
Definition
SCR_DrowningScreenEffect.c:17
SCR_DrowningScreenEffect::DisplayStartDraw
override void DisplayStartDraw(IEntity owner)
Definition
SCR_DrowningScreenEffect.c:25
SCR_DrowningScreenEffect::ClearEffects
override void ClearEffects()
Definition
SCR_DrowningScreenEffect.c:114
SCR_DrowningScreenEffect::DisplayControlledEntityChanged
override void DisplayControlledEntityChanged(IEntity from, IEntity to)
Definition
SCR_DrowningScreenEffect.c:32
EDamageState
EDamageState
Definition
EDamageState.c:13
scripts
Game
UI
ScreenEffects
SCR_DrowningScreenEffect.c
Generated by
1.17.0