Header menu logo Mibo

CellGrid2D Module

Functions and values

Function or value Description

create width height cellSize origin

Full Usage: create width height cellSize origin

Parameters:
Returns: CellGrid2D<'T>

Allocates a new grid. This is an O(Width * Height) operation that allocates a single contiguous array.

width : int
height : int
cellSize : Vector2
origin : Vector2
Returns: CellGrid2D<'T>

get x y grid

Full Usage: get x y grid

Parameters:
Returns: 'T voption
Modifiers: inline
Type parameters: 'T

Retrieves a cell's value. Returns ValueNone for out-of-bounds coordinates. O(1).

x : int
y : int
grid : CellGrid2D<'T>
Returns: 'T voption

getWorldPos x y grid

Full Usage: getWorldPos x y grid

Parameters:
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.

x : ^a
y : ^b
grid : CellGrid2D<'T>
Returns: Vector2

iter action grid

Full Usage: iter action grid

Parameters:
    action : int -> int -> 'T -> unit
    grid : CellGrid2D<'T>

Modifiers: inline
Type parameters: 'T

Iterates over every populated cell in the grid. Skips ValueNone cells cheaply.

action : int -> int -> 'T -> unit
grid : CellGrid2D<'T>

iterVisible bounds action grid

Full Usage: iterVisible bounds action grid

Parameters:
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.

bounds : Rectangle
action : int -> int -> 'T -> unit
grid : CellGrid2D<'T>

set x y content grid

Full Usage: set x y content grid

Parameters:
    x : 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).

x : int
y : int
content : 'T
grid : CellGrid2D<'T>

Type something to start searching.