Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
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 
26  void UpdateSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_Faction faction)
27  {
29 
30  ProcessRules(m_aRulesIndentitySorted, outSymbol, data);
31  ProcessRules(m_aRulesDimensionSorted, outSymbol, data);
32  ProcessRules(m_aRulesIconSorted, outSymbol, data);
33  ProcessRules(m_aRulesAmplifierSorted, outSymbol, data);
34  }
40  void UpdateSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_AIGroup group)
41  {
43 
44  ProcessRules(m_aRulesIndentitySorted, outSymbol, data);
45  ProcessRules(m_aRulesDimensionSorted, outSymbol, data);
46  ProcessRules(m_aRulesIconSorted, outSymbol, data);
47  ProcessRules(m_aRulesAmplifierSorted, outSymbol, data);
48  }
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  {
61  m_aRulesIndentitySorted.Insert(m_aRulesIdentity[i].GetPriority(), m_aRulesIdentity[i]);
62  }
63  for (int i = m_aRulesDimension.Count() - 1; i >= 0; i--)
64  {
65  m_aRulesDimensionSorted.Insert(m_aRulesDimension[i].GetPriority(), m_aRulesDimension[i]);
66  }
67  for (int i = m_aRulesIcon.Count() - 1; i >= 0; i--)
68  {
69  m_aRulesIconSorted.Insert(m_aRulesIcon[i].GetPriority(), m_aRulesIcon[i]);
70  }
71  for (int i = m_aRulesAmplifier.Count() - 1; i >= 0; i--)
72  {
73  m_aRulesAmplifierSorted.Insert(m_aRulesAmplifier[i].GetPriority(), m_aRulesAmplifier[i]);
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>();
83  ref map<EEditableEntityLabel, float> m_aLabels = new map<EEditableEntityLabel, 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.GetAgentsCount();
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 
158  SCR_EditableEntityComponent editableEntity = SCR_EditableEntityComponent.Cast(member.FindComponent(SCR_EditableEntityComponent));
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 = {};
195  Vehicle vehicle;
196  for (int i, count = group.GetUsableVehicles(vehicles); i < count; i++)
197  {
198  vehicle = Vehicle.Cast(vehicles[i]);
199  if (vehicle)
200  data.m_VehicleTypes |= vehicle.m_eVehicleType;
201  }
202  return data;
203  }
204 };
205 
208 {
209  [Attribute()]
210  protected int m_iPriority;
211 
212  int GetPriority()
213  {
214  return m_iPriority;
215  }
216  bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
217  {
218  return false;
219  }
220 
221  protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
222  {
223  return true;
224  }
225 };
226 
228 //--- Identity
231 {
232  [Attribute("0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EMilitarySymbolIdentity))]
233  protected EMilitarySymbolIdentity m_Identity;
234 
235  override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
236  {
237  if (IsCompatible(outSymbol, data))
238  {
239  outSymbol.SetIdentity(m_Identity);
240  return true;
241  }
242  return false;
243  }
244 };
247 {
248  [Attribute()]
249  protected string m_sFactionKey;
250 
251  override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
252  {
253  return data.m_Faction && data.m_Faction.IsInherited(m_sFactionKey);
254  }
255 };
256 
258 //--- Dimension
261 {
262  [Attribute("0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EMilitarySymbolDimension))]
263  protected EMilitarySymbolDimension m_Dimension;
264 
265  override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
266  {
267  if (IsCompatible(outSymbol, data))
268  {
269  outSymbol.SetDimension(m_Dimension);
270  return true;
271  }
272  return false;
273  }
274 };
275 
277 //--- Icon
280 {
281  [Attribute("0", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EMilitarySymbolIcon))]
282  protected EMilitarySymbolIcon m_Icon;
283 
284  override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
285  {
286  if (IsCompatible(outSymbol, data))
287  {
288  outSymbol.SetIcons(m_Icon);
289  return true;
290  }
291  return false;
292  }
293 };
296 {
297  [Attribute("0", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EWeaponType))]
298  protected EWeaponType m_WeaponType;
299 
300  [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")]
301  protected float m_fMinRatio;
302 
303  [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'")]
304  protected ref array<EWeaponType> m_ComparedWeaponTypes;
305 
306  override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
307  {
308  //--- Check if the ratio is above limit
309  float ratio;
310  if (data.m_WeaponTypes.Find(m_WeaponType, ratio) && ratio >= m_fMinRatio)
311  {
312  //--- 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)
313  float comparedRatio;
314  for (int i = m_ComparedWeaponTypes.Count() - 1; i >= 0; i--)
315  {
316  if (data.m_WeaponTypes.Find(m_ComparedWeaponTypes[i], comparedRatio) && comparedRatio >= ratio)
317  return false;
318  }
319  return true;
320  }
321  return false;
322  }
323 };
326 {
327  [Attribute("0", uiwidget: UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(EEditableEntityLabel))]
328  protected EEditableEntityLabel m_Label;
329 
330  [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")]
331  protected float m_fMinRatio;
332 
333  [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'")]
334  protected ref array<EEditableEntityLabel> m_ComparedLabels;
335 
336  override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
337  {
338  //--- Check if the ratio is above limit
339  float ratio;
340  if (data.m_aLabels.Find(m_Label, ratio) && ratio >= m_fMinRatio)
341  {
342  //--- 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)
343  float comparedRatio;
344  for (int i = m_ComparedLabels.Count() - 1; i >= 0; i--)
345  {
346  if (data.m_aLabels.Find(m_ComparedLabels[i], comparedRatio) && comparedRatio >= ratio)
347  return false;
348  }
349  return true;
350  }
351  return false;
352  }
353 };
356 {
357  [Attribute("0", uiwidget: UIWidgets.Flags, enums: ParamEnumArray.FromEnum(EVehicleType))]
358  protected EVehicleType m_VehicleType;
359 
360  override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
361  {
362  return SCR_Enum.HasPartialFlag(data.m_VehicleTypes, m_VehicleType);
363  }
364 };
365 
367 //--- Amplifier
370 {
371  [Attribute("0", uiwidget: UIWidgets.SearchComboBox, enums: ParamEnumArray.FromEnum(EMilitarySymbolAmplifier))]
372  protected EMilitarySymbolAmplifier m_Amplifier;
373 
374  override bool SetSymbol(out notnull SCR_MilitarySymbol outSymbol, SCR_GroupIdentityRuleData data)
375  {
376  if (IsCompatible(outSymbol, data))
377  {
378  outSymbol.SetAmplifier(m_Amplifier);
379  return true;
380  }
381  return false;
382  }
383 };
386 {
387  [Attribute()]
388  protected int m_iMinCount;
389 
390  override protected bool IsCompatible(notnull SCR_MilitarySymbol symbol, SCR_GroupIdentityRuleData data)
391  {
392  return data.m_iMemberCount >= m_iMinCount;
393  }
394 };
EEditableEntityLabel
EEditableEntityLabel
Definition: EEditableEntityLabel.c:1
SCR_MilitarySymbol
Definition: SCR_MilitarySymbol.c:2
SCR_Enum
Definition: SCR_Enum.c:1
SCR_GroupIdentityRuleData
Definition: SCR_MilitarySymbolRuleSet.c:77
SCR_BaseContainerCustomTitleEnum
class SCR_CampaignHintStorage SCR_BaseContainerCustomTitleEnum(EHint, "m_eHintId")
Definition: SCR_CampaignHintStorage.c:22
SCR_EditableEntityUIInfo
Definition: SCR_EditableEntityUIInfo.c:2
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
WeaponSlotComponent
Definition: WeaponSlotComponent.c:12
SCR_GroupIdentityRuleIconLabel
Definition: SCR_MilitarySymbolRuleSet.c:325
SCR_GroupIdentityRuleIconVehicle
Definition: SCR_MilitarySymbolRuleSet.c:355
m_sFactionKey
protected FactionKey m_sFactionKey
Definition: SCR_ScenarioFrameworkLayerBase.c:25
SCR_MilitarySymbolRuleSet
Definition: SCR_MilitarySymbolRuleSet.c:2
GetPriority
int GetPriority()
Definition: SCR_BaseManualCameraComponent.c:107
SCR_GroupIdentityRule
Definition: SCR_MilitarySymbolRuleSet.c:207
SCR_BaseContainerCustomTitleFlags
Attribute for setting any flags enum property as custom title.
Definition: Attributes.c:344
EMilitarySymbolIdentity
EMilitarySymbolIdentity
Definition: EMilitarySymbol.c:1
SCR_GroupIdentityRuleIdentity
Definition: SCR_MilitarySymbolRuleSet.c:230
SCR_GroupIdentityRuleAmplifierCount
Definition: SCR_MilitarySymbolRuleSet.c:385
SCR_GroupIdentityRuleDimension
Definition: SCR_MilitarySymbolRuleSet.c:260
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_GroupIdentityRuleAmplifier
Definition: SCR_MilitarySymbolRuleSet.c:369
EMilitarySymbolAmplifier
EMilitarySymbolAmplifier
Definition: EMilitarySymbol.c:63
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
EMuzzleType
EMuzzleType
Definition: EMuzzleType.c:12
SCR_AIGroup
Definition: SCR_AIGroup.c:68
EWeaponType
EWeaponType
Definition: EWeaponType.c:12
EMilitarySymbolDimension
EMilitarySymbolDimension
Definition: EMilitarySymbol.c:14
data
Get all prefabs that have the spawner data
Definition: SCR_EntityCatalogManagerComponent.c:305
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_GroupIdentityRuleIcon
Definition: SCR_MilitarySymbolRuleSet.c:279
m_iPriority
int m_iPriority
Definition: SCR_AITalkRequest.c:28
SCR_GroupIdentityRuleIdentityFaction
Definition: SCR_MilitarySymbolRuleSet.c:246
SCR_GroupIdentityRuleIconWeapon
Definition: SCR_MilitarySymbolRuleSet.c:295
SCR_Faction
Definition: SCR_Faction.c:6
EMilitarySymbolIcon
EMilitarySymbolIcon
Definition: EMilitarySymbol.c:29
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468