Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_SlotManagerComponent.c
Go to the documentation of this file.
1[EntityEditorProps(insertable: false)]
2class SCR_SpawnerSlotManagerClass : GenericEntityClass
3{
4}
5
7class SCR_SpawnerSlotManager : GenericEntity
8{
9 protected static SCR_SpawnerSlotManager s_Instance;
10
11 protected ref array <SCR_EntitySpawnerSlotComponent> m_aSlots = {};
13
17
18 //------------------------------------------------------------------------------------------------
27
28 //------------------------------------------------------------------------------------------------
37
38 //------------------------------------------------------------------------------------------------
47
48 //------------------------------------------------------------------------------------------------
50 static SCR_SpawnerSlotManager GetInstance()
51 {
52 if (s_Instance)
53 return s_Instance;
54
55 s_Instance = SCR_SpawnerSlotManager.Cast(GetGame().SpawnEntity(SCR_SpawnerSlotManager, GetGame().GetWorld()));
56 if (!s_Instance)
57 return null;
58
59 s_Instance.SetupSlotUpdatedInvoker();
60 return s_Instance;
61 }
62
63 //------------------------------------------------------------------------------------------------
64 protected void SetupSlotUpdatedInvoker()
65 {
67 if (core)
68 core.Event_OnEntityTransformChanged.Insert(OnSlotUpdated);
69 }
70
71 //------------------------------------------------------------------------------------------------
74 void RegisterSlot(SCR_EntitySpawnerSlotComponent slot)
75 {
76 m_aSlots.Insert(slot);
77
79 m_EditableEntityCore.Event_OnEntityTransformChanged.Insert(OnSlotUpdated);
80
82 m_OnSlotCreated.Invoke(slot);
83 }
84
85 //------------------------------------------------------------------------------------------------
88 void UnregisterSlot(notnull SCR_EntitySpawnerSlotComponent slot)
89 {
90 if (m_aSlots.Contains(slot))
91 m_aSlots.RemoveItem(slot);
92
94 m_OnSlotRemoved.Invoke(slot);
95 }
96
97 //------------------------------------------------------------------------------------------------
99 void OnSlotUpdated(notnull SCR_EditableEntityComponent editableComponent)
100 {
101 IEntity slotOwner = editableComponent.GetOwner();
102 if (!slotOwner)
103 return;
104
105 SCR_EntitySpawnerSlotComponent slot = SCR_EntitySpawnerSlotComponent.Cast(slotOwner.FindComponent(SCR_EntitySpawnerSlotComponent));
106 if (slot && m_OnSlotUpdated)
107 m_OnSlotUpdated.Invoke(slot, slotOwner.GetOrigin());
108 }
109
110 //------------------------------------------------------------------------------------------------
111 protected override void EOnInit(IEntity owner)
112 {
113 super.EOnInit(owner);
114
116 if (core)
117 core.Event_OnEntityTransformChanged.Insert(OnSlotUpdated);
118 else
119 Print("SCR_EditableEntityCore not found! Slot transformation won't be updated!", LogLevel.WARNING);
120 }
121
122 //------------------------------------------------------------------------------------------------
123 // destructor
125 {
126 if (s_Instance == this)
127 s_Instance = null;
128 }
129}
ArmaReforgerScripted GetGame()
Definition game.c:1398
void RegisterSlot(SCR_WeaponRackSlotEntity slot)
ref array< SCR_WeaponRackSlotEntity > m_aSlots
IEntity SpawnEntity(ResourceName entityResourceName, notnull IEntity slotOwner)
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
void ~SCR_SpawnerSlotManager()
ScriptInvoker GetOnSlotCreated()
ref ScriptInvoker m_OnSlotRemoved
void OnSlotUpdated(notnull SCR_EditableEntityComponent editableComponent)
ref ScriptInvoker m_OnSlotUpdated
ref ScriptInvoker m_OnSlotCreated
ScriptInvoker GetOnSlotUpdated()
void UnregisterSlot(notnull SCR_EntitySpawnerSlotComponent slot)
ScriptInvoker GetOnSlotRemoved()
SCR_SpawnerSlotManagerClass s_Instance
Class used for managing changes and removals of slots present in world.
SCR_EditableEntityCore m_EditableEntityCore
void SetupSlotUpdatedInvoker()
proto external Managed FindComponent(typename typeName)
proto external vector GetOrigin()
override void EOnInit(IEntity owner)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14
ScriptInvokerBase< func > ScriptInvoker
Definition tools.c:134