~ruther/NosSmooth

35bfb37642045694e90a32fe7d74f4eb7aca889b — Rutherther 2 years ago 89dac16
feat(pathfinding): add user cancelling to walk manager
1 files changed, 3 insertions(+), 2 deletions(-)

M Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs
M Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs => Extensions/NosSmooth.Extensions.Pathfinding/WalkManager.cs +3 -2
@@ 42,10 42,11 @@ public class WalkManager
    /// </remarks>
    /// <param name="x">The target x coordinate.</param>
    /// <param name="y">The target y coordinate.</param>
    /// <param name="allowUserActions">Whether to allow user actions during the walk operation.</param>
    /// <param name="ct">The cancellation token used for cancelling the operation.</param>
    /// <param name="petSelectors">The pet selectors to go with.</param>
    /// <returns>A result that may not succeed.</returns>
    public async Task<Result> GoToAsync(short x, short y, CancellationToken ct = default, params int[] petSelectors)
    public async Task<Result> 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

Do not follow this link