4 static const string PORT_MOVE_RESULT =
"MoveResult";
5 static const string PORT_VEHICLE_USED =
"VehicleUsed";
6 static const string PORT_IS_WAYPOINT_RELEATED =
"IsWaypointReleated";
7 static const string PORT_MOVE_LOCATION =
"MoveLocation";
10 SCR_AIGroupUtilityComponent m_GroupUtilityComponent;
13 override void OnInit(AIAgent owner)
20 m_GroupUtilityComponent = SCR_AIGroupUtilityComponent.Cast(
m_Group.FindComponent(SCR_AIGroupUtilityComponent));
24 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
27 if (!GetVariableIn(PORT_MOVE_RESULT, moveResult))
29 NodeError(
this, owner,
"Missing move result for SCR_AIProcessFailedMovementResult node");
30 return ENodeResult.RUNNING;
34 PrintDebug(owner,
string.Format(
"Move failed with result %1",
SCR_Enum.GetEnumName(EMoveRequestResult, moveResult)));
38 if (moveResult == EMoveRequestResult.Uninitialized || moveResult == EMoveRequestResult.Running || moveResult == EMoveRequestResult.Succeeded || moveResult == EMoveRequestResult.Aborted)
40 NodeError(
this, owner,
string.Format(
"Unexpected move result for SCR_AIProcessFailedMovementResult node: %1",
SCR_Enum.GetEnumName(EMoveRequestResult, moveResult)));
41 return ENodeResult.RUNNING;
45 GetVariableIn(PORT_VEHICLE_USED, vehicleUsed);
47 bool isWaypointReleated;
48 GetVariableIn(PORT_IS_WAYPOINT_RELEATED, isWaypointReleated);
51 GetVariableIn(PORT_MOVE_LOCATION, moveLocation);
58 m_GroupUtilityComponent.OnMoveFailed(moveResult, vehicleUsed, isWaypointReleated, moveLocation);
61 if (moveResult == EMoveRequestResult.Failed)
63 if (isWaypointReleated)
68 if (activity && !activity.m_RelatedWaypoint)
71 PrintDebug(owner,
string.Format(
"Failed move as result of deleted waypoint %1", moveLocation));
74 return ENodeResult.FAIL;
79 NodeError(
this, owner,
string.Format(
"Failed move to waypoint %1", moveLocation));
80 return ENodeResult.RUNNING;
85 PrintDebug(owner,
string.Format(
"Failed move while following the entity %1", moveLocation));
88 return ENodeResult.FAIL;
92 if (moveResult == EMoveRequestResult.Stopped || !vehicleUsed)
95 PrintDebug(owner,
string.Format(
"Move failed with result %1 to location %2, failing action.",
SCR_Enum.GetEnumName(EMoveRequestResult, moveResult), moveLocation));
97 if (isWaypointReleated)
103 return ENodeResult.RUNNING;
106 PrintDebug(owner,
string.Format(
"Move failed with result %1 to location %2, retrying without vehicle.",
SCR_Enum.GetEnumName(EMoveRequestResult, moveResult), moveLocation));
109 m_Group.RemoveUsableVehicle(vehicleUsed);
115 activity.m_bUseVehicles.m_Value =
false;
118 return ENodeResult.FAIL;
122 void PrintDebug(AIAgent owner,
string message)
128 Print(
string.Format(
"%1: %2", owner.ToString(), message));
135 AIActionBase currentAction = m_GroupUtilityComponent.GetExecutedAction();
137 currentAction.Fail();
141 void CompleteWaypoint()
143 AIWaypoint waypoint =
m_Group.GetCurrentWaypoint();
145 m_Group.CompleteWaypoint(waypoint);
149 override protected bool CanReturnRunning() {
return true; }
152 protected static ref TStringArray s_aVarsOut = {};
153 override TStringArray GetVariablesOut() {
return s_aVarsOut; }
156 protected static ref TStringArray s_aVarsIn = {PORT_MOVE_RESULT, PORT_VEHICLE_USED, PORT_IS_WAYPOINT_RELEATED, PORT_MOVE_LOCATION};
157 override TStringArray GetVariablesIn() {
return s_aVarsIn; }
160 protected override string GetOnHoverDescription()
162 return "Processes failed movement result for proper BT reaction, calls group's failed move invoker";