3 static const string PORT_POSITION =
"Position";
4 static const string PORT_COMPARTMENT =
"CompartmentSlot";
5 static const string PORT_AGENT =
"Agent";
6 static const string PORT_VEHICLE =
"Vehicle";
7 static const string PORT_BOARDING_PARAMS =
"BoardingParams";
9 [
Attribute(
"0",
UIWidgets.CheckBox,
"Occupy driver compartment with Group Leader Agent?" )]
12 private IEntity m_VehicleEntity;
15 override void OnEnter(AIAgent owner)
29 SCR_AIBoardingParameters
params;
31 params =
new SCR_AIBoardingParameters;
33 BaseCompartmentManagerComponent compartmentMan = BaseCompartmentManagerComponent.Cast(m_VehicleEntity.FindComponent(BaseCompartmentManagerComponent));
36 return NodeError(
this, owner,
"Missing compartment manager on IEntity" + m_VehicleEntity.ToString());
39 ref array<BaseCompartmentSlot> compartments = {}, pilotComp = {}, turretComp = {}, cargoComp = {};
40 int numOfComp = compartmentMan.GetCompartments(compartments);
46 return NodeError(
this, owner,
"Missing parent SCR_AIGroup class");
50 return NodeError(
this, owner,
"vehicle provided is not registered as used inside group!");
55 BaseCompartmentSlot compartmentToAlocate;
56 bool foundEmptyCompartment;
59 if (group.GetAgentsCount() == 1)
62 foreach (BaseCompartmentSlot comp : compartments)
64 if (!comp.AttachedOccupant() && comp.IsCompartmentAccessible() && !comp.IsReserved())
66 if (PilotCompartmentSlot.Cast(comp) &&
params.m_bIsDriverAllowed && canBePiloted)
67 pilotComp.Insert(comp);
68 else if (TurretCompartmentSlot.Cast(comp) &&
params.m_bIsGunnerAllowed)
69 turretComp.Insert(comp);
70 else if (CargoCompartmentSlot.Cast(comp) &&
params.m_bIsCargoAllowed)
71 cargoComp.Insert(comp);
74 foundEmptyCompartment =
true;
78 if (!foundEmptyCompartment)
84 if (groupMember != group.GetLeaderAgent())
86 if (!pilotComp.IsEmpty())
87 compartmentToAlocate = pilotComp[0];
88 else if (!turretComp.IsEmpty())
89 compartmentToAlocate = turretComp[0];
90 else if (!cargoComp.IsEmpty())
91 compartmentToAlocate = cargoComp[0];
96 compartmentToAlocate = pilotComp[0];
97 else if (!turretComp.IsEmpty())
98 compartmentToAlocate = turretComp[0];
99 else if (!cargoComp.IsEmpty())
100 compartmentToAlocate = cargoComp[0];
103 if (compartmentToAlocate)
106 SetVariableOut(PORT_POSITION, SCR_AICompartmentHandling.CompartmentClassToType(compartmentToAlocate.Type()));
145 return "Returns type of next usable compartment. Compartments are allocated in GetIn activity. The compartments are selected with priority pilot>turret>cargo unless AIAgent is leader";
ENodeResult NodeError(Node node, AIAgent owner, string msg)
Error call to be used in scripted BT nodes.