Region

One 64 by 64 tile square of the world, expanded from the cache into the per-plane arrays the map renderer walks: heights, settings, ground overlays and underlays, and the objects standing on it.


Region._InitArrays

procedure TRegion._InitArrays();

Allocates the region’s per-plane tile arrays - 4 planes of 64 by 64, indexed [z, x, y].


Region.Create

function TRegion.Create(id: Integer): TRegion; static;
function TRegion.Create(x, y: Integer): TRegion; static; overload;

An empty region at the given position, addressed either by its packed id or by its region coordinates.

A region id packs its x into the high byte and its y into the low one, and each region covers 64 by 64 world tiles starting at BaseX, BaseY. The tile arrays are allocated but hold nothing until TRegion.LoadTerrain fills them.


Region.LoadTerrain

procedure TRegion.LoadTerrain(constref map: TMapDefinition);

Expands a decoded TMapDefinition into the region’s per-plane tile arrays.

A ground tile with no stored height falls back to the procedural terrain height, which depends only on the tile’s world x and y, so the whole region’s worth is built in one pass the first time any tile asks for it. A tile on a higher plane with no stored height sits 240 above the one below it, the way the client does it.


Region.LoadLocations

procedure TRegion.LoadLocations(constref locs: TLocationsDefinition);

Takes the region’s object placements from a decoded TLocationsDefinition, converting each one from a position within the region to a world coordinate.


Region.GetOverlayID

function TRegion.GetOverlayID(z, x, y: Integer): Integer;

The ground overlay of one tile, or 0 if it has none.

The stored value keeps a flag in its top bit, which is masked off here.


Region.GetUnderlayID

function TRegion.GetUnderlayID(z, x, y: Integer): Integer;

The ground underlay of one tile, or 0 if it has none, with the same flag bit masked off that TRegion.GetOverlayID masks.