Zones

The world consists of zones that determine which areas are loaded and active. Each zone has a size of 64 m x 64 m.

## Zone biome

Biome information is stored in zone corners. If zone has the same biome in all of its corners then it's considered a full biome. Otherwise it's an edge biome.

The biome of a location is based on its distance to the zone corners. For each corner, get the distance from location to the opposing corner, cube and then sum the values for equal biomes. The biome with the highest value is the biome at that location.

For example:

* 1 biome: The biome is 100% of the zone.
* 2 biomes with 2 corners: Each biome is 50% of the zone.
* 1 biome with 3 corners: The dominant biome is about 80% of the zone.
* 1 biome with two corners, 2 biomes with 1 corner: The dominant biome is about 55% of the zone.
* 4 biomes: Each biome is 25% of the zone.

Biomes can be used to detect the middle of a zone by checking when the current biome changes.

## Zone types

### Generated zones

The game generates 9 x 9 zones around each player which places pregenerated locations (abandoned houses, dungeons entraces, etc.) and vegetation (trees, rocks, plants). After generation, most objects are unloaded from the game world (Unity prefabs, not ZDO's).

Locations are fully spawned on **servers** then subsequently destroyed (ghost mode). The only remaining part is the ZDO (for networking). Location proxies are location representative ZDO's created on the server that become visible on the client that otherwise do not have much network-related actions besides existing.

* Haldor gets discovered.
* Locations get placed (genloc command can no longer move them).
* Trees are initialized and visible.

### Loaded zones

The game loads 5 x 5 zones around each player. Zones are loaded with an interval of 0.1 seconds so it can take up to 2.5 seconds to load every nearby zone. Zones out of the 5 x 5 range are removed after 10 seconds.

* Creatures and other objects are initialized.
* Static objects like structures are visible.
* Terrain is initialized and visible (low quality terrain is used after 180 meters).
* Maximum enemy limit is counted from these zones.

### Active zones

The game activates 3 x 3 zones around each player.

* Creatures are visible, move and attack.
* Creatures eat, tame and breed.
* Creatures set to despawn during the day will despawn if it's daytime.
* Food gets cooked.
* Loot gets generated to treasure chests.
* Actions mentioned at "Inactive zones".

### Current zones

The zones that contain a player are considered current zones. Only spawners in current zones are active.

Entering a new zone often spawns more enemies because the cooldown of spawners is tracked per zone.

### Inactive zones

The game keeps track of the last time since activity so actions can "progress" in inactive zones. The actions are executed when the zone becomes active.

* Beehives, Blast furnaces, Charcoal kilns, Fermenters, Smelters, Spinning wheels and Windmills work.
* Creatures regenerate.
* Cooldown of spawners expires.
* Offsprings grow up.
* Tamed creature food expires.
* Plants and trees grow up.
* Berries and other pickables respawn.
* Fireplaces and torches run out.
* Surtlings from fire geysers respawn.
* Dropped items despawn.

Above actions are also affected by sleeping.

## Distance

The actual distance where things are generated depends on the direction and player's position on the zone.

* At center of a zone: 288 meters to west, north, east and south. 407 meters to diagonal directions.
* At corner of a zone: 256 or 320 meters to main directions. 362 or 453 meters to diagonal directions.

The actual distance where things are loaded depends on the direction and player's position on the zone.

* At center of a zone: 160 meters to west, north, east and south. 226 meters to diagonal directions.
* At corner of a zone: 128 or 192 meters to main directions. 181 or 272 meters to diagonal directions.

The actual distance where things are active depends on the direction and player's position on the zone.

* At center of a zone: 96 meters to west, north, east and south. 136 meters to diagonal directions.
* At corner of a zone: 64 or 128 meters to main directions. 91 or 181 meters to diagonal directions.

So overall there can be activity up to 181 meters away.