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_ChangeComparmentAction.c
Go to the documentation of this file.
1
class
SCR_ChangeComparmentAction
:
SCR_CompartmentUserAction
2
{
3
[
Attribute
(
"0"
,
desc
:
"If enabled 'Compartment Slot Name' will be ignored and the Pilot compartment will be used"
)]
4
protected
bool
m_bUsePilotCompartment
;
5
6
[
Attribute
(
"SeatsRear"
,
desc
:
"Name of slot that holds the compartment Prefab we want to access. Found on: SlotManagerComponent."
)]
7
protected
string
m_sCompartmentSlotName
;
8
9
protected
ChimeraCharacter
m_Character
;
10
11
// Store the last found free compartment slot
12
protected
BaseCompartmentSlot
m_NonOccupiedSlot
;
13
14
//------------------------------------------------------------------------------------------------
15
override
bool
CanBeShownScript
(
IEntity
user)
16
{
17
m_Character
=
ChimeraCharacter
.Cast(user);
18
19
// We cannot be pilot nor interior, if we are not seated in vehicle at all.
20
if
(!
m_Character
.IsInVehicle())
21
return
false
;
22
23
// If the compartment has never been checked before, do it first
24
if
(!
m_NonOccupiedSlot
)
25
m_NonOccupiedSlot
=
GetFreeCompartmentSlot
();
26
27
// If no free compartment slot has been found, don't show this action
28
if
(!
m_NonOccupiedSlot
)
29
return
false
;
30
31
// Check if the last stored free compartment this is occupied
32
if
(
m_NonOccupiedSlot
.GetOccupant())
33
m_NonOccupiedSlot
=
GetFreeCompartmentSlot
();
34
35
return
m_NonOccupiedSlot
&& !
m_NonOccupiedSlot
.GetOccupant();
36
}
37
38
//------------------------------------------------------------------------------------------------
39
override
void
PerformAction
(
IEntity
pOwnerEntity,
IEntity
pUserEntity)
40
{
41
if
(!pOwnerEntity || !pUserEntity)
42
return
;
43
44
m_Character
=
ChimeraCharacter
.Cast(pUserEntity);
45
if
(!
m_Character
)
46
return
;
47
48
BaseCompartmentSlot
targetCompartment =
m_NonOccupiedSlot
;
49
if
(!targetCompartment)
50
return
;
51
52
CompartmentAccessComponent compartmentAccess =
m_Character
.GetCompartmentAccessComponent();
53
if
(!compartmentAccess)
54
return
;
55
56
if
(!compartmentAccess.GetInVehicle(pOwnerEntity, targetCompartment,
false
,
GetRelevantDoorIndex
(pUserEntity),
ECloseDoorAfterActions
.INVALID,
false
))
57
return
;
58
59
super.PerformAction(pOwnerEntity, pUserEntity);
60
}
61
62
//------------------------------------------------------------------------------------------------
63
override
int
GetRelevantDoorIndex
(
IEntity
caller)
64
{
65
if
(
m_iCompartmentDoorInfoIndex
!= -1)
66
return
m_iCompartmentDoorInfoIndex
;
67
68
PlayerController playerController =
GetGame
().GetPlayerController();
69
if
(!playerController || playerController.GetControlledEntity() != caller)
70
return
-1;
71
72
InteractionHandlerComponent
interactionHandler =
InteractionHandlerComponent
.Cast(playerController.FindComponent(
InteractionHandlerComponent
));
73
if
(!interactionHandler)
74
return
-1;
75
76
UserActionContext
actionCtx = interactionHandler.GetCurrentContext();
77
if
(actionCtx)
78
{
79
if
(
m_NonOccupiedSlot
)
80
return
m_NonOccupiedSlot
.PickDoorIndexForPoint(actionCtx.GetOrigin());
81
else
82
return
GetFreeCompartmentSlot
().PickDoorIndexForPoint(actionCtx.GetOrigin());
83
}
84
85
return
-1;
86
}
87
88
//------------------------------------------------------------------------------------------------
91
protected
BaseCompartmentSlot
GetFreeCompartmentSlot
()
92
{
93
Vehicle
vehicle =
Vehicle
.Cast(
GetOwner
().GetRootParent());
94
if
(!vehicle)
95
return
null;
96
97
SCR_BaseCompartmentManagerComponent compartmentManager;
98
99
if
(
m_bUsePilotCompartment
)
100
{
101
PilotCompartmentSlot
pilotCompartmentSlot =
GetPilotCompartmentSlot
();
102
if
(pilotCompartmentSlot)
103
return
pilotCompartmentSlot;
104
105
compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(vehicle.FindComponent(SCR_BaseCompartmentManagerComponent));
106
}
107
else
108
{
109
SlotManagerComponent slotManagerComp = SlotManagerComponent.Cast(vehicle.FindComponent(SlotManagerComponent));
110
if
(!slotManagerComp)
111
return
null;
112
113
EntitySlotInfo
slotInfo = slotManagerComp.GetSlotByName(
m_sCompartmentSlotName
);
114
if
(!slotInfo)
115
return
null;
116
117
IEntity
entity = slotInfo.GetAttachedEntity();
118
119
if
(entity)
120
compartmentManager = SCR_BaseCompartmentManagerComponent.Cast(entity.
FindComponent
(SCR_BaseCompartmentManagerComponent));
121
}
122
123
if
(!compartmentManager)
124
return
null;
125
126
array<BaseCompartmentSlot> outCompartments = {};
127
compartmentManager.GetCompartments(outCompartments);
128
129
// Get the first CompartmentSlot that is not occupied
130
foreach
(
BaseCompartmentSlot
comp : outCompartments)
131
{
132
if
(!comp.GetOccupant())
133
return
comp;
134
}
135
136
return
null;
137
}
138
139
//------------------------------------------------------------------------------------------------
142
protected
PilotCompartmentSlot
GetPilotCompartmentSlot
()
143
{
144
CompartmentAccessComponent compartmentAccess =
m_Character
.GetCompartmentAccessComponent();
145
if
(!compartmentAccess)
146
return
null;
147
148
// Character is in compartment
149
// that belongs to owner of this action
150
BaseCompartmentSlot
slot = compartmentAccess.GetCompartment();
151
if
(!slot)
152
return
null;
153
154
return
PilotCompartmentSlot
.Cast(slot);
155
}
156
}
GetGame
ArmaReforgerScripted GetGame()
Definition
game.c:1398
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition
SCR_RespawnBriefingComponent.c:17
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
ChimeraCharacter
Definition
ChimeraCharacter.c:13
EntitySlotInfo
Adds ability to attach an object to a slot.
Definition
EntitySlotInfo.c:9
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
InteractionHandlerComponent
Definition
InteractionHandlerComponent.c:11
PilotCompartmentSlot
Definition
PilotCompartmentSlot.c:13
SCR_ChangeComparmentAction
Definition
SCR_ChangeComparmentAction.c:2
SCR_ChangeComparmentAction::m_Character
ChimeraCharacter m_Character
Definition
SCR_ChangeComparmentAction.c:9
SCR_ChangeComparmentAction::m_NonOccupiedSlot
BaseCompartmentSlot m_NonOccupiedSlot
Definition
SCR_ChangeComparmentAction.c:12
SCR_ChangeComparmentAction::GetFreeCompartmentSlot
BaseCompartmentSlot GetFreeCompartmentSlot()
Definition
SCR_ChangeComparmentAction.c:91
SCR_ChangeComparmentAction::GetPilotCompartmentSlot
PilotCompartmentSlot GetPilotCompartmentSlot()
Definition
SCR_ChangeComparmentAction.c:142
SCR_ChangeComparmentAction::GetRelevantDoorIndex
override int GetRelevantDoorIndex(IEntity caller)
Definition
SCR_ChangeComparmentAction.c:63
SCR_ChangeComparmentAction::m_sCompartmentSlotName
string m_sCompartmentSlotName
Definition
SCR_ChangeComparmentAction.c:7
SCR_ChangeComparmentAction::PerformAction
override void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
Definition
SCR_ChangeComparmentAction.c:39
SCR_ChangeComparmentAction::m_bUsePilotCompartment
bool m_bUsePilotCompartment
Definition
SCR_ChangeComparmentAction.c:4
SCR_ChangeComparmentAction::CanBeShownScript
override bool CanBeShownScript(IEntity user)
Definition
SCR_ChangeComparmentAction.c:15
SCR_CompartmentUserAction
Definition
SCR_CompartmentUserAction.c:2
SCR_CompartmentUserAction::m_iCompartmentDoorInfoIndex
int m_iCompartmentDoorInfoIndex
Definition
SCR_CompartmentUserAction.c:28
UserActionContext
Definition
UserActionContext.c:16
Vehicle
enum EPhysicsLayerPresets Vehicle
Definition
gameLib.c:24
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition
SCR_FuelNode.c:128
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
ECloseDoorAfterActions
ECloseDoorAfterActions
Definition
ECloseDoorAfterActions.c:13
scripts
Game
UserActions
SCR_ChangeComparmentAction.c
Generated by
1.17.0