GridWalls
namespace Griff.Scenes;
public sealed class GridWallsWhere a grid mover can’t go, gathered once so a search can ask about many cells: off its map (when it has to stay on), solid tiles on any tilemap, solid colliders over a cell’s middle, a solid conveyor’s belts (not its crossings), and the cells other grid movers are in or heading into. Layers either side passes through don’t count. FindWay searches it for the shortest way somewhere.
Properties
Section titled “Properties”public GridCells Grid { get; }The cells it’s about.
public ValueTuple<int, int>? Size { get; }The width and height of its map in cells (its widest layer), or null with no map.
Methods
Section titled “Methods”FindWay
Section titled “FindWay”public List<ValueTuple<int, int>>? FindWay(ValueTuple<int, int> start, ValueTuple<int, int>[] goals, bool diagonal, bool avoidMovers, IReadOnlySet<ValueTuple<int, int>>? avoid = null)A* over cells from start to the nearest of goals: the cells to step into after the start, ending at the goal it reaches; empty if the start is one; null if none can be reached. It never goes through walls or avoid’s cells, nor, with avoidMovers, other grid movers (but into a goal, whoever stands there). Four ways, or eight with diagonal (never cutting a corner); six on a hex map.
Gather
Section titled “Gather”public static GridWalls Gather(Scene scene, GridMovement m, GridCells grid, Entity? except = null)Gathers where m can’t go on grid in scene (only solid colliders on its BlockingLayers, if it has any), leaving out the mover except (the one searching).
IsFree
Section titled “IsFree”public bool IsFree(ValueTuple<int, int> cell)True if nothing blocks a cell: no wall and no grid mover in it or heading into it.
IsWall
Section titled “IsWall”public bool IsWall(ValueTuple<int, int> cell)Off the map it has to stay on, a solid tile, or under a solid collider.
MoverIn
Section titled “MoverIn”public Entity? MoverIn(ValueTuple<int, int> cell)The grid mover in a cell, or heading into it.
Fields
Section titled “Fields”SearchLimit
Section titled “SearchLimit”public const int SearchLimitThe most cells a search for a way looks at before it gives up.
SearchMargin
Section titled “SearchMargin”public const int SearchMarginHow far past the ends a search for a way goes with no map to keep it in, in cells.