using SilkroadBot.Domain.Models; namespace SilkroadBot.Navigation.Interfaces; /// /// Abstract pathfinding algorithm interface. /// Allows NavMesh, A*, Dijkstra, or any other algorithm to be plugged in. /// public interface IPathfindingAlgorithm { /// Algorithm name. string Name { get; } /// Find a path between two world positions. Task FindPathAsync(WorldPosition start, WorldPosition end, PathfindingOptions? options = null); /// Check if a position is traversable. bool IsPositionWalkable(WorldPosition position); /// Get the nearest walkable position to the given point. WorldPosition GetNearestWalkablePosition(WorldPosition position); } /// /// Map data provider interface for loading navigation data. /// public interface IMapDataProvider { /// Load navigation data for a region. Task LoadRegionAsync(short regionId); /// Check if navigation data is available for a region. bool HasRegion(short regionId); /// Get all available region IDs. IReadOnlyList GetAvailableRegions(); } /// /// Navigation data for a single map region. /// 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 Nodes { get; init; } = new(); public List Edges { get; init; } = new(); } /// /// A node in the navigation graph. /// public record NavNode(int Id, float X, float Y, float Z, bool IsWalkable = true); /// /// An edge connecting two navigation nodes. /// public record NavEdge(int FromNodeId, int ToNodeId, float Cost); /// /// Result of a pathfinding operation. /// public record PathResult { public bool Success { get; init; } public IReadOnlyList Waypoints { get; init; } = Array.Empty(); 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 }; } /// /// Options for pathfinding calculations. /// 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; }