Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseFactionEditableAttribute.c
Go to the documentation of this file.
1
6{
7 override SCR_BaseEditorAttributeVar ReadVariable(Managed item, SCR_AttributesManagerEditorComponent manager)
8 {
10 if (!editableEntity)
11 return null;
12
13 if (!ValidEntity(editableEntity.GetOwner()))
14 return null;
15
16 FactionManager factionManager = GetGame().GetFactionManager();
17 if (!factionManager)
18 return null;
19
20 Faction faction = GetFaction(editableEntity.GetOwner());
21 if (!faction)
22 return null;
23
25 if (!delegateFactionManager)
26 return null;
27
28 SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>;
29 int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
30
31 if (factionDelegates.IsEmpty())
32 return null;
33
34 int factionIndex = factionManager.GetFactionIndex(faction);
35
36 for (int i = 0; i < count; i++)
37 {
38 if (factionDelegates.GetValue(i).GetFactionIndex() == factionIndex)
40 }
41
42 return null;
43 }
44
45 //~ Check if entity is valid to set faction
46 protected bool ValidEntity(GenericEntity entity)
47 {
48 return false;
49 }
50
51 //~ Get the entity faction
53 {
54 return null;
55 }
56
57 //~ Set the entity faction
58 protected void SetFaction(GenericEntity entity, Faction faction)
59 {
60
61 }
62
63 //~ Creates the buttons to select faction
64 protected override void CreatePresets()
65 {
67 if (!delegateFactionManager)
68 return;
69
70 FactionManager factionManager = GetGame().GetFactionManager();
71 if (!factionManager)
72 return;
73
74 m_aValues.Clear();
75
76 SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>;
77 int count = delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
78
79 SCR_Faction scrFaction;
80
81 for(int i = 0; i < count; ++i)
82 {
83 scrFaction = SCR_Faction.Cast(factionDelegates.Get(i).GetFaction());
84
85 if (!scrFaction || scrFaction.GetParent() != null)
86 continue;
87
89 value.SetWithUIInfo(scrFaction.GetUIInfo(), factionDelegates.GetValue(i).GetFactionIndex());
90 m_aValues.Insert(value);
91 }
92 }
93
94 override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
95 {
96 if (!var)
97 return;
98
99 FactionManager factionManager = GetGame().GetFactionManager();
100 if (!factionManager)
101 return;
102
104 if (!editableEntity)
105 return;
106
108 if (!delegateFactionManager)
109 return;
110
111 SCR_SortedArray<SCR_EditableFactionComponent> factionDelegates = new SCR_SortedArray<SCR_EditableFactionComponent>;
112 delegateFactionManager.GetSortedFactionDelegates(factionDelegates);
113
114 if (factionDelegates.IsEmpty())
115 return;
116
117 //Faction faction = factionManager.GetFactionByIndex(var.GetInt());
118 Faction faction = factionManager.GetFactionByIndex(factionDelegates.GetValue(var.GetInt()).GetFactionIndex());
119 if (!faction)
120 return;
121
122 SetFaction(editableEntity.GetOwner(), faction);
123 }
124};
125
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
SCR_CampaignFaction GetFaction()
static SCR_BaseEditorAttributeVar CreateInt(int value)
void SetFaction(GenericEntity entity, Faction faction)
override void WriteVariable(Managed item, SCR_BaseEditorAttributeVar var, SCR_AttributesManagerEditorComponent manager, int playerID)
ref array< ref SCR_EditorAttributeFloatStringValueHolder > m_aValues
static SCR_DelegateFactionManagerComponent GetInstance()
int GetSortedFactionDelegates(notnull out SCR_SortedArray< SCR_EditableFactionComponent > outDelegates)
Faction GetParent()