Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_GameCoresManager.c
Go to the documentation of this file.
1 
7 [BaseContainerProps(configRoot: true)]
9 {
10  protected static const ResourceName CORE_CONFIG_PATH = "{A9ACCDC72AD70995}Configs/Core/Cores.conf";
11 
12  [Attribute()]
13  protected ref array<ref SCR_GameCoreBase> m_aCores;
14 
15  protected ref array<SCR_GameCoreBase> m_CoresSorted = new array<SCR_GameCoreBase>;
16  protected static ref map<typename, SCR_GameCoreBase> m_CoresMap = new map<typename, SCR_GameCoreBase>;
17 
18  void OnAfterInit()
19  {
20  foreach (SCR_GameCoreBase core: m_CoresSorted)
21  {
22  if (core)
23  core.OnAfterInit();
24  }
25  }
26  void OnGameStart()
27  {
28  foreach (SCR_GameCoreBase core: m_CoresSorted)
29  {
30  if (core)
31  core.OnGameStart();
32  }
33  }
34  void OnWorldPostProcess(World world)
35  {
36  foreach (SCR_GameCoreBase core: m_CoresSorted)
37  {
38  if (core)
39  core.OnWorldPostProcess(world);
40  }
41  }
42  void OnUpdate(float timeSlice)
43  {
44  foreach (SCR_GameCoreBase core: m_CoresSorted)
45  {
46  if (core)
47  core.OnUpdate(timeSlice);
48  }
49  }
50  void OnGameEnd()
51  {
52  foreach (SCR_GameCoreBase core: m_CoresSorted)
53  {
54  if (core)
55  core.OnGameEnd();
56  }
57  }
58 
64  static SCR_GameCoreBase GetCore(typename type)
65  {
66  return m_CoresMap.Get(type);
67  }
72  static SCR_GameCoresManager CreateCoresManager()
73  {
74  Resource container = BaseContainerTools.LoadContainer(CORE_CONFIG_PATH);
75  if (!container || !container.IsValid())
76  {
77  Print(string.Format("Core config '%1' not found!", CORE_CONFIG_PATH), LogLevel.ERROR);
78  return null;
79  }
80 
81  Managed instance = BaseContainerTools.CreateInstanceFromContainer(container.GetResource().ToBaseContainer());
82  SCR_GameCoresManager manager = SCR_GameCoresManager.Cast(instance);
83  if (!manager)
84  {
85  Print(string.Format("SCR_GameCoresManager class not found in '%1'!", CORE_CONFIG_PATH), LogLevel.ERROR);
86  delete instance;
87  return null;
88  }
89 
90  return manager;
91  }
93  {
94  m_CoresMap = new map<typename, SCR_GameCoreBase>;
95  foreach (SCR_GameCoreBase core: m_aCores)
96  {
97  if (!core.IsEnabled() || !core.CanCreate())
98  continue;
99 
100  if (!m_CoresMap.Contains(core.Type()))
101  {
102  //--- Add by priority
103  int priority = core.GetPriority();
104  int index = 0;
105  for (int c = 0, count = m_CoresSorted.Count(); c < count; c++)
106  {
107  index = c;
108  if (priority > m_CoresSorted[c].GetPriority())
109  break;
110  }
111  m_CoresSorted.InsertAt(core, index);
112  m_CoresMap.Insert(core.Type(), core);
113  }
114  else
115  {
116  Print(string.Format("Duplicate definition of core '%1'!", core.Type()), LogLevel.ERROR);
117  }
118  }
119 
120  OnAfterInit();
121  }
122 };
SCR_GameCoresManager
Definition: SCR_GameCoresManager.c:8
GetPriority
int GetPriority()
Definition: SCR_BaseManualCameraComponent.c:107
Attribute
typedef Attribute
Post-process effect of scripted camera.
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
type
EDamageType type
Definition: SCR_DestructibleTreeV2.c:32
BaseContainerProps
SCR_AIGoalReaction_Follow BaseContainerProps
Handles insects that are supposed to be spawned around selected prefabs defined in prefab names array...
Definition: SCR_AIGoalReaction.c:468