From 35bfb37642045694e90a32fe7d74f4eb7aca889b Mon Sep 17 00:00:00 2001 From: Rutherther Date: Sat, 31 Dec 2022 00:06:16 +0100 Subject: [PATCH] feat(pathfinding): add user cancelling to walk manager --- Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs b/Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs index 517ce52..9458163 100644 --- a/Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs +++ b/Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs @@ -42,10 +42,11 @@ public class WalkManager /// /// The target x coordinate. /// The target y coordinate. + /// Whether to allow user actions during the walk operation. /// The cancellation token used for cancelling the operation. /// The pet selectors to go with. /// A result that may not succeed. - public async Task GoToAsync(short x, short y, CancellationToken ct = default, params int[] petSelectors) + public async Task GoToAsync(short x, short y, bool allowUserActions = true, CancellationToken ct = default, params int[] petSelectors) { var pathResult = _pathfinder.FindPathFromCurrent(x, y); if (!pathResult.IsSuccess) @@ -67,7 +68,7 @@ public class WalkManager } var next = path.TakeForwardPath(); - var walkResult = await _client.SendCommandAsync(new WalkCommand(next.X, next.Y, petSelectors, 2), ct); + var walkResult = await _client.SendCommandAsync(new WalkCommand(next.X, next.Y, petSelectors, 2, AllowUserCancel: allowUserActions), ct); if (!walkResult.IsSuccess) { if (path.ReachedEnd && walkResult.Error is WalkNotFinishedError walkNotFinishedError -- 2.48.1