3 static const string PORT_CENTER_OF_SEARCH =
"OriginIn";
4 static const string PORT_RADIUS =
"RadiusIn";
5 static const string PORT_TURRET_NUMBER =
"TurretNumber";
6 static const string PORT_TURRET_FOUND =
"TurretsFound";
8 private BaseWorld m_world;
9 private int m_turretCount;
10 private int m_agentsCount;
11 private bool m_turretsFound;
15 override bool VisibleInPalette() {
return true;}
18 override void OnInit(AIAgent owner)
25 m_groupOwner =
SCR_AIGroup.Cast(owner.GetParentGroup());
27 NodeError(
this, owner,
"Node is not run on SCR_AIGroup agent or owner is not member of SCR_AIGroup!");
32 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
36 ClearVariable(PORT_TURRET_NUMBER);
37 ClearVariable(PORT_TURRET_FOUND);
38 return ENodeResult.FAIL;
42 m_agentsCount = m_groupOwner.GetAgentsCount();
44 GetVariableIn(PORT_CENTER_OF_SEARCH, center);
45 GetVariableIn(PORT_RADIUS, radius);
47 m_world.QueryEntitiesBySphere(center, radius, GetFirstEntity, FilterEntities, EQueryEntitiesFlags.DYNAMIC | EQueryEntitiesFlags.WITH_OBJECT);
49 SetVariableOut(PORT_TURRET_NUMBER, m_turretCount);
51 ClearVariable(PORT_TURRET_NUMBER);
52 SetVariableOut(PORT_TURRET_FOUND, m_turretsFound);
53 return ENodeResult.SUCCESS;
56 bool GetFirstEntity(IEntity ent)
58 BaseCompartmentManagerComponent compComp = BaseCompartmentManagerComponent.Cast(ent.FindComponent(BaseCompartmentManagerComponent));
62 array<BaseCompartmentSlot> compartmentSlots = {};
63 compComp.GetCompartments(compartmentSlots);
64 foreach (BaseCompartmentSlot slot : compartmentSlots)
69 if (!turretComp.AttachedOccupant() && turretComp.IsCompartmentAccessible() && !turretComp.IsReserved())
73 m_turretsFound =
true;
74 if (m_turretCount <= m_agentsCount)
75 m_groupOwner.AllocateCompartment(turretComp);
84 bool FilterEntities(IEntity ent)
86 return Turret.Cast(ent) !=
null;
90 protected static ref TStringArray s_aVarsOut = {
94 override TStringArray GetVariablesOut()
100 protected static ref TStringArray s_aVarsIn = {
101 PORT_CENTER_OF_SEARCH,
104 override TStringArray GetVariablesIn()