3 static const string PORT_POSITION =
"Position";
4 static const string PORT_AGENT =
"Agent";
5 static const string PORT_VEHICLE =
"Vehicle";
7 [
Attribute(
"0", UIWidgets.CheckBox,
"Occupy driver compartment with Group Leader Agent?" )]
8 protected bool m_bAllowLeaderAsDriver;
10 private IEntity m_VehicleEntity;
13 override void OnEnter(AIAgent owner)
15 GetVariableIn(PORT_VEHICLE, m_VehicleEntity);
19 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
23 ClearVariable(PORT_POSITION);
24 return ENodeResult.FAIL;
27 BaseCompartmentManagerComponent compartmentMan = BaseCompartmentManagerComponent.Cast(m_VehicleEntity.FindComponent(BaseCompartmentManagerComponent));
30 return NodeError(
this, owner,
"Missing compartment manager on IEntity" + m_VehicleEntity.ToString());
33 ref array<BaseCompartmentSlot> compartments = {}, pilotComp = {}, turretComp = {}, cargoComp = {};
34 int numOfComp = compartmentMan.GetCompartments(compartments);
38 return NodeError(
this, owner,
"GetEmptyCompartment not run on SCR_AIGroup agent!");
41 BaseCompartmentSlot compartmentToAlocate;
42 bool foundEmptyCompartment;
44 GetVariableIn(PORT_AGENT, groupMember);
45 if (group.GetAgentsCount() == 1)
46 m_bAllowLeaderAsDriver =
true;
48 foreach (BaseCompartmentSlot comp : compartments)
50 if (!comp.AttachedOccupant() && comp.IsCompartmentAccessible())
53 pilotComp.Insert(comp);
55 turretComp.Insert(comp);
57 cargoComp.Insert(comp);
58 foundEmptyCompartment =
true;
62 if (!foundEmptyCompartment)
64 ClearVariable(PORT_POSITION);
65 return ENodeResult.FAIL;
68 if (groupMember != group.GetLeaderAgent())
70 if (!pilotComp.IsEmpty())
71 compartmentToAlocate = pilotComp[0];
72 else if (!turretComp.IsEmpty())
73 compartmentToAlocate = turretComp[0];
74 else if (!cargoComp.IsEmpty())
75 compartmentToAlocate = cargoComp[0];
79 if (m_bAllowLeaderAsDriver && !pilotComp.IsEmpty())
80 compartmentToAlocate = pilotComp[0];
81 else if (!cargoComp.IsEmpty())
82 compartmentToAlocate = cargoComp[0];
83 else if (!turretComp.IsEmpty())
84 compartmentToAlocate = turretComp[0];
87 if (compartmentToAlocate)
89 group.AllocateCompartment(compartmentToAlocate);
90 PrintFormat(
"Here %1 for %2", compartmentToAlocate, owner);
92 return ENodeResult.SUCCESS;
95 ClearVariable(PORT_POSITION);
96 return ENodeResult.FAIL;
100 protected static ref TStringArray s_aVarsIn = {
104 override TStringArray GetVariablesIn()
110 protected static ref TStringArray s_aVarsOut = {
113 override TStringArray GetVariablesOut()
119 override bool VisibleInPalette()
125 override string GetOnHoverDescription()
127 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";