Arma Reforger Explorer
1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Toggle main menu visibility
Loading...
Searching...
No Matches
SCR_SlotService.c
Go to the documentation of this file.
1
class
SCR_SlotServiceComponentClass
:
SCR_ServicePointComponentClass
2
{
3
[
Attribute
(defvalue:
"5"
,
params
:
"0 inf"
,
desc
:
"Slot Search Radius Size."
,
category
:
"Slot service"
)]
4
protected
float
m_fMaxSlotDistance
;
5
6
//------------------------------------------------------------------------------------------------
8
float
GetMaxSlotDistance
()
9
{
10
return
m_fMaxSlotDistance
;
11
}
12
}
13
15
class
SCR_SlotServiceComponent : SCR_ServicePointComponent
16
{
17
protected
SCR_SpawnerSlotManager
m_SlotManager
;
18
protected
ref array<SCR_EntitySpawnerSlotComponent>
m_aChildSlots
= {};
19
protected
ref array<SCR_EntitySpawnerSlotComponent>
m_aNearSlots
= {};
20
21
//------------------------------------------------------------------------------------------------
25
void
RegisterSlot
(SCR_EntitySpawnerSlotComponent slot)
26
{
27
if
(!
CanBeSlotRegistered
(slot))
28
return
;
29
30
if
(!
m_aNearSlots
.Contains(slot))
31
m_aNearSlots
.Insert(slot);
32
}
33
34
//------------------------------------------------------------------------------------------------
38
protected
bool
CanBeSlotRegistered
(notnull SCR_EntitySpawnerSlotComponent slot)
39
{
40
IEntity
slotOwner = slot.GetOwner();
41
IEntity
parent = slotOwner.
GetParent
();
42
if
(parent && parent.
FindComponent
(SCR_SlotServiceComponent) && parent !=
GetOwner
())
43
return
false
;
44
45
SCR_SlotServiceComponentClass
prefabData =
SCR_SlotServiceComponentClass
.Cast(
GetComponentData
(
GetOwner
()));
46
if
(!prefabData)
47
return
false
;
48
49
float
maxSlotDistance = prefabData.
GetMaxSlotDistance
();
50
return
vector
.DistanceSqXZ(slotOwner.
GetOrigin
(),
GetOwner
().
GetOrigin
()) < maxSlotDistance * maxSlotDistance;
51
}
52
53
//------------------------------------------------------------------------------------------------
56
protected
bool
SlotSearchCallback
(
IEntity
ent)
57
{
58
SCR_EntitySpawnerSlotComponent slotComp = SCR_EntitySpawnerSlotComponent.Cast(ent.
FindComponent
(SCR_EntitySpawnerSlotComponent));
59
if
(!slotComp)
60
return
true
;
61
62
RegisterSlot
(slotComp);
63
return
true
;
64
}
65
66
//------------------------------------------------------------------------------------------------
68
protected
void
RegisterNearbySlots
()
69
{
70
SCR_SlotServiceComponentClass
prefabData =
SCR_SlotServiceComponentClass
.Cast(
GetComponentData
(
GetOwner
()));
71
if
(!prefabData)
72
return
;
73
74
GetGame
().GetWorld().QueryEntitiesBySphere(
GetOwner
().
GetOrigin
(), prefabData.
GetMaxSlotDistance
(),
SlotSearchCallback
);
75
}
76
77
//------------------------------------------------------------------------------------------------
79
protected
void
RegisterChildSlots
()
80
{
81
IEntity
child =
GetOwner
().
GetChildren
();
82
while
(child)
83
{
84
SCR_EntitySpawnerSlotComponent slot = SCR_EntitySpawnerSlotComponent.Cast(child.
FindComponent
(SCR_EntitySpawnerSlotComponent));
85
if
(slot)
86
m_aChildSlots
.Insert(slot);
87
88
child = child.
GetSibling
();
89
}
90
}
91
92
//------------------------------------------------------------------------------------------------
94
protected
void
OnSlotUpdate
(SCR_EntitySpawnerSlotComponent slot,
vector
position
)
95
{
96
if
(
CanBeSlotRegistered
(slot))
97
{
98
if
(!
m_aNearSlots
.Contains(slot) ||
m_aChildSlots
.Contains(slot))
99
m_aNearSlots
.Insert(slot);
100
}
101
else
102
{
103
m_aNearSlots
.RemoveItem(slot);
104
}
105
}
106
107
//------------------------------------------------------------------------------------------------
109
protected
void
OnSlotRemoved
(SCR_EntitySpawnerSlotComponent slot)
110
{
111
m_aNearSlots
.RemoveItem(slot);
112
}
113
114
//------------------------------------------------------------------------------------------------
115
protected
override
void
EOnInit
(
IEntity
owner)
116
{
117
super.EOnInit(owner);
118
119
m_SlotManager
= SCR_SpawnerSlotManager.GetInstance();
120
if
(!
m_SlotManager
)
121
{
122
Print
(
"Slot manager is required for Slot service functionality"
,
LogLevel
.ERROR);
123
return
;
124
}
125
126
RegisterChildSlots
();
127
RegisterNearbySlots
();
128
129
m_SlotManager
.GetOnSlotCreated().Insert(
RegisterSlot
);
130
m_SlotManager
.GetOnSlotUpdated().Insert(
OnSlotUpdate
);
131
m_SlotManager
.GetOnSlotRemoved().Insert(
OnSlotRemoved
);
132
}
133
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
GetOrigin
vector GetOrigin()
Definition
SCR_AIUtilityComponent.c:471
RegisterSlot
void RegisterSlot(SCR_WeaponRackSlotEntity slot)
Definition
SCR_ArsenalDisplayComponent.c:30
GetComponentData
SCR_CharacterSoundComponentClass GetComponentData()
Definition
SCR_CharacterSoundComponent.c:132
position
vector position
Definition
SCR_DestructibleTreeV2.c:30
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
m_aNearSlots
ref array< SCR_EntitySpawnerSlotComponent > m_aNearSlots
Definition
SCR_SlotService.c:19
SlotSearchCallback
bool SlotSearchCallback(IEntity ent)
Definition
SCR_SlotService.c:56
RegisterChildSlots
void RegisterChildSlots()
Registers slots initially created as children. There slots cannot be used by any other spawner and sh...
Definition
SCR_SlotService.c:79
OnSlotRemoved
void OnSlotRemoved(SCR_EntitySpawnerSlotComponent slot)
Called, if slot possition was changed. If it fails to meet previously required criteria in CanBeSlotR...
Definition
SCR_SlotService.c:109
CanBeSlotRegistered
bool CanBeSlotRegistered(notnull SCR_EntitySpawnerSlotComponent slot)
Definition
SCR_SlotService.c:38
m_SlotManager
SCR_SlotServiceComponentClass m_SlotManager
Service with basic slot handling functionalities.
m_aChildSlots
ref array< SCR_EntitySpawnerSlotComponent > m_aChildSlots
Definition
SCR_SlotService.c:18
RegisterNearbySlots
void RegisterNearbySlots()
Registers slots in near distance. Kept for sake of client checks. Skips slots that are in hiearchy of...
Definition
SCR_SlotService.c:68
OnSlotUpdate
void OnSlotUpdate(SCR_EntitySpawnerSlotComponent slot, vector position)
Called, if slot possition was changed. If it fails to meet previously required criteria in CanBeSlotR...
Definition
SCR_SlotService.c:94
params
category params
Definition
SCR_SpherePointGeneratorPreviewComponent.c:21
category
params category
Definition
SCR_VehicleDamageManagerComponent.c:302
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetOrigin
proto external vector GetOrigin()
IEntity::GetChildren
proto external IEntity GetChildren()
IEntity::GetParent
proto external IEntity GetParent()
IEntity::GetSibling
proto external IEntity GetSibling()
SCR_ServicePointComponentClass
Definition
SCR_ServicePointComponent.c:2
SCR_SlotServiceComponentClass
Definition
SCR_SlotService.c:2
SCR_SlotServiceComponentClass::m_fMaxSlotDistance
float m_fMaxSlotDistance
Definition
SCR_SlotService.c:4
SCR_SlotServiceComponentClass::GetMaxSlotDistance
float GetMaxSlotDistance()
Definition
SCR_SlotService.c:8
vector
Definition
vector.c:13
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
EOnInit
override void EOnInit(IEntity owner)
Definition
SCR_AIConfigComponent.c:87
Print
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
LogLevel
Enum with severity of the logging message.
Definition
LogLevel.c:14
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
scripts
Game
Components
Spawner
CatalogSpawner
SCR_SlotService.c
Generated by
1.17.0