Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_FactionRelationshipEditorAttribute.c
Go to the documentation of this file.
3{
4 //------------------------------------------------------------------------------------------------
5 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
6 {
7 SCR_EditableFactionComponent editableFaction = SCR_EditableFactionComponent.Cast(item);
8 if (!editableFaction)
9 return null;
10
11 SCR_Faction selectedFaction = SCR_Faction.Cast(editableFaction.GetFaction());
12 if (!selectedFaction)
13 return null;
14
16 if (!delegateFactionManager)
17 return null;
18
19 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
20 if (!factionManager)
21 return null;
22
23 super.ReadVariable(item, manager);
24
25 // Get delegate faction manager
26 SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>();
27 int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
28 SCR_Faction scrFaction;
29
30 // Loop through all factions
31 for (int i = 0; i < count; ++i)
32 {
33 scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
34 if (!scrFaction)
35 continue;
36
37 // Set the state based on friendly (highlighted) or hostile(non-highlighted)
38 AddOrderedState(scrFaction.DoCheckIfFactionFriendly(selectedFaction));
39 }
40
42 }
43
44 //------------------------------------------------------------------------------------------------
45 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
46 {
47 SCR_EditableFactionComponent editableFaction = SCR_EditableFactionComponent.Cast(item);
48 if (!editableFaction)
49 return;
50
51 SCR_Faction selectedFaction = SCR_Faction.Cast(editableFaction.GetFaction());
52 if (!selectedFaction)
53 return;
54
56 if (!delegateFactionManager)
57 return;
58
59 SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
60 if (!factionManager)
61 return;
62
63 super.WriteVariable(item, var, manager, playerID);
64
65 // Get delegate faction manager
66 SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>();
67 int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
68 SCR_Faction scrFaction;
69
70 // Loop through all factions
71 for (int i = 0; i < count; ++i)
72 {
73 scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
74 if (!scrFaction)
75 continue;
76
77 // Based on the state, set the faction to friendly (highlighted) or hostile(non-highlighted)
78 if (GetOrderedState())
79 factionManager.SetFactionsFriendly(selectedFaction, scrFaction, playerID, false);
80 else
81 factionManager.SetFactionsHostile(selectedFaction, scrFaction, playerID, false);
82 }
83
84 //~ Update AIs
85 SCR_FactionManager.RequestUpdateAllTargetsFactions();
86 }
87
88 //------------------------------------------------------------------------------------------------
89 override protected void CreatePresets()
90 {
92 if (!delegateFactionManager)
93 return;
94
95 FactionManager factionManager = GetGame().GetFactionManager();
96 if (!factionManager)
97 return;
98
99 m_aValues.Clear();
100
101 SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>();
102 int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
103
104 SCR_Faction scrFaction;
106
107 for (int i = 0; i < count; ++i)
108 {
109 scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
110
111 if (!scrFaction || scrFaction.GetParent() != null)
112 continue;
113
115
116 value.SetWithUIInfo(scrFaction.GetUIInfo(), factionManager.GetFactionIndex(factionDelegates.Get(i).GetFaction()));
117 m_aValues.Insert(value);
118 }
119 }
120};
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_FactionManager(IEntitySource src, IEntity parent)
static SCR_BaseEditorAttributeVar CreateVector(vector value)
ref array< ref SCR_EditorAttributeFloatStringValueHolder > m_aValues
static SCR_DelegateFactionManagerComponent GetInstance()
int GetSortedFactionDelegates(notnull out SCR_SortedArray< SCR_EditableFactionComponent > outDelegates)
Faction GetParent()
override bool DoCheckIfFactionFriendly(Faction faction)