Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BuildingConfigManagerEntity.c
Go to the documentation of this file.
1 //------------------------------------------------------------------------------------------------
2 class SCR_BuildingConfigManagerEntityClass: GenericEntityClass
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
8 {
9  static SCR_BuildingConfigManagerEntity s_Instance = null;
10 
11  ref map<ResourceName, ref SCR_BuildingSetup> m_BuildingSetups = new map<ResourceName, ref SCR_BuildingSetup>();
12 
13  //------------------------------------------------------------------------------------------------
14  static void CreateInstance()
15  {
16  if (!s_Instance)
18  }
19 
20  //------------------------------------------------------------------------------------------------
21  static SCR_BuildingSetup ReloadConfig(ResourceName configPath)
22  {
23  if (configPath == string.Empty)
24  return null;
25 
26  if (!s_Instance)
27  return null;
28 
29  s_Instance.m_BuildingSetups.Remove(configPath);
30 
31  return GetBuildingSetupFromConfig(configPath);
32  }
33 
34  //------------------------------------------------------------------------------------------------
35  static SCR_BuildingSetup GetBuildingSetupFromConfig(ResourceName configPath)
36  {
37  if (configPath == string.Empty)
38  return null;
39 
40  CreateInstance();
41 
42  SCR_BuildingSetup buildSetup = s_Instance.m_BuildingSetups.Get(configPath);
43  if (!buildSetup)
44  {
45  Resource holder = BaseContainerTools.LoadContainer(configPath);
46  if (!holder)
47  return null;
48 
49  buildSetup = SCR_BuildingSetup.Cast(BaseContainerTools.CreateInstanceFromContainer(holder.GetResource().ToBaseContainer()));
50  if (!buildSetup)
51  return null;
52 
53  buildSetup.SetConfigPath(configPath);
54  buildSetup.Init();
55  s_Instance.m_BuildingSetups.Insert(configPath, buildSetup);
56  }
57 
58  return buildSetup;
59  }
60 
61  //------------------------------------------------------------------------------------------------
62  void SCR_BuildingConfigManagerEntity(IEntitySource src, IEntity parent)
63  {
64  s_Instance = this;
65  }
66 
67  //------------------------------------------------------------------------------------------------
69  {
70  if (s_Instance == this)
71  s_Instance = null;
72  }
73 };
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_BuildingConfigManagerEntity
Definition: SCR_BuildingConfigManagerEntity.c:7
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
s_Instance
SCR_SpawnerSlotManagerClass s_Instance
Class used for managing changes and removals of slots present in world.
SCR_BuildingConfigManagerEntityClass
Definition: SCR_BuildingConfigManagerEntity.c:2
SCR_BuildingSetup
Definition: SCR_BuildingSetup.c:4