14 class SCR_DamageIntensityHolder
17 protected ref array<ref SCR_DamageIntensityEntry> m_aDamageIntensityEntries;
19 protected ref SCR_SortedArray<SCR_DamageIntensityEntry> m_SortedDamageIntensityEntries;
26 Print(
"'SCR_DamageIntensityEntry' Damage scaled cannot be less than 0!", LogLevel.WARNING);
31 for (
int i = 0, count = m_SortedDamageIntensityEntries.Count(); i < count; i++)
34 entry = m_SortedDamageIntensityEntries.Get(i);
35 if (!entry || !entry.IsValidDamageState(value))
48 if (hitZones.IsEmpty())
51 float healthScaled = 0;
52 foreach (
HitZone hitZone : hitZones)
54 healthScaled += hitZone.GetHealthScaled();
57 return GetValidIntensityEntry(healthScaled / hitZones.Count());
63 return GetValidIntensityEntry(hitZone.GetHealthScaled());
69 HitZone defaultHitZone = damageManager.GetDefaultHitZone();
71 return GetValidIntensityEntry(defaultHitZone.GetHealthScaled());
77 SCR_UIName GetValidIntensityUIInfo(
float value)
82 return entry.GetUiInfo();
88 SCR_UIName GetValidIntensityUIInfo(notnull array<HitZone> hitZones)
93 return entry.GetUiInfo();
104 return entry.GetUiInfo();
110 SCR_UIName GetValidIntensityUIInfo(notnull SCR_DamageManagerComponent damageManager)
115 return entry.GetUiInfo();
126 return entry.GetDamageIntensityType();
137 return entry.GetDamageIntensityType();
148 return entry.GetDamageIntensityType();
159 return entry.GetDamageIntensityType();
168 for (
int i = 0, count = m_SortedDamageIntensityEntries.Count(); i < count; i++)
170 entry = m_SortedDamageIntensityEntries.Get(i);
171 if (entry && entry.GetDamageIntensityType() ==
type)
183 return entry.GetUiInfo();
193 return uiInfo.GetName();
199 void SCR_DamageIntensityHolder()
201 m_SortedDamageIntensityEntries =
new SCR_SortedArray<SCR_DamageIntensityEntry>();
204 if (!entry || !entry.m_bIsEnabled || !entry.GetUiInfo())
207 m_SortedDamageIntensityEntries.Insert(entry.m_iOrder, entry);
222 [
Attribute(
desc:
"A lower order means it is checked before any with a higher order")]
225 [
Attribute(
desc:
"Damage state UI info. If left null the entry will be ignored")]
228 [
Attribute(
desc:
"If value (generally health scaled) is equal or greater than min and smaller (or equal and smaller if 1 or 0) than max than this intensity entry is valid",
params:
"0 inf")]
229 protected float m_fMaxValue;
231 [
Attribute(
desc:
"If value (generally health scaled) is equal or greater than min and smaller than max than this intensity entry is valid. Generally this is damage scaled but does not need to be",
params:
"0 inf")]
232 protected float m_fMinValue;
243 return m_eDamageIntensityType;
247 bool IsValidDamageState(
float value)
249 if (m_fMaxValue == 0)
250 return (value >= m_fMinValue && value <= m_fMaxValue);
252 return (value >= m_fMinValue && value < m_fMaxValue);
258 if (m_fMinValue > m_fMaxValue)
260 Print(
"'SCR_DamageIntensityEntry': '" +
typename.EnumToString(
SCR_EDamageIntensityType, m_eDamageIntensityType) +
"' has a min value that is greater than max value! Min value is set the same as max value", LogLevel.WARNING);
261 m_fMinValue = m_fMaxValue;