Grid2DSpatial Module
Nested modules
| Modules | Description |
|
Internal helpers for A* pathfinding. Not intended for direct use. |
Functions and values
| Function or value |
Description
|
Full Usage:
distanceChebyshev x1 y1 x2 y2
Parameters:
^a
y1 : ^c
x2 : ^b
y2 : ^d
Returns: int
Modifiers: inline Type parameters: ^a, ^b, ^c, ^d |
Chebyshev distance: cost of moving in 8 directions (diagonal = 1).
|
Full Usage:
distanceEuclidean x1 y1 x2 y2
Parameters:
^a
y1 : ^d
x2 : ^b
y2 : ^e
Returns: float32
Modifiers: inline Type parameters: ^a, ^b, ^c, ^d, ^e, ^f |
Euclidean distance (straight-line).
|
Full Usage:
distanceManhattan x1 y1 x2 y2
Parameters:
^a
y1 : ^f
x2 : ^b
y2 : ^e
Returns: int
Modifiers: inline Type parameters: ^a, ^b, ^c, ^d, ^e, ^f |
Manhattan distance: cost of moving in 4 directions.
|
Full Usage:
findPath startX startY goalX goalY isPassable costFn grid
Parameters:
int
startY : int
goalX : int
goalY : int
isPassable : int -> int -> bool
costFn : int -> int -> int -> int -> float32
grid : CellGrid2D<'T>
Returns: (int * int)[] voption
Modifiers: inline Type parameters: 'T |
A* pathfinding on a square grid. Returns the shortest path from (startX, startY) to (goalX, goalY) as an array of coordinates, or ValueNone if no path exists. `isPassable` returns true for cells that can be walked through. `costFn` returns the movement cost between two adjacent cells.
|
Full Usage:
floodFill x y predicate grid
Parameters:
int
y : int
predicate : int -> int -> bool
grid : CellGrid2D<'T>
Returns: (int * int)[]
Modifiers: inline Type parameters: 'T |
Flood fill from (x, y) using BFS. Returns all reachable cells for which `predicate` returns true. Does not cross cells where predicate is false.
|
Full Usage:
inRange x y range grid
Parameters:
int32
y : int32
range : int
grid : CellGrid2D<'T>
Returns: (int * int)[]
Modifiers: inline Type parameters: 'T |
Returns all grid cells within Chebyshev distance `range` of (x, y). Includes the origin cell when range >= 0.
|
Full Usage:
lineOfSight x1 y1 x2 y2 isBlocked grid
Parameters:
int
y1 : int
x2 : int
y2 : int
isBlocked : int -> int -> bool
grid : CellGrid2D<'T>
Returns: bool
Modifiers: inline Type parameters: 'T |
Returns true if a straight line from (x1,y1) to (x2,y2) is clear of blocked cells. Uses Bresenham's algorithm. The start cell is not checked; the goal cell IS checked (a blocked goal means LOS is false).
|
Full Usage:
lineOfSightCells x1 y1 x2 y2 isBlocked grid
Parameters:
int
y1 : int
x2 : int
y2 : int
isBlocked : int -> int -> bool
grid : CellGrid2D<'T>
Returns: (int * int)[]
Modifiers: inline Type parameters: 'T |
Returns the visible cells along a line from (x1,y1) toward (x2,y2), stopping at the first blocked cell. The start cell is included if not blocked.
|
Full Usage:
neighbors4 x y grid
Parameters:
int
y : int
grid : CellGrid2D<'T>
Returns: (int * int)[]
Modifiers: inline Type parameters: 'T |
Returns the 4 cardinal (N/S/E/W) neighbors of (x, y), filtered to grid bounds.
|
Full Usage:
neighbors8 x y grid
Parameters:
int32
y : int32
grid : CellGrid2D<'T>
Returns: (int * int)[]
Modifiers: inline Type parameters: 'T |
Returns the 8 surrounding neighbors (cardinal + diagonal), filtered to grid bounds.
|
Full Usage:
worldToCell worldPos grid
Parameters:
Vector2
grid : CellGrid2D<'T>
Returns: (int * int) voption
Modifiers: inline Type parameters: 'T |
Converts a world position to the nearest grid cell coordinates. Returns ValueNone if the position is outside the grid.
|
Mibo