Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_SpawnPositionComponentManager.c
Go to the documentation of this file.
1 [EntityEditorProps(insertable: false)]
2 class SCR_SpawnPositionComponentManagerClass : GenericEntityClass
3 {
4 }
5 
6 class SCR_SpawnPositionComponentManager : GenericEntity
7 {
8  protected static SCR_SpawnPositionComponentManager s_Instance;
9  protected ref array<SCR_SpawnPositionComponent> m_aSpawnPositions;
10 
11  //------------------------------------------------------------------------------------------------
14  static SCR_SpawnPositionComponentManager GetInstance(bool createNew = true)
15  {
16  if (!s_Instance && createNew)
17  s_Instance = SCR_SpawnPositionComponentManager.Cast(GetGame().SpawnEntity(SCR_SpawnPositionComponentManager, GetGame().GetWorld()));
18 
19  return s_Instance;
20  }
21 
22  //------------------------------------------------------------------------------------------------
25  void AddSpawnPosition(SCR_SpawnPositionComponent positionComp)
26  {
27  if (!m_aSpawnPositions)
28  m_aSpawnPositions = {};
29 
30  if (!m_aSpawnPositions.Contains(positionComp))
31  m_aSpawnPositions.Insert(positionComp);
32  }
33 
34  //------------------------------------------------------------------------------------------------
37  void DeleteSpawnPosition(SCR_SpawnPositionComponent positionComp)
38  {
39  if (!m_aSpawnPositions)
40  return;
41 
42  m_aSpawnPositions.RemoveItem(positionComp);
43 
44  if (m_aSpawnPositions.IsEmpty())
45  m_aSpawnPositions = null;
46  }
47 
48  //------------------------------------------------------------------------------------------------
53  int GetSpawnPositionsInRange(vector center, float range, out array<SCR_SpawnPositionComponent> positions)
54  {
55  if (!m_aSpawnPositions)
56  return 0;
57 
58  float rangeSq = range * range;
59  foreach (SCR_SpawnPositionComponent position : m_aSpawnPositions)
60  {
61  if (vector.DistanceSq(position.GetOwner().GetOrigin(), center) <= rangeSq)
62  positions.Insert(position);
63  }
64 
65  return positions.Count();
66  }
67 
68  //------------------------------------------------------------------------------------------------
69  // destructor
71  {
72  if (s_Instance == this)
73  s_Instance = null;
74  }
75 }
SpawnEntity
protected IEntity SpawnEntity(ResourceName entityResourceName, notnull IEntity slotOwner)
Definition: SCR_CatalogEntitySpawnerComponent.c:1008
SCR_SpawnPositionComponentManagerClass
Definition: SCR_SpawnPositionComponentManager.c:2
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
m_aSpawnPositions
protected ref array< SCR_SpawnPositionComponent > m_aSpawnPositions
Definition: SCR_SpawnPositionComponentManager.c:9
GetInstance
SCR_TextsTaskManagerComponentClass ScriptComponentClass GetInstance()
Definition: SCR_TextsTaskManagerComponent.c:50
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
GenericEntity
SCR_GenericBoxEntityClass GenericEntity
GetSpawnPositionsInRange
int GetSpawnPositionsInRange(vector center, float range, out array< SCR_SpawnPositionComponent > positions)
Definition: SCR_SpawnPositionComponentManager.c:53
s_Instance
SCR_SpawnPositionComponentManagerClass s_Instance
~SCR_SpawnPositionComponentManager
void ~SCR_SpawnPositionComponentManager()
Definition: SCR_SpawnPositionComponentManager.c:70
DeleteSpawnPosition
void DeleteSpawnPosition(SCR_SpawnPositionComponent positionComp)
Definition: SCR_SpawnPositionComponentManager.c:37
AddSpawnPosition
void AddSpawnPosition(SCR_SpawnPositionComponent positionComp)
Definition: SCR_SpawnPositionComponentManager.c:25
position
vector position
Definition: SCR_DestructibleTreeV2.c:30