asobi_zone_manager (asobi v0.35.4)
View SourceLazy zone lifecycle manager for the world server.
Replaces the static zone_pids map with on-demand zone creation and idle reaping. For large worlds (2000x2000 grids), spawning all zones at startup is untenable — this module creates zones on first access and reaps them after an idle timeout.
Hot-path lookups go through ETS directly, bypassing the gen_server.
Summary
Functions
Return existing zone or start a new one. ETS fast path first.
Return all active zone pids. For the ticker.
Non-creating lookup. ETS only.
Spawn all zones in grid. Backward compat for small grids.
Register an externally-spawned zone with the manager.
Hint that zone can be unloaded.
Provide per-coord initial zone_state. Used to thread per-zone state from
GameMod:generate_world/2 (e.g. lua_state for the asobi_lua_world bridge,
or station/planet seeds for sc_game) through to each zone's init. Without
this, zones would all start with empty zone_state and any callback that
needs per-zone setup would silently no-op.
Update the base zone config used when spawning new zones.
Start the zone manager.
Reset idle timer for a zone. Fire-and-forget.
Called by zone on terminate. Cleans up ETS entry.
Functions
Return existing zone or start a new one. ETS fast path first.
Return all active zone pids. For the ticker.
Non-creating lookup. ETS only.
-spec handle_call(term(), gen_server:from(), map()) -> {reply, term(), map()}.
Spawn all zones in grid. Backward compat for small grids.
Register an externally-spawned zone with the manager.
Hint that zone can be unloaded.
Provide per-coord initial zone_state. Used to thread per-zone state from
GameMod:generate_world/2 (e.g. lua_state for the asobi_lua_world bridge,
or station/planet seeds for sc_game) through to each zone's init. Without
this, zones would all start with empty zone_state and any callback that
needs per-zone setup would silently no-op.
Update the base zone config used when spawning new zones.
-spec start_link(map()) -> gen_server:start_ret().
Start the zone manager.
Reset idle timer for a zone. Fire-and-forget.
Called by zone on terminate. Cleans up ETS entry.