CellGrid2D Module
Functions and values
| Function or value |
Description
|
|
Allocates a new grid. This is an O(Width * Height) operation that allocates a single contiguous array.
|
Full Usage:
get x y grid
Parameters:
int
y : int
grid : CellGrid2D<'T>
Returns: 'T voption
Modifiers: inline Type parameters: 'T |
Retrieves a cell's value. Returns ValueNone for out-of-bounds coordinates. O(1).
|
Full Usage:
getWorldPos x y grid
Parameters:
^a
y : ^b
grid : CellGrid2D<'T>
Returns: Vector2
Modifiers: inline Type parameters: ^a, ^b, 'T |
Projects a grid index (x, y) to its world-space position (top-left of the cell). Does NOT validate bounds.
|
Full Usage:
iter action grid
Parameters:
int -> int -> 'T -> unit
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Iterates over every populated cell in the grid. Skips ValueNone cells cheaply.
|
Full Usage:
iterVisible bounds action grid
Parameters:
Rectangle
action : int -> int -> 'T -> unit
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Optimization for rendering: only iterates cells that intersect the given world-space bounds. Use this to avoid drawing off-screen tiles.
|
Full Usage:
set x y content grid
Parameters:
int
y : int
content : 'T
grid : CellGrid2D<'T>
Modifiers: inline Type parameters: 'T |
Sets a cell's value. Silently ignores out-of-bounds coordinates to allow "painting off the edge" without crashing. O(1).
|
Mibo