Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_DelegateFactionManagerComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/FactionManager/Components", description: "")]
3 {
4 };
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 
16 {
17  [Attribute(params: "et")]
18  protected ResourceName m_FactionDelegatePrefab;
19 
20  protected ref map<Faction, SCR_EditableFactionComponent> m_FactionDelegates = new map<Faction, SCR_EditableFactionComponent>;
21 
22 
27  static SCR_DelegateFactionManagerComponent GetInstance()
28  {
29  FactionManager factionManager = GetGame().GetFactionManager();
30  if (factionManager)
31  return SCR_DelegateFactionManagerComponent.Cast(factionManager.FindComponent(SCR_DelegateFactionManagerComponent));
32  else
33  return null;
34  }
40  int GetFactionDelegates(notnull out map<Faction, SCR_EditableFactionComponent> outDelegates)
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  }
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  }
75  int GetFactionDelegateCount()
76  {
77  return m_FactionDelegates.Count();
78  }
83  int GetPlayableFactionDelegates(notnull out map<Faction, SCR_EditableFactionComponent> outDelegates)
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  }
100  int GetPlayableFactionDelegateCount()
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  }
118  SCR_EditableFactionComponent GetFactionDelegate(Faction faction)
119  {
120  return m_FactionDelegates.Get(faction);
121  }
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 };
SCR_BaseFactionManagerComponent
void SCR_BaseFactionManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_BaseFactionManagerComponent.c:20
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BaseFactionManagerComponentClass
Definition: SCR_BaseFactionManagerComponent.c:2
SCR_DelegateFactionManagerComponentClass
Definition: SCR_DelegateFactionManagerComponent.c:2
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_EditableFactionComponentClass
Definition: SCR_EditableFactionComponent.c:2
Faction
Definition: Faction.c:12
SCR_Global
Definition: Functions.c:6
params
Configs ServerBrowser KickDialogs params
Definition: SCR_NotificationSenderComponent.c:24
SCR_DelegateFactionManagerComponent
Definition: SCR_DelegateFactionManagerComponent.c:15
SCR_Faction
Definition: SCR_Faction.c:6
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180