Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MilitarySymbolRuleSet.c
Go to the documentation of this file.
1[BaseContainerProps(configRoot: true)]
3{
4 [Attribute()]
5 protected ref array<ref SCR_GroupIdentityRuleIdentity> m_aRulesIdentity;
6
7 [Attribute()]
8 protected ref array<ref SCR_GroupIdentityRuleDimension> m_aRulesDimension;
9
10 [Attribute()]
11 protected ref array<ref SCR_GroupIdentityRuleIcon> m_aRulesIcon;
12
13 [Attribute()]
14 protected ref array<ref SCR_GroupIdentityRuleAmplifier> m_aRulesAmplifier;
15
16 protected ref SCR_SortedArray<SCR_GroupIdentityRule> m_aRulesIndentitySorted = new SCR_SortedArray<SCR_GroupIdentityRule>();
17 protected ref SCR_SortedArray<SCR_GroupIdentityRule> m_aRulesDimensionSorted = new SCR_SortedArray<SCR_GroupIdentityRule>();
18 protected ref SCR_SortedArray<SCR_GroupIdentityRule> m_aRulesIconSorted = new SCR_SortedArray<SCR_GroupIdentityRule>();
19 protected ref SCR_SortedArray<SCR_GroupIdentityRule> m_aRulesAmplifierSorted = new SCR_SortedArray<SCR_GroupIdentityRule>();
20
35
49 protected void ProcessRules(SCR_SortedArray<SCR_GroupIdentityRule> rules, out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
50 {
51 for (int i = rules.Count() - 1; i >= 0; i--)
52 {
53 if (rules[i].SetSymbol(outSymbol, data))
54 break;
55 }
56 }
58 {
59 for (int i = m_aRulesIdentity.Count() - 1; i >= 0; i--)
60 {
62 }
63 for (int i = m_aRulesDimension.Count() - 1; i >= 0; i--)
64 {
66 }
67 for (int i = m_aRulesIcon.Count() - 1; i >= 0; i--)
68 {
70 }
71 for (int i = m_aRulesAmplifier.Count() - 1; i >= 0; i--)
72 {
74 }
75 }
76};
78{
79 SCR_AIGroup m_Group;
80 SCR_Faction m_Faction;
81 EVehicleType m_VehicleTypes;
82 ref map<EWeaponType, float> m_WeaponTypes = new map<EWeaponType, float>();
84 int m_iMemberCount;
85
86 static SCR_GroupIdentityRuleData CreateData(SCR_Faction faction)
87 {
89 data.m_Faction = faction;
90 return data;
91 }
92 static SCR_GroupIdentityRuleData CreateData(SCR_AIGroup group)
93 {
95
96 data.m_Faction = SCR_Faction.Cast(group.GetFaction());
97 data.m_iMemberCount = group.GetServerAgentsCount();
98
99 //--- Weapon types
100 array<AIAgent> agents = {};
101 data.m_iMemberCount = group.GetAgents(agents);
102 if (data.m_iMemberCount > 0)
103 {
104 IEntity member;
105 BaseWeaponManagerComponent weaponManager;
106 array<WeaponSlotComponent> weapons = {};
107 array<BaseMuzzleComponent> muzzles = {};
108 array<EEditableEntityLabel> labels = {};
109 data.m_WeaponTypes.Clear();
110 for (int i; i < data.m_iMemberCount; i++)
111 {
112 if (!agents[i])
113 continue;
114
115 member = agents[i].GetControlledEntity();
116 weaponManager = BaseWeaponManagerComponent.Cast(member.FindComponent(BaseWeaponManagerComponent));
117 if (weaponManager)
118 {
119 weaponManager.GetWeaponsSlots(weapons);
120 foreach (WeaponSlotComponent slot : weapons)
121 {
122 //--- Get weapon type
123 EWeaponType weaponType = slot.GetWeaponType();
124 if (weaponType == EWeaponType.WT_NONE)
125 continue;
126
127 float weaponTypeCount;
128 if (data.m_WeaponTypes.Find(weaponType, weaponTypeCount))
129 data.m_WeaponTypes[weaponType] = weaponTypeCount + 1;
130 else
131 data.m_WeaponTypes.Insert(weaponType, 1);
132
133 //-- Get muzzle types (e.g., underslung grenade launcher)
134 for (int m = 0, mCount = slot.GetMuzzlesList(muzzles); m < mCount; m++)
135 {
136 //--- Convert muzzle types to weapon types (ToDo: Not hardcoded?)
137 EWeaponType muzzleWeaponType = -1;
138 switch (muzzles[m].GetMuzzleType())
139 {
140 case EMuzzleType.MT_RPGMuzzle:
141 muzzleWeaponType = EWeaponType.WT_ROCKETLAUNCHER;
142 break;
143 case EMuzzleType.MT_UGLMuzzle:
144 muzzleWeaponType = EWeaponType.WT_GRENADELAUNCHER;
145 break;
146 }
147 if (muzzleWeaponType != -1 && muzzleWeaponType != weaponType)
148 {
149 if (data.m_WeaponTypes.Find(muzzleWeaponType, weaponTypeCount))
150 data.m_WeaponTypes[muzzleWeaponType] = weaponTypeCount + 1;
151 else
152 data.m_WeaponTypes.Insert(muzzleWeaponType, 1);
153 }
154 }
155 }
156 }
157
159 if (editableEntity)
160 {
161 SCR_EditableEntityUIInfo info = SCR_EditableEntityUIInfo.Cast(editableEntity.GetInfo());
162 if (info)
163 {
164 labels.Clear();
165 for (int l = 0, lCount = info.GetEntityLabels(labels); l < lCount; l++)
166 {
167 EEditableEntityLabel label = labels[l];
168
169 float labelCount;
170 if (data.m_aLabels.Find(label, labelCount))
171 data.m_aLabels[label] = labelCount + 1;
172 else
173 data.m_aLabels.Insert(label, 1);
174 }
175 }
176 }
177 }
178
179 //--- Convert absolute numbers to ratios
180 //Print("------------");
181 foreach (int weaponType, float count: data.m_WeaponTypes)
182 {
183 data.m_WeaponTypes[weaponType] = count / data.m_iMemberCount;
184 //PrintFormat("%1: %2", typename.EnumToString(EWeaponType, weaponType), m_WeaponTypes[weaponType]);
185 }
186 foreach (int label, float count: data.m_aLabels)
187 {
188 data.m_aLabels[label] = count / data.m_iMemberCount;
189 //PrintFormat("%1: %2", typename.EnumToString(EEditableEntityLabel, label), m_aLabels[label]);
190 }
191 }
192
193 //--- Vehicle types
194 array<IEntity> vehicles = {};
196
197 Vehicle vehicle;
198 for (int i, count = vehicles.Count(); i < count; i++)
199 {
200 vehicle = Vehicle.Cast(vehicles[i]);
201 if (vehicle)
202 data.m_VehicleTypes |= vehicle.m_eVehicleType;
203 }
204 return data;
205 }
206};
207
210{
211 [Attribute()]
212 protected int m_iPriority;
213
215 {
216 return m_iPriority;
217 }
219 {
220 return false;
221 }
222
224 {
225 return true;
226 }
227};
228
230//--- Identity
233{
234 [Attribute("0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EMilitarySymbolIdentity))]
236
237 override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
238 {
239 if (IsCompatible(outSymbol, data))
240 {
241 outSymbol.SetIdentity(m_Identity);
242 return true;
243 }
244 return false;
245 }
246};
249{
250 [Attribute()]
251 protected string m_sFactionKey;
252
253 override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
254 {
255 return data.m_Faction && data.m_Faction.IsInherited(m_sFactionKey);
256 }
257};
258
260//--- Dimension
263{
264 [Attribute("0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EMilitarySymbolDimension))]
266
267 override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
268 {
269 if (IsCompatible(outSymbol, data))
270 {
271 outSymbol.SetDimension(m_Dimension);
272 return true;
273 }
274 return false;
275 }
276};
277
279//--- Icon
282{
283 [Attribute("0", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EMilitarySymbolIcon))]
285
286 override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
287 {
288 if (IsCompatible(outSymbol, data))
289 {
290 outSymbol.SetIcons(m_Icon);
291 return true;
292 }
293 return false;
294 }
295};
298{
299 [Attribute("0", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EWeaponType))]
301
302 [Attribute("0.5", uiwidget: UIWidgets.Slider, params: "0 1 0.01", desc: "Condition is met only if ratio of weapons defined by 'Weapon Type' in the group is higher than this limit.\nE.g., Four-man group with two MGs will have MG ratio of 0.5\nUnarmed will never check ratio.")]
303 protected float m_fMinRatio;
304
305 [Attribute("0", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EWeaponType), desc: "Condition is failed if any of these weapon types have ratio bigger than the one of 'Weapon Type', even when it's above 'Min Limit'.\nUnarmed will never check ratio.")]
306 protected ref array<EWeaponType> m_ComparedWeaponTypes;
307
308 override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
309 {
310 //~ If check for no weapons and weapons are empty it succeeds
311 if (m_WeaponType == EWeaponType.WT_NONE && data.m_WeaponTypes.IsEmpty())
312 return true;
313
314 //--- Check if the ratio is above limit
315 float ratio;
316 if (data.m_WeaponTypes.Find(m_WeaponType, ratio) && ratio >= m_fMinRatio)
317 {
318 //--- Check if the ratio is larger than related ratios (e.g., group of 2x MG and 2x AT is neither MG nor AT, but generic one)
319 float comparedRatio;
320 for (int i = m_ComparedWeaponTypes.Count() - 1; i >= 0; i--)
321 {
322 if (data.m_WeaponTypes.Find(m_ComparedWeaponTypes[i], comparedRatio) && comparedRatio >= ratio)
323 return false;
324 }
325 return true;
326 }
327 return false;
328 }
329};
332{
333 [Attribute("0", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityLabel))]
335
336 [Attribute("0.5", uiwidget: UIWidgets.Slider, params: "0 1 0.01", desc: "Condition is met only if ratio of labels defined by 'Label' in the group is higher than this limit.\nE.g., Four-man group with two medics will have medic ratio of 0.5")]
337 protected float m_fMinRatio;
338
339 [Attribute("0", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityLabel), desc: "Condition is failed if any of these labels have ratio bigger than the one of 'Label', even when it's above 'Min Limit'")]
340 protected ref array<EEditableEntityLabel> m_ComparedLabels;
341
342 override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
343 {
344 //--- Check if the ratio is above limit
345 float ratio;
346 if (data.m_aLabels.Find(m_Label, ratio) && ratio >= m_fMinRatio)
347 {
348 //--- Check if the ratio is larger than related ratios (e.g., group of 2x MG and 2x AT is neither MG nor AT, but generic one)
349 float comparedRatio;
350 for (int i = m_ComparedLabels.Count() - 1; i >= 0; i--)
351 {
352 if (data.m_aLabels.Find(m_ComparedLabels[i], comparedRatio) && comparedRatio >= ratio)
353 return false;
354 }
355 return true;
356 }
357 return false;
358 }
359};
362{
363 [Attribute("0", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EVehicleType))]
365
366 override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
367 {
368 return SCR_Enum.HasPartialFlag(data.m_VehicleTypes, m_VehicleType);
369 }
370};
371
373//--- Amplifier
376{
377 [Attribute("0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EMilitarySymbolAmplifier))]
379
380 override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
381 {
382 if (IsCompatible(outSymbol, data))
383 {
384 outSymbol.SetAmplifier(m_Amplifier);
385 return true;
386 }
387 return false;
388 }
389};
392{
393 [Attribute()]
394 protected int m_iMinCount;
395
396 override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
397 {
398 return data.m_iMemberCount >= m_iMinCount;
399 }
400};
EEditableEntityLabel
EMilitarySymbolIdentity
EMilitarySymbolDimension
EMilitarySymbolIcon
EMilitarySymbolAmplifier
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Get all prefabs that have the spawner data
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
EVehicleType
Definition Vehicle.c:4
proto external Managed FindComponent(typename typeName)
SCR_AIGroupUtilityComponent GetGroupUtilityComponent()
Faction GetFaction()
ref SCR_AIGroupVehicleManager m_VehicleMgr
void GetAllVehicleEntities(array< IEntity > outAllVehicles)
Attribute for setting any flags enum property as custom title.
Definition Attributes.c:418
SCR_UIInfo GetInfo(IEntity owner=null)
int GetEntityLabels(out notnull array< EEditableEntityLabel > entityLabels)
bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
ref array< EEditableEntityLabel > m_ComparedLabels
bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
ref array< EWeaponType > m_ComparedWeaponTypes
bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
ref SCR_SortedArray< SCR_GroupIdentityRule > m_aRulesAmplifierSorted
ref array< ref SCR_GroupIdentityRuleAmplifier > m_aRulesAmplifier
void UpdateSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_AIGroup group)
ref SCR_SortedArray< SCR_GroupIdentityRule > m_aRulesDimensionSorted
ref array< ref SCR_GroupIdentityRuleDimension > m_aRulesDimension
ref SCR_SortedArray< SCR_GroupIdentityRule > m_aRulesIndentitySorted
void UpdateSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_Faction faction)
ref SCR_SortedArray< SCR_GroupIdentityRule > m_aRulesIconSorted
void ProcessRules(SCR_SortedArray< SCR_GroupIdentityRule > rules, out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
ref array< ref SCR_GroupIdentityRuleIdentity > m_aRulesIdentity
ref array< ref SCR_GroupIdentityRuleIcon > m_aRulesIcon
Definition Types.c:486
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
SCR_FieldOfViewSettings Attribute
EWeaponType
Definition EWeaponType.c:13
EMuzzleType
Definition EMuzzleType.c:13