Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DamageIntensityHolder.c
Go to the documentation of this file.
1//------------------------------------------------------------------------------------------------
10
11//------------------------------------------------------------------------------------------------
13[BaseContainerProps(configRoot: true)]
14class SCR_DamageIntensityHolder
17 protected ref array<ref SCR_DamageIntensityEntry> m_aDamageIntensityEntries;
19 protected ref SCR_SortedArray<SCR_DamageIntensityEntry> m_SortedDamageIntensityEntries;
20
21 //------------------------------------------------------------------------------------------------
22 SCR_DamageIntensityEntry GetValidIntensityEntry(float value)
23 {
24 if (value < 0)
25 {
26 Print("'SCR_DamageIntensityEntry' Damage scaled cannot be less than 0!", LogLevel.WARNING);
27 value = 0;
28 }
29
31 for (int i = 0, count = m_SortedDamageIntensityEntries.Count(); i < count; i++)
32 {
33 //~ Check if entry is valid damage state
34 entry = m_SortedDamageIntensityEntries.Get(i);
35 if (!entry || !entry.IsValidDamageState(value))
36 continue;
37
38 //~ Valid entry
39 return entry;
40 }
41
42 return null;
43 }
44
45 //------------------------------------------------------------------------------------------------
46 SCR_DamageIntensityEntry GetValidIntensityEntry(notnull array<HitZone> hitZones)
47 {
48 if (hitZones.IsEmpty())
49 return null;
50
51 float healthScaled = 0;
52 SCR_FlammableHitZone flammableHitZone;
53 SCR_DamageManagerComponent hitZoneContainer;
54 foreach (HitZone hitZone : hitZones)
55 {
56 if (!hitZone)
57 continue;
58
59 healthScaled += hitZone.GetHealthScaled();
60 flammableHitZone = SCR_FlammableHitZone.Cast(hitZone);
61 if (!flammableHitZone)
62 continue;
63
64 hitZoneContainer = SCR_DamageManagerComponent.Cast(flammableHitZone.GetHitZoneContainer());
65 if (!hitZoneContainer || !hitZoneContainer.IsOnFire(flammableHitZone))
66 continue;
67
68 healthScaled = 0;
69 break;
70 }
71
72 return GetValidIntensityEntry(healthScaled / hitZones.Count());
73 }
74
75 //------------------------------------------------------------------------------------------------
76 SCR_DamageIntensityEntry GetValidIntensityEntry(notnull HitZone hitZone)
77 {
78 return GetValidIntensityEntry(hitZone.GetHealthScaled());
79 }
80
81 //------------------------------------------------------------------------------------------------
82 SCR_DamageIntensityEntry GetValidIntensityEntry(notnull SCR_DamageManagerComponent damageManager)
83 {
84 HitZone defaultHitZone = damageManager.GetDefaultHitZone();
85 return GetValidIntensityEntry(defaultHitZone.GetHealthScaled());
86 }
87
88 //------------------------------------------------------------------------------------------------
89 SCR_UIName GetValidIntensityUIInfo(float value)
90 {
91 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(value);
92
93 if (entry)
94 return entry.GetUiInfo();
95
96 return null;
97 }
98
99 //------------------------------------------------------------------------------------------------
100 SCR_UIName GetValidIntensityUIInfo(notnull array<HitZone> hitZones)
101 {
102 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZones);
103
104 if (entry)
105 return entry.GetUiInfo();
106
107 return null;
108 }
109
110 //------------------------------------------------------------------------------------------------
111 SCR_UIName GetValidIntensityUIInfo(notnull HitZone hitZone)
112 {
113 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZone);
114
115 if (entry)
116 return entry.GetUiInfo();
117
118 return null;
119 }
120
121 //------------------------------------------------------------------------------------------------
122 SCR_UIName GetValidIntensityUIInfo(notnull SCR_DamageManagerComponent damageManager)
123 {
124 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(damageManager);
125
126 if (entry)
127 return entry.GetUiInfo();
128
129 return null;
130 }
131
132 //------------------------------------------------------------------------------------------------
133 SCR_EDamageIntensityType GetValidIntensityType(float value)
134 {
135 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(value);
136
137 if (entry)
138 return entry.GetDamageIntensityType();
139
140 return SCR_EDamageIntensityType.NO_DAMAGE;
141 }
142
143 //------------------------------------------------------------------------------------------------
144 SCR_EDamageIntensityType GetValidIntensityType(notnull array<HitZone> hitZones)
145 {
146 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZones);
147
148 if (entry)
149 return entry.GetDamageIntensityType();
150
151 return SCR_EDamageIntensityType.NO_DAMAGE;
152 }
153
154 //------------------------------------------------------------------------------------------------
155 SCR_EDamageIntensityType GetValidIntensityType(notnull HitZone hitZone)
156 {
157 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(hitZone);
158
159 if (entry)
160 return entry.GetDamageIntensityType();
161
162 return SCR_EDamageIntensityType.NO_DAMAGE;
163 }
164
165 //------------------------------------------------------------------------------------------------
166 SCR_EDamageIntensityType GetValidIntensityType(notnull SCR_DamageManagerComponent damageManager)
167 {
168 SCR_DamageIntensityEntry entry = GetValidIntensityEntry(damageManager);
169
170 if (entry)
171 return entry.GetDamageIntensityType();
172
173 return SCR_EDamageIntensityType.NO_DAMAGE;
174 }
175
176 //------------------------------------------------------------------------------------------------
177 SCR_DamageIntensityEntry GetIntensityEntry(SCR_EDamageIntensityType type)
178 {
179 SCR_DamageIntensityEntry entry;
180 for (int i = 0, count = m_SortedDamageIntensityEntries.Count(); i < count; i++)
181 {
182 entry = m_SortedDamageIntensityEntries.Get(i);
183 if (entry && entry.GetDamageIntensityType() == type)
184 return entry;
185 }
186
187 return null;
188 }
189
190 //------------------------------------------------------------------------------------------------
191 SCR_UIName GetIntensityUIInfo(SCR_EDamageIntensityType type)
192 {
193 SCR_DamageIntensityEntry entry = GetIntensityEntry(type);
194 if (entry)
195 return entry.GetUiInfo();
196
197 return null;
198 }
199
200 //------------------------------------------------------------------------------------------------
201 string GetIntensityName(SCR_EDamageIntensityType type)
202 {
203 SCR_UIName uiInfo = GetIntensityUIInfo(type);
204 if (uiInfo)
205 return uiInfo.GetName();
206
207 return string.Empty;
208 }
209
210 //------------------------------------------------------------------------------------------------
211 void SCR_DamageIntensityHolder()
212 {
213 m_SortedDamageIntensityEntries = new SCR_SortedArray<SCR_DamageIntensityEntry>();
214 foreach (SCR_DamageIntensityEntry entry : m_aDamageIntensityEntries)
215 {
216 if (!entry || !entry.m_bIsEnabled || !entry.GetUiInfo())
217 continue;
218
219 m_SortedDamageIntensityEntries.Insert(entry.m_iOrder, entry);
220 }
221 }
222}
223
224//------------------------------------------------------------------------------------------------
227{
228 [Attribute(desc: "The intensity enum associated with the min and max damage", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(SCR_EDamageIntensityType))]
230
231 [Attribute("1", desc: "If false it will be ignored")]
233
234 [Attribute(desc: "A lower order means it is checked before any with a higher order")]
236
237 [Attribute(desc: "Damage state UI info. If left null the entry will be ignored")]
238 protected ref SCR_UIName m_UiInfo;
239
240 [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")]
241 protected float m_fMaxValue;
242
243 [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")]
244 protected float m_fMinValue;
245
246 //------------------------------------------------------------------------------------------------
248 {
249 return m_UiInfo;
250 }
251
252 //------------------------------------------------------------------------------------------------
257
258 //------------------------------------------------------------------------------------------------
259 bool IsValidDamageState(float value)
260 {
261 if (m_fMaxValue == 0)
262 return (value >= m_fMinValue && value <= m_fMaxValue);
263 else
264 return (value >= m_fMinValue && value < m_fMaxValue);
265 }
266
267 //------------------------------------------------------------------------------------------------
269 {
271 {
272 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);
274 }
275 }
276}
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
enum SCR_EAITalkRequestState MEDIUM
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
EDamageType type
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
float m_fMaxValue
float m_fMinValue
ref SCR_UIName m_UiInfo
SCR_UIName GetUiInfo()
void SCR_DamageIntensityEntry()
int m_iOrder
bool IsValidDamageState(float value)
SCR_EDamageIntensityType GetDamageIntensityType()
SCR_EDamageIntensityType m_eDamageIntensityType
bool m_bIsEnabled
LocalizedString GetName()
Definition SCR_UIName.c:31
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