Logo Mibo

CellGrid2D Module

Functions and values

Function or value Description

clear x y grid

Full Usage: clear x y grid

Parameters:
Modifiers: inline
Type parameters: 'T

Empties one cell. Out-of-range coordinates are ignored.

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

create width height cellSize origin

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.

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

createHex spec

Full Usage: createHex spec

Parameters:
Returns: CellGrid2D<'T>
Type parameters: 'T

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.

spec : HexSpec
Returns: CellGrid2D<'T>

get x y grid

Full Usage: get x y grid

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

Reads one cell. Answers `ValueNone` for an empty cell and for out-of-range coordinates.

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: 'T

The world position of a cell. Square grids step by `CellSize`; hex grids stagger every other row (pointy top) or column (flat top).

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

hexOrientation grid

Full Usage: hexOrientation grid

Parameters:
Returns: HexOrientation
Type parameters: 'T

The hex orientation of a hex-geometry grid. Throws for square grids.

grid : CellGrid2D<'T>
Returns: HexOrientation

hexRadius grid

Full Usage: hexRadius grid

Parameters:
Returns: float32
Type parameters: 'T

The hex radius (center to corner) of a hex-geometry grid. Throws for square grids.

grid : CellGrid2D<'T>
Returns: float32

iter action grid

Full Usage: iter action grid

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

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

iterVisible left top right bottom action grid

Full Usage: iterVisible left top right bottom action grid

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

left : int
top : int
right : int
bottom : int
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

Writes `content` into one cell. Out-of-range coordinates are ignored, so a section walk needs no bounds check.

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

visibleRange left top right bottom grid

Full Usage: visibleRange left top right bottom grid

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

left : int
top : int
right : int
bottom : int
grid : CellGrid2D<'T>
Returns: int * int * int * int

Type something to start searching.