Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_UnconsciousScreenEffect.c
Go to the documentation of this file.
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;
15
16 //Character
19
20 [Attribute("0", UIWidgets.ComboBox, "Which curve shape should be used for lerping the effect in", "", ParamEnumArray.FromEnum(EAnimationCurve)) ]
22
23 [Attribute("0", UIWidgets.ComboBox, "Which curve shape should be used for lerping the effect out", "", ParamEnumArray.FromEnum(EAnimationCurve)) ]
25
26 //------------------------------------------------------------------------------------------------
27 override void DisplayStartDraw(IEntity owner)
28 {
30 m_wDeath = ImageWidget.Cast(m_wRoot.FindAnyWidget("UnconOverlay"));
31 }
32
33 //------------------------------------------------------------------------------------------------
35 {
37
40 return;
41
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)
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)
61 else
63 }
64
65 //------------------------------------------------------------------------------------------------
66 protected void PlayUnconAnim(float speed)
67 {
69 return;
70
71 if (m_CharacterController.IsDead())
72 return;
73
75
76 float unconProgress = 1 - GetUnconProgress();
77 float targetProgress;
78 EAnimationCurve curve;
79
80 if (m_bOverUnder)
81 {
83 targetProgress = unconProgress + (unconProgress * UNCONSCIOUS_OSCILIATION_OVERSHOOT);
84 AnimateWidget.Opacity(m_wDeath, 1, speed, true);
85 }
86 else
87 {
89 targetProgress = unconProgress - (unconProgress * UNCONSCIOUS_OSCILIATION_OVERSHOOT);
91 }
92
94 m_UnconMaskAnim.SetCurve(curve);
95
97 m_UnconMaskAnim.GetOnCompleted().Insert(OnAnimCycleComplete);
98
99 SCR_LogitechLEDManager.ActivateState(ELogitechLEDState.UNCONSCIOUS);
100 }
101
102 //------------------------------------------------------------------------------------------------
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
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 {
154 m_wDeath.SetOpacity(0);
155 m_wDeath.SetMaskProgress(0);
156 }
157 }
158}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ECharacterBloodState
ECharacterResilienceState
SCR_CharacterPerceivableComponentClass m_CharacterController
Widget m_wRoot
void WidgetAnimationBase(Widget w, float speed)
EAnimationCurve
static WidgetAnimationOpacity Opacity(Widget widget, float targetValue, float speed, bool toggleVisibility=false)
static WidgetAnimationAlphaMask AlphaMask(Widget widget, float targetValue, float speed)
static void StopAllAnimations(Widget w)
Definition Math.c:13
Blood - does not receive damage directly, only via scripted events.
override void DisplayStartDraw(IEntity owner)
SCR_CharacterDamageManagerComponent m_DamageManager
void OnAnimCycleComplete(WidgetAnimationBase anim)
override void DisplayControlledEntityChanged(IEntity from, IEntity to)
override void DisplayConsciousnessChanged(bool conscious, bool init=false)
ECharacterLifeState
SCR_FieldOfViewSettings Attribute
Tuple param1