Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_EntityConditionTooltipDetail.c
Go to the documentation of this file.
3{
4 [Attribute("{01E150D909447632}Configs/Damage/DamageStateConfig.conf", desc: "Config to get visual data from", params: "conf class=SCR_DamageStateConfig")]
6
7 [Attribute("{19A8157C2CA02EFB}UI/layouts/Damage/DamageStateIcon.layout", desc: "Layout to create and apply visuals to", params: "layout")]
9
10 [Attribute("32", desc: "Size of condition icons")]
11 protected float m_fConditionIconSize;
12
13 [Attribute("0", desc: "If true show death icon rather then destroy icon")]
14 protected bool m_bDiesOnDestroy;
15
16 //~ Ref
18 protected ref array<EDamageType> m_aActiveDamageTypes = {};
19
20 //~ States
21 protected ref array<ref SCR_DamageStateInfo> m_aDamageStateUiInfo = {};
22 protected bool m_bIsDestroyed = false;
23 protected bool m_bIsUnconscious = false;
24 protected bool m_bHasNoConditions = false;
25
26 protected Widget m_wLabel;
27
29
30 //------------------------------------------------------------------------------------------------
31 override bool CreateDetail(SCR_EditableEntityComponent entity, Widget parent, TextWidget label, bool setFrameslot = true)
32 {
33 m_wLabel = label;
34
35 return super.CreateDetail(entity, parent, label, setFrameslot);
36 }
37
38 //------------------------------------------------------------------------------------------------
39 override bool NeedUpdate()
40 {
41 return m_ConditionHolder && m_DamageManager && (m_DamageManager.GetState() != EDamageState.DESTROYED || (m_DamageManager.GetState() == EDamageState.DESTROYED && !m_bIsDestroyed) && !m_aDamageStateUiInfo.IsEmpty());// && m_MultiLineTextWidget;
42 }
43
44 //------------------------------------------------------------------------------------------------
46 {
47 bool isDestroyed, isUnconscious, conditionChanged;
48 array<EDamageType> activeCondition = {};
49
50 //~ If has no conditions but is active hide it
51 if (!HasConditions(isDestroyed, isUnconscious, activeCondition, conditionChanged))
52 {
53 //~ Already hidden
55 return;
56
57 m_wLabel.SetVisible(false);
58 m_ConditionHolder.SetVisible(false);
59 m_bHasNoConditions = true;
60 return;
61 }
62 //~ Show again
63 else if (m_bHasNoConditions)
64 {
65 m_wLabel.SetVisible(true);
66 m_ConditionHolder.SetVisible(true);
67 m_bHasNoConditions = false;
68 }
69
70 //~ If destroyed
71 if (isDestroyed)
72 {
73 //~ Already set is destroyed
75 return;
76
77 m_bIsDestroyed = true;
78
80 }
81 else
82 {
83 m_bIsDestroyed = false;
84 }
85
86 //~ Conditions still the same
87 if (!conditionChanged && m_bIsUnconscious == isUnconscious)
88 return;
89
90 m_bIsUnconscious = isUnconscious;
91
92 CreateConditionIcons(activeCondition, m_bIsUnconscious);
93 }
94
95 //------------------------------------------------------------------------------------------------
96 protected void CreateConditionIcons(array<EDamageType> activeCondition, bool isUnconscious)
97 {
99 Widget damageStateWidget;
100 SCR_DamageStateUIComponent damageStateUIComponent;
101
102 if (isUnconscious)
103 {
104 damageStateWidget = GetGame().GetWorkspace().CreateWidgets(m_sStateIconLayout, m_ConditionHolder);
105 if (!damageStateWidget)
106 {
107 Print("'SCR_EntityConditionTooltipDetail' Unable to create icon widget!",LogLevel.ERROR);
108 return;
109 }
110
111 damageStateUIComponent = SCR_DamageStateUIComponent.Cast(damageStateWidget.FindHandler(SCR_DamageStateUIComponent));
112 if (!damageStateUIComponent)
113 {
114 Print("'SCR_EntityConditionTooltipDetail' Unable to create find SCR_DamageStateUIComponent on entry!",LogLevel.ERROR);
115 return;
116 }
117
118 damageStateUIComponent.SetSize(m_fConditionIconSize);
119 damageStateUIComponent.SetVisuals(m_DamageStateConfig.GetUnconciousStateUiInfo());
120 }
121
122 //~ Todo: Currently all icons are on one line. This might cause an overflow if more conditions are added. Make sure that the m_Layout used is a vertical instead of a horizontal then add horizontal for each x amount and use the horizontal for m_ConditionHolder
123
124 foreach (EDamageType damageType: activeCondition)
125 {
126 damageStateWidget = GetGame().GetWorkspace().CreateWidgets(m_sStateIconLayout, m_ConditionHolder);
127
128 if (!damageStateWidget)
129 {
130 Print("'SCR_EntityConditionTooltipDetail' Unable to create icon widget!",LogLevel.ERROR);
131 return;
132 }
133
134 damageStateUIComponent = SCR_DamageStateUIComponent.Cast(damageStateWidget.FindHandler(SCR_DamageStateUIComponent));
135 if (!damageStateUIComponent)
136 {
137 Print("'SCR_EntityConditionTooltipDetail' Unable to create find SCR_DamageStateUIComponent on entry!",LogLevel.ERROR);
138 return;
139 }
140
141 damageStateUIComponent.SetSize(m_fConditionIconSize);
142 damageStateUIComponent.SetVisuals(damageType);
143 }
144 }
145
146 //------------------------------------------------------------------------------------------------
147 protected void CreateDestroyIcon()
148 {
150
151 Widget damageStateWidget = GetGame().GetWorkspace().CreateWidgets(m_sStateIconLayout, m_ConditionHolder);
152 if (!damageStateWidget)
153 {
154 Print("'SCR_EntityConditionTooltipDetail' Unable to create icon widget!",LogLevel.ERROR);
155 return;
156 }
157
158 SCR_DamageStateUIComponent damageStateUIComponent = SCR_DamageStateUIComponent.Cast(damageStateWidget.FindHandler(SCR_DamageStateUIComponent));
159 if (!damageStateUIComponent)
160 {
161 Print("'SCR_EntityConditionTooltipDetail' Unable to create find SCR_DamageStateUIComponent on entry!",LogLevel.ERROR);
162 return;
163 }
164
165 damageStateUIComponent.SetSize(m_fConditionIconSize);
166
167 if (!m_bDiesOnDestroy)
168 damageStateUIComponent.SetVisuals(m_DamageStateConfig.GetDestroyedStateUiInfo());
169 else
170 damageStateUIComponent.SetVisuals(m_DamageStateConfig.GetDeathStateUiInfo());
171 }
172
173// //------------------------------------------------------------------------------------------------
174// protected void CreateConditionText(LocalizedString text)
175// {
176// ClearConditionHolder();
177//
178// TextWidget textWidget = TextWidget.Cast(GetGame().GetWorkspace().CreateWidgets(m_sStateTextOnlyLayout, m_ConditionHolder));
179// if (!textWidget)
180// {
181// Print("'SCR_EntityConditionTooltipDetail' Unable to create text widget!",LogLevel.ERROR);
182// return;
183// }
184//
185// textWidget.SetText(text);
186// }
187
188 //------------------------------------------------------------------------------------------------
189 protected void ClearConditionHolder()
190 {
191 Widget child = m_ConditionHolder.GetChildren();
192 Widget childtemp;
193 while (child)
194 {
195 childtemp = child;
196 child = child.GetSibling();
197 childtemp.RemoveFromHierarchy();
198 }
199 }
200
201 //------------------------------------------------------------------------------------------------
202 override bool InitDetail(SCR_EditableEntityComponent entity, Widget widget)
203 {
204 if (!widget || !m_DamageStateConfig || m_sStateIconLayout.IsEmpty())
205 return false;
206
207 m_ConditionHolder = widget;
208
209 m_DamageManager = DamageManagerComponent.Cast(entity.GetOwner().FindComponent(DamageManagerComponent));
210 if (!m_DamageManager)
211 return false;
212
213 if (m_DamageStateConfig.GetDamageStateInfoArray(m_aDamageStateUiInfo) <= 0)
214 return false;
215
216 bool isDestroyed, isUnconscious, conditionChanged;
217 array<EDamageType> activeCondition = {};
218
219 if (HasConditions(isDestroyed, isUnconscious, activeCondition, conditionChanged, true))
220 {
221 UpdateDetail(entity);
222 return true;
223 }
224
225 return false;
226 }
227
228 //------------------------------------------------------------------------------------------------
229 protected bool HasConditions(out bool isDestroyed, out bool isUnconscious, out notnull array<EDamageType> activeCondition, out bool conditionChanged, bool onlyCheckOneTrue = false)
230 {
231 bool hasCondition = false;
232
233 //~ Always return if destroyed as no need to check the other conditions
234 if (m_DamageManager.GetState() == EDamageState.DESTROYED)
235 {
236 isDestroyed = true;
237 return true;
238 }
239
240 ChimeraCharacter char = ChimeraCharacter.Cast(m_DamageManager.GetOwner());
241 if (char)
242 {
243 CharacterControllerComponent controller = char.GetCharacterController();
244 if (controller.GetLifeState() == ECharacterLifeState.INCAPACITATED)
245 {
246 isUnconscious = true;
247
248 if (onlyCheckOneTrue)
249 return true;
250 else
251 hasCondition = true;
252 }
253 }
254
255 bool isDamagedOverTime;
256 SCR_CharacterDamageManagerComponent characterDamageManager;
257
258 foreach (SCR_DamageStateInfo damageStateInfo: m_aDamageStateUiInfo)
259 {
260 if (damageStateInfo.m_eDamageType != EDamageType.BLEEDING)
261 {
262 isDamagedOverTime = m_DamageManager.IsDamagedOverTime(damageStateInfo.m_eDamageType);
263 }
264 else
265 {
266 characterDamageManager = SCR_CharacterDamageManagerComponent.Cast(m_DamageManager);
267 isDamagedOverTime = characterDamageManager && characterDamageManager.IsBleeding();
268 }
269
270 if (isDamagedOverTime)
271 {
272 activeCondition.Insert(damageStateInfo.m_eDamageType);
273
274 if (onlyCheckOneTrue)
275 {
276 return true;
277 }
278 else
279 {
280 if (!m_aActiveDamageTypes.Contains(damageStateInfo.m_eDamageType))
281 conditionChanged = true;
282
283 hasCondition = true;
284 }
285 }
286 }
287
288 if (activeCondition.Count() != m_aActiveDamageTypes.Count())
289 conditionChanged = true;
290
291 if (conditionChanged)
292 m_aActiveDamageTypes.Copy(activeCondition);
293
294 return hasCondition;
295 }
296}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_KeyBindingFilter BaseContainerCustomTitleField("m_sBindString")
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
bool IsBleeding()
the official and globally used way of checking if bleeding tests for any PERSISTENT damage effects of...
void SetVisuals(EDamageType damageType)
bool HasConditions(out bool isDestroyed, out bool isUnconscious, out notnull array< EDamageType > activeCondition, out bool conditionChanged, bool onlyCheckOneTrue=false)
override void UpdateDetail(SCR_EditableEntityComponent entity)
void CreateConditionIcons(array< EDamageType > activeCondition, bool isUnconscious)
override bool CreateDetail(SCR_EditableEntityComponent entity, Widget parent, TextWidget label, bool setFrameslot=true)
override bool InitDetail(SCR_EditableEntityComponent entity, Widget widget)
ref array< ref SCR_DamageStateInfo > m_aDamageStateUiInfo
ECharacterLifeState
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute
EDamageType
Definition EDamageType.c:13
EDamageState