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_AIDecoTestCanGroupDriveVehicle.c
Go to the documentation of this file.
1
class
SCR_AIDecoTestCanGroupDriveVehicle
:
DecoratorTestScripted
2
{
3
//------------------------------------------------------------------------------------------------
5
// "CanDrive" is true if there is available driver seat and entire group fits in the car(s) with available driver seats
6
// TODO: this node as decorator may check this potentially every frame and have big performance impact! Could be hidden
7
// into some component that reacts on Events of compartments
8
protected
override
bool
TestFunction
(AIAgent agent,
IEntity
controlled)
9
{
10
SCR_AIGroup
group =
SCR_AIGroup
.Cast(agent);
11
if
(!group)
12
return
false
;
13
14
SCR_AIGroupUtilityComponent
utility = group.
GetGroupUtilityComponent
();
15
if
(!utility)
16
return
false
;
17
18
array<IEntity> vehicles = {};
19
array<AIAgent> agents = {};
20
utility.
m_VehicleMgr
.
GetAllVehicleEntities
(vehicles);
21
if
(vehicles.IsEmpty())
22
return
false
;
23
24
int
agentsCount = group.GetAgents(agents);
// number of agents we need to find compartments for
25
if
(agents.IsEmpty())
26
return
false
;
27
28
IEntity
vehicleToUse;
29
foreach
(AIAgent ag: agents)
30
{
31
ChimeraCharacter
agentEntity =
ChimeraCharacter
.Cast(ag.GetControlledEntity());
32
if
(!agentEntity)
33
continue
;
34
IEntity
vehicleOfAgent = CompartmentAccessComponent.GetVehicleIn(agentEntity);
35
if
(!vehicleOfAgent)
36
continue
;
37
SCR_AIGroupVehicle
groupVehicle = utility.
m_VehicleMgr
.
FindVehicle
(vehicleOfAgent);
38
if
(!groupVehicle)
39
continue
;
40
SCR_AIVehicleUsageComponent
vehicleUsage = groupVehicle.
GetVehicleUsageComponent
();
41
if
(!vehicleUsage)
42
continue
;
43
if
(!vehicleUsage.
CanBePiloted
())
44
continue
;
45
CompartmentAccessComponent compAcc = agentEntity.GetCompartmentAccessComponent();
46
if
(!compAcc)
47
continue
;
48
agentsCount --;
49
if
(!
PilotCompartmentSlot
.Cast(compAcc.GetCompartment()))
50
continue
;
51
vehicleToUse = vehicleOfAgent;
// group agent is driver inside some of groups registered vehicle
52
}
53
54
if
(agentsCount < 1)
55
return
true
;
56
57
// we will use vehicles array and search for available compartments only in vehicles that have available driver seat
58
BaseCompartmentSlot
compartment;
59
ref array<BaseCompartmentSlot> compartments = {};
60
BaseCompartmentManagerComponent
compMan;
61
62
if
(!vehicleToUse && !
SCR_AICompartmentHandling
.FindAvailableCompartmentInVehicles(vehicles,
ECompartmentType
.PILOT, compartment, vehicleToUse))
63
return
false
;
// no available driver
64
65
while
(!vehicles.IsEmpty() && agentsCount > 0 && vehicleToUse)
66
{
67
SCR_AIGroupVehicle
groupVehicle = utility.
m_VehicleMgr
.
FindVehicle
(vehicleToUse);
68
if
(!groupVehicle)
69
break
;
70
71
SCR_AIVehicleUsageComponent
vehicleUsage = groupVehicle.
GetVehicleUsageComponent
();
72
if
(vehicleUsage && vehicleUsage.
CanBePiloted
())
73
{
74
compMan =
BaseCompartmentManagerComponent
.Cast(vehicleToUse.
FindComponent
(
BaseCompartmentManagerComponent
));
75
if
(!compMan)
76
break
;
77
78
compMan.GetCompartments(compartments);
79
foreach
(
BaseCompartmentSlot
comp: compartments)
80
{
81
if
(!comp.GetOccupant() && comp.IsCompartmentAccessible())
82
agentsCount --;
83
if
(agentsCount == 0)
84
break
;
85
}
86
}
87
88
vehicles.Remove(vehicles.Find(vehicleToUse));
89
if
(!
SCR_AICompartmentHandling
.FindAvailableCompartmentInVehicles(vehicles,
ECompartmentType
.PILOT, compartment, vehicleToUse))
90
break
;
// no vehicle with available driver
91
}
92
93
return
agentsCount == 0;
94
}
95
};
ECompartmentType
ECompartmentType
Definition
ECompartmentType.c:8
BaseCompartmentManagerComponent
Definition
BaseCompartmentManagerComponent.c:13
BaseCompartmentSlot
Definition
BaseCompartmentSlot.c:2
ChimeraCharacter
Definition
ChimeraCharacter.c:13
DecoratorTestScripted
Definition
DecoratorTestScripted.c:13
IEntity
Definition
IEntity.c:13
IEntity::FindComponent
proto external Managed FindComponent(typename typeName)
PilotCompartmentSlot
Definition
PilotCompartmentSlot.c:13
SCR_AICompartmentHandling
Definition
SCR_AIUtils.c:153
SCR_AIDecoTestCanGroupDriveVehicle
Definition
SCR_AIDecoTestCanGroupDriveVehicle.c:2
SCR_AIDecoTestCanGroupDriveVehicle::TestFunction
override bool TestFunction(AIAgent agent, IEntity controlled)
Decorator test that checks vehicles registered on group for availability of compartments for group me...
Definition
SCR_AIDecoTestCanGroupDriveVehicle.c:8
SCR_AIGroup
Definition
SCR_AIGroup.c:75
SCR_AIGroup::GetGroupUtilityComponent
SCR_AIGroupUtilityComponent GetGroupUtilityComponent()
Definition
SCR_AIGroup.c:208
SCR_AIGroupUtilityComponent
Definition
SCR_AIGroupUtilityComponent.c:18
SCR_AIGroupUtilityComponent::m_VehicleMgr
ref SCR_AIGroupVehicleManager m_VehicleMgr
Definition
SCR_AIGroupUtilityComponent.c:63
SCR_AIGroupVehicle
This class is used for keeping track of vehicles assigned to group.
Definition
SCR_AIGroupVehicle.c:3
SCR_AIGroupVehicle::GetVehicleUsageComponent
SCR_AIVehicleUsageComponent GetVehicleUsageComponent()
Definition
SCR_AIGroupVehicle.c:47
SCR_AIGroupVehicleManager::FindVehicle
SCR_AIGroupVehicle FindVehicle(IEntity vehicleEntity)
Definition
SCR_AIGroupVehicleManager.c:6
SCR_AIGroupVehicleManager::GetAllVehicleEntities
void GetAllVehicleEntities(array< IEntity > outAllVehicles)
Definition
SCR_AIGroupVehicleManager.c:47
SCR_AIVehicleUsageComponent
Definition
SCR_AIVehicleUsageComponent.c:30
SCR_AIVehicleUsageComponent::CanBePiloted
bool CanBePiloted()
AI can use the pilot compartments on this vehicle.
Definition
SCR_AIVehicleUsageComponent.c:73
scripts
Game
AI
ScriptedNodes
Vehicles
SCR_AIDecoTestCanGroupDriveVehicle.c
Generated by
1.17.0