~ruther/NosSmooth

287285c0a17c745afe5cb261a3a557d278c185c8 — Rutherther 2 years ago 8933958
feat(pathfinding): create custom pathfinding
M Extensions/NosSmooth.Extensions.Combat/Operations/WalkInRangeOperation.cs => Extensions/NosSmooth.Extensions.Combat/Operations/WalkInRangeOperation.cs +2 -1
@@ 6,6 6,7 @@

using NosSmooth.Extensions.Combat.Errors;
using NosSmooth.Extensions.Pathfinding;
using NosSmooth.Extensions.Pathfinding.Errors;
using NosSmooth.Game.Data.Entities;
using NosSmooth.Game.Data.Info;
using Remora.Results;


@@ 96,7 97,7 @@ public record WalkInRangeOperation
                return Result.FromSuccess();
            }

            if (!walkResult.IsSuccess && walkResult.Error is NotFoundError)
            if (!walkResult.IsSuccess && walkResult.Error is PathNotFoundError)
            {
                if (distance - 1 > 0)
                {

A Extensions/NosSmooth.Extensions.Pathfinding/Errors/PathNotFoundError.cs => Extensions/NosSmooth.Extensions.Pathfinding/Errors/PathNotFoundError.cs +16 -0
@@ 0,0 1,16 @@
//
//  PathNotFoundError.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Remora.Results;

namespace NosSmooth.Extensions.Pathfinding.Errors;

/// <summary>
/// Could not find path to the given target.
/// </summary>
/// <param name="TargetX">The target x coordinate.</param>
/// <param name="TargetY">The target y coordinate.</param>
public record PathNotFoundError(short TargetX, short TargetY) : ResultError($"Path to {TargetX}, {TargetY} not found.");
\ No newline at end of file

M Extensions/NosSmooth.Extensions.Pathfinding/Pathfinder.cs => Extensions/NosSmooth.Extensions.Pathfinding/Pathfinder.cs +1 -1
@@ 159,7 159,7 @@ public class Pathfinder
            }
        }

        return new NotFoundError("Could not find path to the given position.");
        return new PathNotFoundError(targetX, targetY);
    }

    private Path ReconstructPath

Do not follow this link