Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableFactionStruct.c
Go to the documentation of this file.
2 {
3  //--- Serialized (names shortened to save memory)
4  protected string fk; //--- Faction key
5  protected ref array<ref SCR_EditorAttributeStruct> at = {};
6 
7  static void SerializeFactions(out notnull array<ref SCR_EditableFactionStruct> outEntries, SCR_EditorAttributeList attributeList)
8  {
10  if (!delegateManager)
11  return;
12 
13  //--- Clear existing array
14  outEntries.Clear();
15 
16  SCR_SortedArray<SCR_EditableFactionComponent> delegates = new SCR_SortedArray<SCR_EditableFactionComponent>();
17  for (int i, count = delegateManager.GetSortedFactionDelegates(delegates); i < count; i++)
18  {
19  SerializeFaction(delegates[i], outEntries, attributeList);
20  }
21  }
22  protected static void SerializeFaction(SCR_EditableFactionComponent faction, out notnull array<ref SCR_EditableFactionStruct> outEntries, SCR_EditorAttributeList attributeList)
23  {
25  entry.fk = faction.GetFaction().GetFactionKey();
26  outEntries.Insert(entry);
27 
28  SCR_EditorAttributeStruct.SerializeAttributes(entry.at, attributeList, faction);
29  }
30  static void DeserializeFactions(notnull array<ref SCR_EditableFactionStruct> entries, SCR_EditorAttributeList attributeList = null)
31  {
32  FactionManager factionManager = GetGame().GetFactionManager();
33  if (!factionManager)
34  return;
35 
37  if (!delegateManager)
38  return;
39 
40  Faction faction;
41  SCR_EditableFactionComponent factionDelegate;
42  foreach (int id, SCR_EditableFactionStruct entry: entries)
43  {
44  faction = factionManager.GetFactionByKey(entry.fk);
45  factionDelegate = delegateManager.GetFactionDelegate(faction);
46  if (factionDelegate)
47  {
48  SCR_EditorAttributeStruct.DeserializeAttributes(entry.at, attributeList, factionDelegate);
49  }
50  else
51  {
52  Print(string.Format("SCR_EditableFactionStruct: Cannot load faction '%1', it's not configured in FactionManager!", entry.fk), LogLevel.WARNING);
53  }
54  }
55 
56  SCR_SortedArray<SCR_EditableFactionComponent> delegates = new SCR_SortedArray<SCR_EditableFactionComponent>();
57  for (int i, count = delegateManager.GetSortedFactionDelegates(delegates); i < count; i++)
58  {
59  }
60  }
61  static void LogFactions(notnull array<ref SCR_EditableFactionStruct> entries, SCR_EditorAttributeList attributeList = null)
62  {
63  Print(" SCR_EditableFactionStruct: " + entries.Count());
64  foreach (int id, SCR_EditableFactionStruct entry: entries)
65  {
66  PrintFormat(" %1", entry.fk);
67 
68  SCR_EditorAttributeStruct.LogAttributes(entry.at, attributeList, " ");
69  }
70  }
72  {
73  RegV("fk");
74  RegV("at");
75  }
76 };
SCR_EditableFactionStruct
Definition: SCR_EditableFactionStruct.c:1
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
JsonApiStruct
Parameters for joining server.
Definition: FeedbackDialogUI.c:2
SCR_EditorAttributeList
Definition: SCR_EditorAttributeConfig.c:2
Faction
Definition: Faction.c:12
SCR_EditorAttributeStruct
Definition: SCR_EditorAttributeStruct.c:6
SCR_DelegateFactionManagerComponent
Definition: SCR_DelegateFactionManagerComponent.c:15