Update to the timeline triggering logic

This commit is contained in:
Michal Pikulski
2025-10-06 16:16:41 +02:00
committed by Michal Pikulski
parent fd611ac27f
commit bdec77d36f
8 changed files with 875 additions and 933 deletions

View File

@@ -314,7 +314,8 @@ namespace Interactions
}
}
_followerController.GoToPointAndReturn(targetPosition, _playerRef.transform);
// Use the new GoToPoint method instead of GoToPointAndReturn
_followerController.GoToPoint(targetPosition);
// Await follower arrival
await tcs.Task;
@@ -356,7 +357,8 @@ namespace Interactions
}
}
_followerController.GoToPointAndReturn(targetPosition, _playerRef.transform);
// Use the new GoToPoint method instead of GoToPointAndReturn
_followerController.GoToPoint(targetPosition);
// Await follower arrival
await tcs.Task;
@@ -368,10 +370,32 @@ namespace Interactions
if (!_interactionInProgress)
return;
// Dispatch FollowerArrived event
// Dispatch InteractingCharacterArrived event and WAIT for all actions to complete
// This ensures we wait for any timeline animations to finish before proceeding
Debug.Log("[Interactable] Follower arrived, dispatching InteractingCharacterArrived event and waiting for completion");
await DispatchEventAsync(InteractionEventType.InteractingCharacterArrived);
Debug.Log("[Interactable] All InteractingCharacterArrived actions completed, proceeding with interaction");
// After all FollowerArrived actions complete, proceed to character arrived
// Check if we have any components that might have paused the interaction flow
bool hasTimelineActions = false;
foreach (var action in _registeredActions)
{
if (action is InteractionTimelineAction timelineAction &&
timelineAction.respondToEvents.Contains(InteractionEventType.InteractingCharacterArrived) &&
timelineAction.pauseInteractionFlow)
{
hasTimelineActions = true;
break;
}
}
// Tell the follower to return to the player
if (_followerController != null && _playerRef != null)
{
_followerController.ReturnToPlayer(_playerRef.transform);
}
// After all InteractingCharacterArrived actions complete, proceed to character arrived
await BroadcastCharacterArrivedAsync();
}