4 [
Attribute(
"{01E150D909447632}Configs/Damage/DamageStateConfig.conf",
desc:
"Config to get visual data from",
params:
"conf class=SCR_DamageStateConfig")]
7 [
Attribute(
"{19A8157C2CA02EFB}UI/layouts/Damage/DamageStateIcon.layout",
desc:
"Layout to create and apply visuals to",
params:
"layout")]
8 protected ResourceName m_sStateIconLayout;
11 protected float m_fConditionIconSize;
13 [
Attribute(
"0",
desc:
"If true show death icon rather then destroy icon")]
14 protected bool m_bDiesOnDestroy;
17 protected Widget m_ConditionHolder;
18 protected ref array<EDamageType> m_aActiveDamageTypes = {};
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;
26 protected Widget m_wLabel;
35 return super.CreateDetail(entity, parent, label, setFrameslot);
39 override bool NeedUpdate()
47 bool isDestroyed, isUnconscious, conditionChanged;
48 array<EDamageType> activeCondition = {};
51 if (!HasConditions(isDestroyed, isUnconscious, activeCondition, conditionChanged))
54 if (m_bHasNoConditions)
57 m_wLabel.SetVisible(
false);
58 m_ConditionHolder.SetVisible(
false);
59 m_bHasNoConditions =
true;
63 else if (m_bHasNoConditions)
65 m_wLabel.SetVisible(
true);
66 m_ConditionHolder.SetVisible(
true);
67 m_bHasNoConditions =
false;
77 m_bIsDestroyed =
true;
83 m_bIsDestroyed =
false;
96 protected void CreateConditionIcons(array<EDamageType> activeCondition,
bool isUnconscious)
98 ClearConditionHolder();
99 Widget damageStateWidget;
104 damageStateWidget =
GetGame().GetWorkspace().CreateWidgets(m_sStateIconLayout, m_ConditionHolder);
105 if (!damageStateWidget)
107 Print(
"'SCR_EntityConditionTooltipDetail' Unable to create icon widget!",LogLevel.ERROR);
112 if (!damageStateUIComponent)
114 Print(
"'SCR_EntityConditionTooltipDetail' Unable to create find SCR_DamageStateUIComponent on entry!",LogLevel.ERROR);
118 damageStateUIComponent.SetSize(m_fConditionIconSize);
119 damageStateUIComponent.SetVisuals(m_DamageStateConfig.GetUnconciousStateUiInfo());
126 damageStateWidget =
GetGame().GetWorkspace().CreateWidgets(m_sStateIconLayout, m_ConditionHolder);
128 if (!damageStateWidget)
130 Print(
"'SCR_EntityConditionTooltipDetail' Unable to create icon widget!",LogLevel.ERROR);
135 if (!damageStateUIComponent)
137 Print(
"'SCR_EntityConditionTooltipDetail' Unable to create find SCR_DamageStateUIComponent on entry!",LogLevel.ERROR);
141 damageStateUIComponent.SetSize(m_fConditionIconSize);
142 damageStateUIComponent.SetVisuals(damageType);
147 protected void CreateDestroyIcon()
149 ClearConditionHolder();
151 Widget damageStateWidget =
GetGame().GetWorkspace().CreateWidgets(m_sStateIconLayout, m_ConditionHolder);
152 if (!damageStateWidget)
154 Print(
"'SCR_EntityConditionTooltipDetail' Unable to create icon widget!",LogLevel.ERROR);
159 if (!damageStateUIComponent)
161 Print(
"'SCR_EntityConditionTooltipDetail' Unable to create find SCR_DamageStateUIComponent on entry!",LogLevel.ERROR);
165 damageStateUIComponent.SetSize(m_fConditionIconSize);
167 if (!m_bDiesOnDestroy)
168 damageStateUIComponent.SetVisuals(m_DamageStateConfig.GetDestroyedStateUiInfo());
170 damageStateUIComponent.SetVisuals(m_DamageStateConfig.GetDeathStateUiInfo());
189 protected void ClearConditionHolder()
191 Widget child = m_ConditionHolder.GetChildren();
196 child = child.GetSibling();
197 childtemp.RemoveFromHierarchy();
204 if (!widget || !m_DamageStateConfig || m_sStateIconLayout.IsEmpty())
207 m_ConditionHolder = widget;
213 if (m_DamageStateConfig.GetDamageStateInfoArray(m_aDamageStateUiInfo) <= 0)
216 bool isDestroyed, isUnconscious, conditionChanged;
217 array<EDamageType> activeCondition = {};
219 if (HasConditions(isDestroyed, isUnconscious, activeCondition, conditionChanged,
true))
221 UpdateDetail(entity);
229 protected bool HasConditions(out
bool isDestroyed, out
bool isUnconscious, out notnull array<EDamageType> activeCondition, out
bool conditionChanged,
bool onlyCheckOneTrue =
false)
231 bool hasCondition =
false;
240 ChimeraCharacter
char = ChimeraCharacter.Cast(
m_DamageManager.GetOwner());
243 CharacterControllerComponent controller = CharacterControllerComponent.Cast(
char.
GetCharacterController());
246 isUnconscious =
true;
248 if (onlyCheckOneTrue)
259 activeCondition.Insert(damageStateInfo.m_eDamageType);
261 if (onlyCheckOneTrue)
267 if (!m_aActiveDamageTypes.Contains(damageStateInfo.m_eDamageType))
268 conditionChanged =
true;
275 if (activeCondition.Count() != m_aActiveDamageTypes.Count())
276 conditionChanged =
true;
278 if (conditionChanged)
279 m_aActiveDamageTypes.Copy(activeCondition);