Logo FSBarV1_Archived

MapQuery Module

Elmo-coordinate query functions for MapGrid data. All functions accept world-space elmo coordinates and handle the conversion to grid indices internally.

Functions and values

Function or value Description

elmoToGrid x z

Full Usage: elmoToGrid x z

Parameters:
    x : int - X coordinate in elmos.
    z : int - Z coordinate in elmos.

Returns: int * int A tuple (gridX, gridZ) of heightmap grid indices.

Converts elmo (world) coordinates to heightmap grid indices by dividing by 8.

x : int

X coordinate in elmos.

z : int

Z coordinate in elmos.

Returns: int * int

A tuple (gridX, gridZ) of heightmap grid indices.

gridToElmo x z

Full Usage: gridToElmo x z

Parameters:
    x : int - X grid index.
    z : int - Z grid index.

Returns: int * int A tuple (elmoX, elmoZ) of world coordinates.

Converts heightmap grid indices to elmo (world) coordinates by multiplying by 8.

x : int

X grid index.

z : int

Z grid index.

Returns: int * int

A tuple (elmoX, elmoZ) of world coordinates.

heightAtElmo grid x z

Full Usage: heightAtElmo grid x z

Parameters:
    grid : MapGrid - The map grid containing height data.
    x : int - X coordinate in elmos.
    z : int - Z coordinate in elmos.

Returns: Result<float32, string> Ok height if within bounds, or Error message if out of bounds.

Queries the terrain height at the given elmo coordinates.

grid : MapGrid

The map grid containing height data.

x : int

X coordinate in elmos.

z : int

Z coordinate in elmos.

Returns: Result<float32, string>

Ok height if within bounds, or Error message if out of bounds.

heightSubRegion grid x1 z1 x2 z2

Full Usage: heightSubRegion grid x1 z1 x2 z2

Parameters:
    grid : MapGrid - The map grid containing height data.
    x1 : int - Left edge X coordinate in elmos.
    z1 : int - Top edge Z coordinate in elmos.
    x2 : int - Right edge X coordinate in elmos.
    z2 : int - Bottom edge Z coordinate in elmos.

Returns: Result<float32[,], string> Ok subRegion as a 2D float32 array, or Error message if the region has zero or negative size.

Extracts a rectangular sub-region of the heightmap defined by elmo coordinate bounds. Coordinates are clamped to the valid grid range.

grid : MapGrid

The map grid containing height data.

x1 : int

Left edge X coordinate in elmos.

z1 : int

Top edge Z coordinate in elmos.

x2 : int

Right edge X coordinate in elmos.

z2 : int

Bottom edge Z coordinate in elmos.

Returns: Result<float32[,], string>

Ok subRegion as a 2D float32 array, or Error message if the region has zero or negative size.

metalSpotsFromResourceMap grid

Full Usage: metalSpotsFromResourceMap grid

Parameters:
Returns: (float32 * float32 * float32 * float32) array

Scans grid.ResourceMap for connected components of non-zero cells using 8-way connectivity and returns one synthetic metal spot per cluster, in (worldX, worldY, worldZ, richness) tuples matching the shape of GameSnapshot.MetalSpots.

worldX and worldZ are the cluster's centroid in elmos (heightmap cells * 8). worldY is the height at the centroid as read from grid.HeightMap (nearest-cell lookup). richness is the cluster's mean cell value normalised to [0, 1] against the grid's global max resource value. Returns an empty array when the grid contains no non-zero cells. Deterministic.

grid : MapGrid
Returns: (float32 * float32 * float32 * float32) array

nearestMetalSpot spots (position, arg2, arg2)

Full Usage: nearestMetalSpot spots (position, arg2, arg2)

Parameters:
    spots : (float32 * float32 * float32 * float32) array
    position : float32
    arg2 : float32
    arg3 : float32

Returns: (float32 * float32 * float32 * float32) option A list of (gridX, gridZ, resourceValue) tuples sorted by value descending.

Finds all cells in a rectangular region where the resource value exceeds the given threshold. Results are sorted by resource value in descending order (richest first).

spots : (float32 * float32 * float32 * float32) array
position : float32
arg2 : float32
arg3 : float32
Returns: (float32 * float32 * float32 * float32) option

A list of (gridX, gridZ, resourceValue) tuples sorted by value descending.

resourceHotspots grid x1 z1 x2 z2 threshold

Full Usage: resourceHotspots grid x1 z1 x2 z2 threshold

Parameters:
    grid : MapGrid
    x1 : int
    z1 : int
    x2 : int
    z2 : int
    threshold : int

Returns: (int * int * int) list
grid : MapGrid
x1 : int
z1 : int
x2 : int
z2 : int
threshold : int
Returns: (int * int * int) list

slopeAtElmo grid x z

Full Usage: slopeAtElmo grid x z

Parameters:
    grid : MapGrid - The map grid containing slope data.
    x : int - X coordinate in elmos.
    z : int - Z coordinate in elmos.

Returns: Result<float32, string> Ok slope (0.0 = flat, 1.0 = vertical) if within bounds, or Error message if out of bounds.

Queries the terrain slope at the given elmo coordinates.

grid : MapGrid

The map grid containing slope data.

x : int

X coordinate in elmos.

z : int

Z coordinate in elmos.

Returns: Result<float32, string>

Ok slope (0.0 = flat, 1.0 = vertical) if within bounds, or Error message if out of bounds.

terrainAtElmo grid x z

Full Usage: terrainAtElmo grid x z

Parameters:
    grid : MapGrid - The map grid containing height and slope data.
    x : int - X coordinate in elmos.
    z : int - Z coordinate in elmos.

Returns: Result<Terrain, string> Ok terrain with the Terrain classification, or Error message if out of bounds.

Queries the terrain classification at the given elmo coordinates.

grid : MapGrid

The map grid containing height and slope data.

x : int

X coordinate in elmos.

z : int

Z coordinate in elmos.

Returns: Result<Terrain, string>

Ok terrain with the Terrain classification, or Error message if out of bounds.

Type something to start searching.