CellGrid2D Module
Functions and values
| Function or value |
Description
|
Full Usage:
clear x y grid
Parameters:
int
y : int
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Empties one cell. Out-of-range coordinates are ignored.
|
Full Usage:
create width height cellSize origin
Parameters: Returns: CellGrid2D<'T>
Type parameters: 'T |
Creates a square grid. `cellSize` is the cell's width and height.
|
|
Creates a hex grid: hexagons of the spec's `Radius` (center to corner) stored as offset columns and rows. `CellSize` holds the hexagon's bounding box.
|
Full Usage:
get x y grid
Parameters:
int
y : int
grid : CellGrid2D<'T>
Returns: 'T voption
Modifiers: inline Type parameters: 'T |
Reads one cell. Answers `ValueNone` for an empty cell and for out-of-range coordinates.
|
Full Usage:
getWorldPos x y grid
Parameters:
int
y : int
grid : CellGrid2D<'T>
Returns: Vector2
Modifiers: inline Type parameters: 'T |
The world position of a cell. Square grids step by `CellSize`; hex grids stagger every other row (pointy top) or column (flat top).
|
Full Usage:
hexOrientation grid
Parameters:
CellGrid2D<'T>
Returns: HexOrientation
Type parameters: 'T |
The hex orientation of a hex-geometry grid. Throws for square grids.
|
|
The hex radius (center to corner) of a hex-geometry grid. Throws for square grids.
|
Full Usage:
iter action grid
Parameters:
int -> int -> 'T -> unit
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Calls `action` once per populated cell, in row-major order, with the cell's coordinates and content. Empty cells are skipped.
|
Full Usage:
iterVisible left top right bottom action grid
Parameters:
int
top : int
right : int
bottom : int
action : int -> int -> 'T -> unit
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Iterates the cells that intersect a pixel rect, with orientation-aware culling for hex grids (every other row or column staggers, so the window is padded by one cell on each axis). The bounds are conservative: the window may include cells whose hexagon does not touch the rect, but never misses one that does.
|
Full Usage:
set x y content grid
Parameters:
int
y : int
content : 'T
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Writes `content` into one cell. Out-of-range coordinates are ignored, so a section walk needs no bounds check.
|
Full Usage:
visibleRange left top right bottom grid
Parameters:
int
top : int
right : int
bottom : int
grid : CellGrid2D<'T>
Returns: int * int * int * int
Type parameters: 'T |
The inclusive cell range a world-space pixel rect touches. Square grids map the rect through the origin and the cell size; hex grids stagger every other row or column, so the range is padded by one cell on each axis. The bounds are conservative: the range may include cells whose hexagon does not touch the rect, but never misses one that does. The tuple is `struct (startX, endX, startY, endY)`, ready for the two loops a window walk runs — `CellGrid2D.iterVisible` and `Occupancy.iterInWindow` both read it.
|
Mibo