Files
mrgameeng/src/MrGameEng.Simulation/Pathfinding/IPathGrid.cs
T

35 lines
1.1 KiB
C#

namespace MrGameEng.Pathfinding;
/// <summary>Neighbor connectivity of a grid.</summary>
public enum GridConnectivity
{
/// <summary>Orthogonal moves only.</summary>
Four = 4,
/// <summary>Orthogonal and diagonal moves. Diagonals never cut corners.</summary>
Eight = 8,
}
/// <summary>
/// A grid the pathfinding algorithms operate on. The game implements this over its own
/// world representation (terrain cells, a <c>TileGrid</c>, …) — the pathfinding module
/// never owns world data.
/// </summary>
public interface IPathGrid
{
/// <summary>Grid width in cells.</summary>
int Width { get; }
/// <summary>Grid height in cells.</summary>
int Height { get; }
/// <summary>True when the cell can be entered. Out-of-range cells are never queried.</summary>
bool IsPassable(int x, int y);
/// <summary>
/// Cost multiplier for entering the cell, <b>must be ≥ 1</b> (1 = normal terrain,
/// 3 = swamp three times slower, …). Used by A* and Dijkstra; ignored by BFS.
/// </summary>
float Cost(int x, int y);
}