| using SilkroadBot.Domain.Models; |
|
|
| namespace SilkroadBot.Navigation.Interfaces; |
|
|
| |
| |
| |
| |
| public interface IPathfindingAlgorithm |
| { |
| |
| string Name { get; } |
| |
| |
| Task<PathResult> FindPathAsync(WorldPosition start, WorldPosition end, PathfindingOptions? options = null); |
| |
| |
| bool IsPositionWalkable(WorldPosition position); |
| |
| |
| WorldPosition GetNearestWalkablePosition(WorldPosition position); |
| } |
|
|
| |
| |
| |
| public interface IMapDataProvider |
| { |
| |
| Task<RegionNavData?> LoadRegionAsync(short regionId); |
| |
| |
| bool HasRegion(short regionId); |
| |
| |
| IReadOnlyList<short> GetAvailableRegions(); |
| } |
|
|
| |
| |
| |
| public class RegionNavData |
| { |
| public short RegionId { get; init; } |
| public int Width { get; init; } |
| public int Height { get; init; } |
| public byte[,] WalkabilityGrid { get; init; } = new byte[0, 0]; |
| public List<NavNode> Nodes { get; init; } = new(); |
| public List<NavEdge> Edges { get; init; } = new(); |
| } |
|
|
| |
| |
| |
| public record NavNode(int Id, float X, float Y, float Z, bool IsWalkable = true); |
|
|
| |
| |
| |
| public record NavEdge(int FromNodeId, int ToNodeId, float Cost); |
|
|
| |
| |
| |
| public record PathResult |
| { |
| public bool Success { get; init; } |
| public IReadOnlyList<WorldPosition> Waypoints { get; init; } = Array.Empty<WorldPosition>(); |
| public double TotalDistance { get; init; } |
| public TimeSpan ComputeTime { get; init; } |
| public string? ErrorMessage { get; init; } |
| |
| public static PathResult Failed(string reason) => new() { Success = false, ErrorMessage = reason }; |
| } |
|
|
| |
| |
| |
| public record PathfindingOptions |
| { |
| public bool AllowDiagonal { get; init; } = true; |
| public double MaxDistance { get; init; } = double.MaxValue; |
| public int MaxIterations { get; init; } = 10000; |
| public bool SmoothPath { get; init; } = true; |
| public double WaypointSpacing { get; init; } = 10.0; |
| } |
|
|