Skip to content

ZoneMap ​

Inherits: RefCounted

The zones of a world as a picture from above, the same area the map image of the world covers: one byte for each cell, the number of the zone there (0 = no zone). It is made from the three things that say where a zone is (the same order ZoneLookup uses): the default zone of the world fills everything, the zones painted on the terrain (cells of 4 m) go over it, and the zone volumes go over those (the highest priority last, so it wins). Nothing is saved: it is made again from the world whenever the map opens, so a zone painted a minute ago is on the map. The world map panel draws it over the picture of the map (highlights, outlines, the dark outside a zone) and asks it which zone is under the mouse, where a zone is and how big it is. See docs: World > World map.

Variables ​

Rect2rectRect2()
Vector2icellsVector2i(MIN_CELLS, MIN_CELLS)
Array[int]ids[]
intdefault_zone0

Methods ​

ZoneMapbuild( zone_ids: Array[int], default_zone: int, map_rect: Rect2, terrain: Object, volumes: Array ) static
AABBworld_box_of( volume: Node3D ) static
ImageTexturetexture()
Imageget_image()
intzone_at_world( x: float, z: float )
intzone_at_uv( uv: Vector2 )
Vector2uv_of_world( x: float, z: float )
Vector2world_of_uv( uv: Vector2 )
Rect2uv_rect_of( world_rect: Rect2 )
Array[int]zones_present()
intcell_count( zone_id: int )
Rect2bounds_of( zone_id: int, with_children: bool = true )
Vector2centre_of( zone_id: int, with_children: bool = true )
Array[int]family_of( zone_id: int )

Constants ​

  • int MAX_CELLS = 2048 - The most cells a side of the picture has
  • int MIN_CELLS = 16
  • float TERRAIN_CELL = 4.0 - The side of a cell of the terrain's zone layer (metres)

Variable descriptions ​

Rect2 rect = Rect2() ​

The area of the world (x, z in metres) the picture covers

Vector2i cells = Vector2i(MIN_CELLS, MIN_CELLS) ​

Cells along each side

Array[int] ids = [] ​

The zones the picture can hold: ids[i] is the zone with the number i + 1

int default_zone = 0 ​

The default zone of the world (0 = none): it is everywhere nothing else is, so the map gives it no name

Method descriptions ​

ZoneMap build( zone_ids: Array[int], default_zone: int, map_rect: Rect2, terrain: Object, volumes: Array ) ​

Makes the picture. zone_ids are the zones of the world (the picture holds them, and any other zone it finds painted), default_zone the default zone of the world (0 = none), map_rect the area of the world it covers, terrain a ChronicleTerrain (or null), volumes the ZoneVolumes of the world.

AABB world_box_of( volume: Node3D ) ​

The box round the shape of a volume, in the world (an empty box when it has no shape)

ImageTexture texture() ​

The picture as a texture (one byte a cell, nearest filter is what you want)

Image get_image() ​

The picture

int zone_at_world( x: float, z: float ) ​

The zone at a place of the world (0 = none, or outside the picture)

int zone_at_uv( uv: Vector2 ) ​

The zone at a place of the picture (uv from 0 to 1 over the area it covers)

Vector2 uv_of_world( x: float, z: float ) ​

Where a place of the world is on the picture (0 to 1 each way; outside is below 0 or above 1)

Vector2 world_of_uv( uv: Vector2 ) ​

The place of the world (x, z) that a place of the picture is

Rect2 uv_rect_of( world_rect: Rect2 ) ​

A rectangle of the world as a rectangle of the picture (uv)

Array[int] zones_present() ​

The zones that have at least one cell

int cell_count( zone_id: int ) ​

How many cells a zone has (of its own, not of its sub-zones)

Rect2 bounds_of( zone_id: int, with_children: bool = true ) ​

The box (world metres) round the cells of a zone and, with with_children, of its sub-zones. An empty rectangle when it has none

Vector2 centre_of( zone_id: int, with_children: bool = true ) ​

The middle of the cells of a zone (and its sub-zones): where its name goes. The average of its cells, moved to the nearest cell it has when that falls outside it (a ring)

Array[int] family_of( zone_id: int ) ​

The numbers of the zone and its sub-zones (the zones a highlight of the zone covers)