Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_PrefabsSpawnerManager.c
Go to the documentation of this file.
2 {
3  Generic,
4 // AppleTrees,
8 }
9 
10 class SCR_PrefabsSpawnerManagerClass : GenericEntityClass
11 {
12 }
13 
16 {
17  [Attribute("", UIWidgets.Object, "Prefabs spawners, each for different type of SpawnPoints")]
18  protected ref array<ref SCR_PrefabsSpawner> m_aPrefabsSpawners;
19 
21  protected static ref map<EPrefabSpawnType, ref array<SCR_PrefabSpawnPoint>> s_aPrefabSpawnPoints = new map<EPrefabSpawnType, ref array<SCR_PrefabSpawnPoint>>();
22 
23  //------------------------------------------------------------------------------------------------
26  static void RegisterPrefabSpawnPoint(SCR_PrefabSpawnPoint prefabSpawnPoint)
27  {
28  if (GetGame().GetWorldEntity() && s_aPrefabSpawnPoints)
29  {
30  array<SCR_PrefabSpawnPoint> spawnPoints = s_aPrefabSpawnPoints[prefabSpawnPoint.GetType()];
31 
32  if (!spawnPoints)
33  {
34  spawnPoints = {};
35  s_aPrefabSpawnPoints.Insert(prefabSpawnPoint.GetType(), spawnPoints);
36  }
37 
38  spawnPoints.Insert(prefabSpawnPoint);
39  }
40  }
41 
42  //------------------------------------------------------------------------------------------------
45  static void UnregisterPrefabSpawnPoint(SCR_PrefabSpawnPoint prefabSpawnPoint)
46  {
47  if (GetGame().GetWorldEntity() && s_aPrefabSpawnPoints)
48  {
49  array<SCR_PrefabSpawnPoint> spawnPoints = s_aPrefabSpawnPoints[prefabSpawnPoint.GetType()];
50  if (spawnPoints)
51  spawnPoints.RemoveItem(prefabSpawnPoint);
52  }
53  }
54 
55  //------------------------------------------------------------------------------------------------
59  override void EOnFrame(IEntity owner, float timeSlice)
60  {
61  if (!GetGame().GetWorldEntity() || RplSession.Mode() == RplMode.Client)
62  {
63  ClearEventMask(EntityEvent.FRAME);
64  return;
65  }
66 
67  foreach (SCR_PrefabsSpawner prefabsSpawner : m_aPrefabsSpawners)
68  {
69  prefabsSpawner.Spawn(s_aPrefabSpawnPoints[prefabsSpawner.GetType()]);
70  }
71 
72  ClearEventMask(EntityEvent.FRAME);
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  // constructor
79  void SCR_PrefabsSpawnerManager(IEntitySource src, IEntity parent)
80  {
81  SetEventMask(EntityEvent.FRAME);
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  // destructor
87  {
88  s_aPrefabSpawnPoints = new map<EPrefabSpawnType, ref array<SCR_PrefabSpawnPoint>>();
89  }
90 }
EOnFrame
override void EOnFrame(IEntity owner, float timeSlice)
Definition: SCR_PrefabsSpawnerManager.c:59
Generic
Generic
Definition: SCR_PrefabsSpawnerManager.c:2
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
CivilVehicles
CivilVehicles
Definition: SCR_PrefabsSpawnerManager.c:4
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
MilitaryVehicles
MilitaryVehicles
Definition: SCR_PrefabsSpawnerManager.c:5
~SCR_PrefabsSpawnerManager
void ~SCR_PrefabsSpawnerManager()
Definition: SCR_PrefabsSpawnerManager.c:86
EPrefabSpawnType
EPrefabSpawnType
Definition: SCR_PrefabsSpawnerManager.c:1
MilitaryHeliVehicles
MilitaryHeliVehicles
Definition: SCR_PrefabsSpawnerManager.c:6
SCR_PrefabsSpawnerManager
void SCR_PrefabsSpawnerManager(IEntitySource src, IEntity parent)
Definition: SCR_PrefabsSpawnerManager.c:79
SCR_PrefabsSpawner
Base class for Prefabs Spawning.
Definition: SCR_PrefabsSpawner.c:3
Attribute
enum EPrefabSpawnType Attribute("", UIWidgets.Object, "Prefabs spawners, each for different type of SpawnPoints")] protected ref array< ref SCR_PrefabsSpawner > m_aPrefabsSpawners
Manager for spawning prefabs in the mission.
SCR_PrefabSpawnPoint
void SCR_PrefabSpawnPoint(IEntitySource src, IEntity parent)
Definition: SCR_PrefabSpawnPoint.c:40