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_AIDecoTestDoorIsOpen.c
Go to the documentation of this file.
1
class
SCR_AIDecoTestDoorIsOpen
:
DecoratorTestScripted
2
{
3
private
DoorComponent
m_doorComponent;
4
5
//------------------------------------------------------------------------------------------------
6
protected
override
bool
TestFunction
(AIAgent agent,
IEntity
controlled)
7
{
8
if
(controlled)
9
{
10
if
(!m_doorComponent)
11
m_doorComponent =
DoorComponent
.Cast(controlled.
FindComponent
(
DoorComponent
));
12
if
(!m_doorComponent)
13
return
false
;
14
return
m_doorComponent.IsOpen();
15
}
16
return
false
;
17
}
18
};
19
20
class
SCR_AIDecoTestDoorIsConditionWithSiblings
:
DecoratorTestScripted
21
{
22
private
ref array<DoorComponent> m_aDoorComponents;
23
//------------------------------------------------------------------------------------------------
24
protected
bool
Predicate
(
DoorComponent
dc, AIAgent agent,
IEntity
controlled)
25
{
26
return
true
;
27
}
28
//------------------------------------------------------------------------------------------------
29
protected
override
bool
TestFunction
(AIAgent agent,
IEntity
controlled)
30
{
31
if
(controlled)
32
{
33
if
(!m_aDoorComponents)
34
{
35
m_aDoorComponents = {};
36
FindDoorComponents
(controlled, m_aDoorComponents);
37
}
38
39
if
(m_aDoorComponents.IsEmpty())
40
return
false
;
41
42
foreach
(
DoorComponent
dc : m_aDoorComponents)
43
{
44
if
(!dc)
45
return
false
;
46
47
bool
isTotallyOpen =
Math
.AbsFloat(dc.GetNormalizedDoorState()) > 1.0 -
SCR_AIOpenDoor
.STATE_EPSILON;
48
bool
isOpen = isTotallyOpen || dc.IsOpening();
49
50
if
(!isOpen)
51
return
false
;
52
}
53
return
true
;
54
}
55
return
false
;
56
}
57
//------------------------------------------------------------------------------------------------
58
static
void
FindDoorComponents
(notnull
IEntity
doorEntity, notnull array<DoorComponent> outDoorComponents)
59
{
60
outDoorComponents.Clear();
61
62
IEntity
doorParent = doorEntity.
GetParent
();
63
if
(!doorParent)
64
{
65
// Door is in world root, or we don't care for siblings
66
DoorComponent
doorComponent =
DoorComponent
.Cast(doorEntity.FindComponent(
DoorComponent
));
67
if
(doorComponent)
68
outDoorComponents.Insert(doorComponent);
69
return
;
70
}
71
72
IEntity
doorSibling = doorParent.
GetChildren
();
73
74
// Door is in some hierarchy, check all children of parent of the door
75
while
(doorSibling)
76
{
77
DoorComponent
doorComponent =
DoorComponent
.Cast(doorSibling.
FindComponent
(
DoorComponent
));
78
if
(doorComponent)
79
outDoorComponents.Insert(doorComponent);
80
81
doorSibling = doorSibling.
GetSibling
();
82
}
83
}
84
}
85
//------------------------------------------------------------------------------------------------
86
class
SCR_AIDecoTestDoorIsOpeningWithSiblings :
SCR_AIDecoTestDoorIsConditionWithSiblings
87
{
88
protected
override
bool
Predicate
(DoorComponent dc, AIAgent agent,
IEntity
controlled)
89
{
90
bool
isTotallyOpen = Math.AbsFloat(dc.GetNormalizedDoorState()) > 1.0 - SCR_AIOpenDoor.STATE_EPSILON;
91
return
isTotallyOpen || dc.IsOpening();
92
}
93
}
94
//------------------------------------------------------------------------------------------------
95
class
SCR_AIDecoTestDoorIsOpenWithSiblings
:
SCR_AIDecoTestDoorIsConditionWithSiblings
96
{
97
protected
override
bool
Predicate
(
DoorComponent
dc, AIAgent agent,
IEntity
controlled)
98
{
99
return
!dc.IsOpening() && dc.IsOpen();
100
}
101
};
Predicate
SCR_AIDecoTestDoorIsOpenWithSiblings Predicate
Definition
SCR_AIDecoTestDoorIsOpen.c:91
IEntity
enum EVehicleType IEntity
DecoratorTestScripted
Definition
DecoratorTestScripted.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
SCR_AIDecoTestDoorIsConditionWithSiblings
Definition
SCR_AIDecoTestDoorIsOpen.c:21
SCR_AIDecoTestDoorIsConditionWithSiblings::Predicate
bool Predicate(DoorComponent dc, AIAgent agent, IEntity controlled)
Definition
SCR_AIDecoTestDoorIsOpen.c:24
SCR_AIDecoTestDoorIsConditionWithSiblings::TestFunction
override bool TestFunction(AIAgent agent, IEntity controlled)
Definition
SCR_AIDecoTestDoorIsOpen.c:29
SCR_AIDecoTestDoorIsConditionWithSiblings::FindDoorComponents
static void FindDoorComponents(notnull IEntity doorEntity, notnull array< DoorComponent > outDoorComponents)
Definition
SCR_AIDecoTestDoorIsOpen.c:58
SCR_AIDecoTestDoorIsOpen
Definition
SCR_AIDecoTestDoorIsOpen.c:2
SCR_AIDecoTestDoorIsOpen::TestFunction
override bool TestFunction(AIAgent agent, IEntity controlled)
Definition
SCR_AIDecoTestDoorIsOpen.c:6
SCR_AIDecoTestDoorIsOpenWithSiblings
Definition
SCR_AIDecoTestDoorIsOpen.c:96
SCR_AIDecoTestDoorIsOpenWithSiblings::Predicate
override bool Predicate(DoorComponent dc, AIAgent agent, IEntity controlled)
Definition
SCR_AIDecoTestDoorIsOpen.c:97
SCR_AIOpenDoor
Definition
SCR_AIOpenDoor.c:2
scripts
Game
AI
ScriptedNodes
Behavior
SCR_AIDecoTestDoorIsOpen.c
Generated by
1.17.0