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_UnconsciousScreenEffect.c
Go to the documentation of this file.
1
class
SCR_UnconsciousScreenEffect
:
SCR_BaseScreenEffect
2
{
3
// Play Animation of UnconsciousnessEffect()
4
protected
const
float
UNCONSCIOUS_EFFECT_DURATION
= 0.5;
5
protected
const
float
UNCONSCIOUS_FADEOUT_DURATION
= 0.8;
6
protected
const
float
UNCONSCIOUS_OSCILIATION_OVERSHOOT
= 0.2;
7
protected
const
float
UNCONSCIOUS_ALPHAMASK_MIN
= 0.4;
8
protected
const
float
UNCONSCIOUS_ALPHAMASK_MAX
= 0.7;
9
protected
const
float
UNCONSCIOUS_OPACITY_DIFF
= 0.05;
10
11
// Widgets
12
protected
bool
m_bOverUnder
;
13
protected
WidgetAnimationBase
m_UnconMaskAnim
;
14
protected
ImageWidget
m_wDeath
;
15
16
//Character
17
protected
SCR_CharacterDamageManagerComponent
m_DamageManager
;
18
protected
ChimeraCharacter
m_CharacterEntity
;
19
20
[
Attribute
(
"0"
,
UIWidgets
.ComboBox,
"Which curve shape should be used for lerping the effect in"
,
""
, ParamEnumArray.FromEnum(
EAnimationCurve
)) ]
21
EAnimationCurve
m_eUnconsciousEffectAnimIn
;
22
23
[
Attribute
(
"0"
,
UIWidgets
.ComboBox,
"Which curve shape should be used for lerping the effect out"
,
""
, ParamEnumArray.FromEnum(
EAnimationCurve
)) ]
24
EAnimationCurve
m_eUnconsciousEffectAnimOut
;
25
26
//------------------------------------------------------------------------------------------------
27
override
void
DisplayStartDraw
(
IEntity
owner)
28
{
29
m_CharacterEntity
=
ChimeraCharacter
.Cast(owner);
30
m_wDeath
=
ImageWidget
.Cast(
m_wRoot
.FindAnyWidget(
"UnconOverlay"
));
31
}
32
33
//------------------------------------------------------------------------------------------------
34
override
void
DisplayControlledEntityChanged
(
IEntity
from,
IEntity
to)
35
{
36
ClearEffects
();
37
38
m_CharacterEntity
=
ChimeraCharacter
.Cast(to);
39
if
(!
m_CharacterEntity
)
40
return
;
41
42
m_DamageManager
=
SCR_CharacterDamageManagerComponent
.Cast(
m_CharacterEntity
.GetDamageManager());
43
44
// In case player became unconscious before invokers were established, check if already bleeding
45
CharacterControllerComponent controller =
m_CharacterEntity
.GetCharacterController();
46
if
(controller && controller.GetLifeState() ==
ECharacterLifeState
.INCAPACITATED)
47
DisplayConsciousnessChanged
(
false
);
48
}
49
50
//------------------------------------------------------------------------------------------------
51
protected
override
void
DisplayConsciousnessChanged
(
bool
conscious,
bool
init =
false
)
52
{
53
UnconsciousnessEffect
(conscious);
54
}
55
56
//------------------------------------------------------------------------------------------------
57
protected
void
UnconsciousnessEffect
(
bool
conscious)
58
{
59
if
(!conscious)
60
PlayUnconAnim
(
UNCONSCIOUS_EFFECT_DURATION
);
61
else
62
StopUnconAnim
();
63
}
64
65
//------------------------------------------------------------------------------------------------
66
protected
void
PlayUnconAnim
(
float
speed)
67
{
68
if
(!
m_wDeath
|| !
m_CharacterController
)
69
return
;
70
71
if
(
m_CharacterController
.IsDead())
72
return
;
73
74
m_bOverUnder
= !
m_bOverUnder
;
75
76
float
unconProgress = 1 -
GetUnconProgress
();
77
float
targetProgress;
78
EAnimationCurve
curve;
79
80
if
(
m_bOverUnder
)
81
{
82
curve =
m_eUnconsciousEffectAnimIn
;
83
targetProgress = unconProgress + (unconProgress *
UNCONSCIOUS_OSCILIATION_OVERSHOOT
);
84
AnimateWidget
.
Opacity
(
m_wDeath
, 1, speed,
true
);
85
}
86
else
87
{
88
curve =
m_eUnconsciousEffectAnimOut
;
89
targetProgress = unconProgress - (unconProgress *
UNCONSCIOUS_OSCILIATION_OVERSHOOT
);
90
AnimateWidget
.
Opacity
(
m_wDeath
, 1 -
UNCONSCIOUS_OPACITY_DIFF
, speed,
true
);
91
}
92
93
m_UnconMaskAnim
=
AnimateWidget
.
AlphaMask
(
m_wDeath
,
Math
.Lerp(
UNCONSCIOUS_ALPHAMASK_MIN
,
UNCONSCIOUS_ALPHAMASK_MAX
, targetProgress), speed);
94
m_UnconMaskAnim
.SetCurve(curve);
95
96
if
(
m_UnconMaskAnim
)
97
m_UnconMaskAnim
.GetOnCompleted().Insert(
OnAnimCycleComplete
);
98
99
SCR_LogitechLEDManager
.ActivateState(ELogitechLEDState.UNCONSCIOUS);
100
}
101
102
//------------------------------------------------------------------------------------------------
103
protected
void
OnAnimCycleComplete
(
WidgetAnimationBase
anim)
104
{
105
if
(anim)
106
{
107
anim.Stop();
108
anim.GetOnCycleCompleted().Remove(
OnAnimCycleComplete
);
109
}
110
111
GetGame
().GetCallqueue().CallLater(
PlayUnconAnim
,
param1
:
UNCONSCIOUS_EFFECT_DURATION
);
112
}
113
114
//------------------------------------------------------------------------------------------------
115
protected
float
GetUnconProgress
()
116
{
117
if
(!
m_DamageManager
)
118
return
0;
119
120
SCR_CharacterResilienceHitZone resilience =
m_DamageManager
.GetResilienceHitZone();
121
if
(!resilience)
122
return
0;
123
124
SCR_CharacterBloodHitZone
blood =
m_DamageManager
.GetBloodHitZone();
125
if
(blood && blood.GetHealthScaled() < blood.GetDamageStateThreshold(
ECharacterBloodState
.UNCONSCIOUS))
126
return
0;
127
128
return
Math
.Lerp(0, resilience.GetDamageStateThreshold(
ECharacterResilienceState
.WEAKENED), resilience.GetHealthScaled());
129
}
130
131
//------------------------------------------------------------------------------------------------
132
protected
void
StopUnconAnim
()
133
{
134
if
(
m_UnconMaskAnim
)
135
m_UnconMaskAnim
.GetOnCycleCompleted().Remove(
OnAnimCycleComplete
);
136
137
if
(!
m_wDeath
)
138
return
;
139
140
AnimateWidget
.
AlphaMask
(
m_wDeath
, 0,
UNCONSCIOUS_FADEOUT_DURATION
);
141
AnimateWidget
.
Opacity
(
m_wDeath
, 0,
UNCONSCIOUS_FADEOUT_DURATION
,
true
);
142
SCR_LogitechLEDManager
.ActivateState(ELogitechLEDState.DEFAULT);
143
}
144
145
//------------------------------------------------------------------------------------------------
146
protected
override
void
ClearEffects
()
147
{
148
if
(
m_UnconMaskAnim
)
149
m_UnconMaskAnim
.GetOnCycleCompleted().Remove(
OnAnimCycleComplete
);
150
151
if
(
m_wDeath
)
152
{
153
AnimateWidget
.
StopAllAnimations
(
m_wDeath
);
154
m_wDeath
.SetOpacity(0);
155
m_wDeath
.SetMaskProgress(0);
156
}
157
}
158
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
ECharacterBloodState
ECharacterBloodState
Definition
SCR_CharacterHitZone.c:16
ECharacterResilienceState
ECharacterResilienceState
Definition
SCR_CharacterHitZone.c:23
m_CharacterController
SCR_CharacterPerceivableComponentClass m_CharacterController
m_wRoot
Widget m_wRoot
Definition
SCR_GameModeCleanSweep.c:25
WidgetAnimationBase
void WidgetAnimationBase(Widget w, float speed)
Definition
WidgetAnimation.c:308
EAnimationCurve
EAnimationCurve
Definition
WidgetAnimation.c:6
AnimateWidget
Definition
AnimateWidget.c:3
AnimateWidget::Opacity
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
Definition
AnimateWidget.c:167
AnimateWidget::AlphaMask
static WidgetAnimationAlphaMask AlphaMask(Widget widget, float targetValue, float speed)
Definition
AnimateWidget.c:189
AnimateWidget::StopAllAnimations
static void StopAllAnimations(Widget w)
Definition
AnimateWidget.c:73
ChimeraCharacter
Definition
ChimeraCharacter.c:13
IEntity
Definition
IEntity.c:13
ImageWidget
Definition
ImageWidget.c:13
Math
Definition
Math.c:13
SCR_BaseScreenEffect
Definition
SCR_BaseScreenEffect.c:2
SCR_CharacterBloodHitZone
Blood - does not receive damage directly, only via scripted events.
Definition
SCR_CharacterHitZone.c:430
SCR_CharacterDamageManagerComponent
Definition
SCR_CharacterDamageManagerComponent.c:19
SCR_LogitechLEDManager
Definition
SCR_LogitechLedManager.c:2
SCR_UnconsciousScreenEffect
Definition
SCR_UnconsciousScreenEffect.c:2
SCR_UnconsciousScreenEffect::DisplayStartDraw
override void DisplayStartDraw(IEntity owner)
Definition
SCR_UnconsciousScreenEffect.c:27
SCR_UnconsciousScreenEffect::UNCONSCIOUS_OSCILIATION_OVERSHOOT
const float UNCONSCIOUS_OSCILIATION_OVERSHOOT
Definition
SCR_UnconsciousScreenEffect.c:6
SCR_UnconsciousScreenEffect::UNCONSCIOUS_ALPHAMASK_MAX
const float UNCONSCIOUS_ALPHAMASK_MAX
Definition
SCR_UnconsciousScreenEffect.c:8
SCR_UnconsciousScreenEffect::m_wDeath
ImageWidget m_wDeath
Definition
SCR_UnconsciousScreenEffect.c:14
SCR_UnconsciousScreenEffect::m_DamageManager
SCR_CharacterDamageManagerComponent m_DamageManager
Definition
SCR_UnconsciousScreenEffect.c:17
SCR_UnconsciousScreenEffect::UnconsciousnessEffect
void UnconsciousnessEffect(bool conscious)
Definition
SCR_UnconsciousScreenEffect.c:57
SCR_UnconsciousScreenEffect::OnAnimCycleComplete
void OnAnimCycleComplete(WidgetAnimationBase anim)
Definition
SCR_UnconsciousScreenEffect.c:103
SCR_UnconsciousScreenEffect::m_CharacterEntity
ChimeraCharacter m_CharacterEntity
Definition
SCR_UnconsciousScreenEffect.c:18
SCR_UnconsciousScreenEffect::GetUnconProgress
float GetUnconProgress()
Definition
SCR_UnconsciousScreenEffect.c:115
SCR_UnconsciousScreenEffect::DisplayControlledEntityChanged
override void DisplayControlledEntityChanged(IEntity from, IEntity to)
Definition
SCR_UnconsciousScreenEffect.c:34
SCR_UnconsciousScreenEffect::DisplayConsciousnessChanged
override void DisplayConsciousnessChanged(bool conscious, bool init=false)
Definition
SCR_UnconsciousScreenEffect.c:51
SCR_UnconsciousScreenEffect::StopUnconAnim
void StopUnconAnim()
Definition
SCR_UnconsciousScreenEffect.c:132
SCR_UnconsciousScreenEffect::UNCONSCIOUS_FADEOUT_DURATION
const float UNCONSCIOUS_FADEOUT_DURATION
Definition
SCR_UnconsciousScreenEffect.c:5
SCR_UnconsciousScreenEffect::m_UnconMaskAnim
WidgetAnimationBase m_UnconMaskAnim
Definition
SCR_UnconsciousScreenEffect.c:13
SCR_UnconsciousScreenEffect::m_bOverUnder
bool m_bOverUnder
Definition
SCR_UnconsciousScreenEffect.c:12
SCR_UnconsciousScreenEffect::UNCONSCIOUS_ALPHAMASK_MIN
const float UNCONSCIOUS_ALPHAMASK_MIN
Definition
SCR_UnconsciousScreenEffect.c:7
SCR_UnconsciousScreenEffect::ClearEffects
override void ClearEffects()
Definition
SCR_UnconsciousScreenEffect.c:146
SCR_UnconsciousScreenEffect::m_eUnconsciousEffectAnimOut
EAnimationCurve m_eUnconsciousEffectAnimOut
Definition
SCR_UnconsciousScreenEffect.c:24
SCR_UnconsciousScreenEffect::UNCONSCIOUS_EFFECT_DURATION
const float UNCONSCIOUS_EFFECT_DURATION
Definition
SCR_UnconsciousScreenEffect.c:4
SCR_UnconsciousScreenEffect::PlayUnconAnim
void PlayUnconAnim(float speed)
Definition
SCR_UnconsciousScreenEffect.c:66
SCR_UnconsciousScreenEffect::UNCONSCIOUS_OPACITY_DIFF
const float UNCONSCIOUS_OPACITY_DIFF
Definition
SCR_UnconsciousScreenEffect.c:9
SCR_UnconsciousScreenEffect::m_eUnconsciousEffectAnimIn
EAnimationCurve m_eUnconsciousEffectAnimIn
Definition
SCR_UnconsciousScreenEffect.c:21
UIWidgets
Definition
attributes.c:40
ECharacterLifeState
ECharacterLifeState
Definition
ECharacterLifeState.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
param1
Tuple param1
scripts
Game
UI
ScreenEffects
SCR_UnconsciousScreenEffect.c
Generated by
1.17.0