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_AIOpenDoor.c
Go to the documentation of this file.
1
class
SCR_AIOpenDoor
:
AITaskScripted
2
{
3
static
const
string
PORT_DOOR_ENTITY =
"DoorEntity"
;
4
static
const
float
STATE_EPSILON = 0.01;
5
6
[
Attribute
(
"0"
)]
7
protected
bool
m_bOpenSiblingDoors
;
8
9
//------------------------------------------------------------------------------------------------
10
override
ENodeResult
EOnTaskSimulate
(AIAgent owner,
float
dt)
11
{
12
IEntity
doorEntity;
13
GetVariableIn
(PORT_DOOR_ENTITY, doorEntity);
14
15
if
(!doorEntity)
16
return
ENodeResult
.FAIL;
17
18
array<ScriptedUserAction> doorActions = {};
19
FindDoorActions
(doorEntity, doorActions,
m_bOpenSiblingDoors
);
20
21
if
(doorActions.IsEmpty())
22
return
ENodeResult
.FAIL;
23
24
IEntity
actionPerformer = owner.GetControlledEntity();
25
if
(!actionPerformer)
26
actionPerformer = owner;
27
28
bool
isOpened =
true
;
29
30
foreach
(
ScriptedUserAction
action : doorActions)
31
{
32
IEntity
actionOwner = action.GetOwner();
33
if
(!actionOwner)
34
continue
;
35
DoorComponent
doorComp =
DoorComponent
.Cast(actionOwner.
FindComponent
(
DoorComponent
));
36
if
(!doorComp)
37
continue
;
38
39
bool
isTotallyOpen =
Math
.AbsFloat(doorComp.GetNormalizedDoorState()) > 1.0 - STATE_EPSILON;
40
41
if
(!isTotallyOpen && !doorComp.IsOpening())
42
{
43
action.PerformAction(actionOwner, actionPerformer);
44
isOpened =
false
45
}
46
}
47
if
(isOpened)
48
return
ENodeResult
.SUCCESS;
49
else
50
return
ENodeResult
.RUNNING;
51
}
52
53
//------------------------------------------------------------------------------------------------
55
static
void
FindDoorActions
(notnull
IEntity
doorEntity, notnull array<ScriptedUserAction> outActions,
bool
includeSiblings)
56
{
57
outActions.Clear();
58
59
IEntity
doorParent = doorEntity.
GetParent
();
60
if
(!doorParent || !includeSiblings)
61
{
62
// Door is in world root, or we don't care for siblings
63
ScriptedUserAction
action =
FindDoorUserAction
(doorEntity);
64
if
(action)
65
outActions.Insert(action);
66
return
;
67
}
68
69
IEntity
doorSibling = doorParent.
GetChildren
();
70
71
// Door is in some hierarchy, check all children of parent of the door
72
while
(doorSibling)
73
{
74
ScriptedUserAction
action =
FindDoorUserAction
(doorSibling);
75
if
(action)
76
outActions.Insert(action);
77
78
doorSibling = doorSibling.
GetSibling
();
79
}
80
}
81
82
//------------------------------------------------------------------------------------------------
83
static
SCR_DoorUserAction
FindDoorUserAction
(notnull
IEntity
entity)
84
{
85
ActionsManagerComponent
actionsMgr =
ActionsManagerComponent
.Cast(entity.FindComponent(
ActionsManagerComponent
));
86
87
if
(!actionsMgr)
88
return
null;
89
90
array<BaseUserAction> actions = {};
91
actionsMgr.GetActionsList(actions);
92
foreach
(
BaseUserAction
action : actions)
93
{
94
SCR_DoorUserAction
doorAction =
SCR_DoorUserAction
.Cast(action);
95
if
(doorAction)
96
return
doorAction;
97
}
98
99
return
null;
100
}
101
102
//------------------------------------------------------------------------------------------------
103
protected
static
override
bool
VisibleInPalette
() {
return
true
; }
104
105
protected
static
override
string
GetOnHoverDescription
() {
return
"Opens the given door. Can also open its sibling doors"
; }
106
107
protected
static
ref
TStringArray
s_aVarsIn
= { PORT_DOOR_ENTITY };
108
override
TStringArray
GetVariablesIn
() {
return
s_aVarsIn
; }
109
};
AITaskScripted
Definition
AITaskScripted.c:13
ActionsManagerComponent
Definition
ActionsManagerComponent.c:6
BaseUserAction
Definition
BaseUserAction.c:13
DoorComponent
Definition
DoorComponent.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
IEntity::GetChildren
proto external IEntity GetChildren()
IEntity::GetParent
proto external IEntity GetParent()
IEntity::GetSibling
proto external IEntity GetSibling()
Math
Definition
Math.c:13
Node::GetVariableIn
proto bool GetVariableIn(string name, out void val)
SCR_AIOpenDoor
Definition
SCR_AIOpenDoor.c:2
SCR_AIOpenDoor::FindDoorUserAction
static SCR_DoorUserAction FindDoorUserAction(notnull IEntity entity)
Definition
SCR_AIOpenDoor.c:83
SCR_AIOpenDoor::s_aVarsIn
static ref TStringArray s_aVarsIn
Definition
SCR_AIOpenDoor.c:107
SCR_AIOpenDoor::EOnTaskSimulate
override ENodeResult EOnTaskSimulate(AIAgent owner, float dt)
Definition
SCR_AIOpenDoor.c:10
SCR_AIOpenDoor::GetVariablesIn
override TStringArray GetVariablesIn()
Definition
SCR_AIOpenDoor.c:108
SCR_AIOpenDoor::FindDoorActions
static void FindDoorActions(notnull IEntity doorEntity, notnull array< ScriptedUserAction > outActions, bool includeSiblings)
Searches doorEntity and all its siblings (children of same parent) for SCR_DoorUserAction.
Definition
SCR_AIOpenDoor.c:55
SCR_AIOpenDoor::m_bOpenSiblingDoors
bool m_bOpenSiblingDoors
Definition
SCR_AIOpenDoor.c:7
SCR_AIOpenDoor::GetOnHoverDescription
static override string GetOnHoverDescription()
Definition
SCR_AIOpenDoor.c:105
SCR_AIOpenDoor::VisibleInPalette
static override bool VisibleInPalette()
Definition
SCR_AIOpenDoor.c:103
SCR_DoorUserAction
Definition
SCR_DoorUserAction.c:4
ScriptedUserAction
Definition
ScriptedUserAction.c:13
ENodeResult
ENodeResult
Definition
ENodeResult.c:13
Attribute
SCR_FieldOfViewSettings Attribute
Definition
SendGoalMessage.c:170
TStringArray
array< string > TStringArray
Definition
Types.c:385
scripts
Game
AI
ScriptedNodes
Soldier
SCR_AIOpenDoor.c
Generated by
1.17.0