From ac2c6ccae534918f4f9392f6b31fe2d1b434a908 Mon Sep 17 00:00:00 2001 From: Lena Linke <130255332+lenalinke@users.noreply.github.com> Date: Sun, 5 May 2024 20:43:30 +0200 Subject: [PATCH] Change TaskAction StartAdaptiveGazeForTime to use TaskBundles --- .../ScheduleBasedExecution/TaskActions.cs | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs b/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs index b8206ac..cfa4105 100644 --- a/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs +++ b/Assets/Virtual Agents Framework/Runtime/Scripts/ScheduleBasedExecution/TaskActions.cs @@ -126,13 +126,15 @@ public AgentBaseTask PickUp(GameObject pickupObject, int priority = 0, SocketId public AgentBaseTask GoToAndPickUp(GameObject destinationObject, int priority = 0, SocketId bodyAttachPoint = SocketId.RightHand, float minDistance = 0.3f) { List tasks = new List(); + AgentMovementTask movementTask = new AgentMovementTask(destinationObject, default, true); movementTask.MinDistance = minDistance; tasks.Add(movementTask); + AgentPickUpTask pickUpTask = new AgentPickUpTask(destinationObject, bodyAttachPoint); tasks.Add(pickUpTask); - TaskBundle PickUpBundle = new TaskBundle(tasks); + TaskBundle PickUpBundle = new TaskBundle(tasks); scheduleTaskSystem.ScheduleTask(PickUpBundle, priority); return PickUpBundle; } @@ -161,12 +163,14 @@ public AgentBaseTask DropItem(GameObject dropObject = null, int priority = 0) public AgentBaseTask GoToAndDropItem(Vector3 destinationCoordinates, GameObject dropObject = null, int priority = 0) { List tasks = new List(); + AgentMovementTask movementTask = new AgentMovementTask(destinationCoordinates); tasks.Add(movementTask); + AgentDropTask dropTask = new AgentDropTask(dropObject); tasks.Add(dropTask); - TaskBundle dropTaskBundle = new TaskBundle(tasks); + TaskBundle dropTaskBundle = new TaskBundle(tasks); scheduleTaskSystem.ScheduleTask(dropTaskBundle, priority); return dropTaskBundle; } @@ -181,12 +185,14 @@ public AgentBaseTask GoToAndDropItem(Vector3 destinationCoordinates, GameObject public AgentBaseTask GoToAndDropItem(Transform destinationTransform, GameObject dropObject = null, int priority = 0) { List tasks = new List(); + AgentMovementTask movementTask = new AgentMovementTask(destinationTransform.position); tasks.Add(movementTask); + AgentDropTask dropTask = dropObject == null ? new AgentDropTask() : new AgentDropTask(dropObject); tasks.Add(dropTask); - TaskBundle dropTaskBundle = new TaskBundle(tasks); + TaskBundle dropTaskBundle = new TaskBundle(tasks); scheduleTaskSystem.ScheduleTask(dropTaskBundle, priority); return dropTaskBundle; } @@ -199,14 +205,19 @@ public AgentBaseTask GoToAndDropItem(Transform destinationTransform, GameObject /// Returns a AgentBaseTask array with two elements. The first has the starting Task (e.g. for startTask.waitFor(differentTask), and the second the stop Task ((e.g. for differentTask.waitFor(stopTask)) public AgentBaseTask[] StartAdaptiveGazeForTime(float seconds, int priority = 0) { - //TODO: Check if this can better be solved with a TaskBundle + List tasks = new List(); + AgentBaseTask adaptiveGazeTaskStart = new AgentAdaptiveGazeTask(true); - scheduleTaskSystem.ScheduleTask(adaptiveGazeTaskStart, priority, "Head"); - AgentBaseTask waitHead = WaitForSeconds(seconds, priority, "Head"); - waitHead.WaitFor(adaptiveGazeTaskStart); + tasks.Add(adaptiveGazeTaskStart); + + AgentWaitTask agentWaitTask = new AgentWaitTask(seconds); + tasks.Add(agentWaitTask); + AgentBaseTask adaptiveGazeTaskStop = new AgentAdaptiveGazeTask(false); - adaptiveGazeTaskStop.WaitFor(waitHead); - scheduleTaskSystem.ScheduleTask(adaptiveGazeTaskStop, priority, "Head"); + tasks.Add(adaptiveGazeTaskStop); + + TaskBundle adaptiveGazeBundle = new TaskBundle(tasks); + scheduleTaskSystem.ScheduleTask(adaptiveGazeBundle, priority, "Head"); return new AgentBaseTask[] { adaptiveGazeTaskStart, adaptiveGazeTaskStop }; } ///