Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_DelegateFactionManagerComponent.c
Go to the documentation of this file.
1[ComponentEditorProps(category: "GameScripted/FactionManager/Components", description: "")]
5//Here track tasks and spawn points
6//Find faction deletegate on changed send that to the correct faction then have an rpl function to send the task
7
10
16{
17 [Attribute(params: "et")]
19
21
22
28 {
29 FactionManager factionManager = GetGame().GetFactionManager();
30 if (factionManager)
31 return SCR_DelegateFactionManagerComponent.Cast(factionManager.FindComponent(SCR_DelegateFactionManagerComponent));
32 else
33 return null;
34 }
35
41 {
42 int count = m_FactionDelegates.Count();
43 for (int i = 0; i < count; i++)
44 {
45 outDelegates.Insert(m_FactionDelegates.GetKey(i), m_FactionDelegates.GetElement(i));
46 }
47 return count;
48 }
49
54 int GetSortedFactionDelegates(notnull out SCR_SortedArray<SCR_EditableFactionComponent> outDelegates)
55 {
56 int count = m_FactionDelegates.Count();
57 SCR_Faction faction;
58 SCR_EditableFactionComponent factionDelegate;
59 for (int i = 0; i < count; i++)
60 {
61 factionDelegate = m_FactionDelegates.GetElement(i);
62 int order = 0;
63 faction = SCR_Faction.Cast(factionDelegate.GetFaction());
64 if (faction)
65 order = faction.GetOrder();
66
67 outDelegates.Insert(order, factionDelegate);
68 }
69 return count;
70 }
71
76 {
77 return m_FactionDelegates.Count();
78 }
79
84 {
85 foreach (Faction faction, SCR_EditableFactionComponent delegate: m_FactionDelegates)
86 {
87 SCR_Faction scrFaction = SCR_Faction.Cast(faction);
88 if (scrFaction && scrFaction.IsPlayable())
89 {
90 outDelegates.Insert(scrFaction, delegate);
91 }
92 }
93
94 return outDelegates.Count();
95 }
96
101 {
102 int count = 0;
103
104 foreach (Faction faction, SCR_EditableFactionComponent delegate: m_FactionDelegates)
105 {
106 SCR_Faction scrFaction = SCR_Faction.Cast(faction);
107 if (scrFaction && scrFaction.IsPlayable())
108 count++;
109 }
110
111 return count;
112 }
113
118 SCR_EditableFactionComponent GetFactionDelegate(Faction faction)
119 {
120 return m_FactionDelegates.Get(faction);
121 }
122
127 void SetFactionDelegate(Faction faction, SCR_EditableFactionComponent delegate)
128 {
129 m_FactionDelegates.Set(faction, delegate);
130 }
131
132 override void OnFactionsInit(array<Faction> factions)
133 {
134 if (SCR_Global.IsEditMode(GetOwner()) || factions.IsEmpty() || (Replication.IsClient() && Replication.Runtime()))
135 return;
136
137 Resource entityResource = Resource.Load(m_FactionDelegatePrefab);
138 IEntityComponentSource componentSource = SCR_EditableFactionComponentClass.GetEditableEntitySource(entityResource);
139 if (!componentSource)
140 {
141 Print(string.Format("SCR_EditableFactionComponent missing in '%1'!", m_FactionDelegatePrefab.GetPath()), LogLevel.WARNING);
142 return;
143 }
144
145 SCR_EditableFactionComponent editableEntity;
146 foreach (int i, Faction faction: factions)
147 {
148 IEntity delegateEntity = GetGame().SpawnEntityPrefab(entityResource);
149 editableEntity = SCR_EditableFactionComponent.Cast(SCR_EditableFactionComponent.GetEditableEntity(delegateEntity));
150 editableEntity.SetFactionIndex(i);
151 }
152 }
153};
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
void SCR_BaseFactionManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Main replication API.
Definition Replication.c:14
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
int GetFactionDelegates(notnull out map< Faction, SCR_EditableFactionComponent > outDelegates)
SCR_EditableFactionComponent GetFactionDelegate(Faction faction)
override void OnFactionsInit(array< Faction > factions)
void SetFactionDelegate(Faction faction, SCR_EditableFactionComponent delegate)
int GetPlayableFactionDelegates(notnull out map< Faction, SCR_EditableFactionComponent > outDelegates)
static SCR_DelegateFactionManagerComponent GetInstance()
ref map< Faction, SCR_EditableFactionComponent > m_FactionDelegates
int GetSortedFactionDelegates(notnull out SCR_SortedArray< SCR_EditableFactionComponent > outDelegates)
bool IsPlayable()
static bool IsEditMode()
Definition Functions.c:1566
Definition Types.c:486
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
SCR_FieldOfViewSettings Attribute