HammeriteWorldrepCompile

Core: in the scene. Inherits RefCounted

A just-loaded map's worldrep, compiled on a worker thread so that whoever loaded it can go on drawing, say how far the compile has got, and let it be cancelled (#109). A large level takes minutes to carve the first time, and done where a view first asks for it, it held the main thread for all of them.

Only for a map nothing else holds yet. The compile writes the map's derived state as it goes, so a view reading the same map meanwhile would read it half-built, on another thread. Hand the map to its views once is_done(), after finish():

var job := HammeriteWorldrepCompile.new(map)
job.start()
# each frame: show job.progress.describe(); job.cancel() if asked
if job.is_done() and job.finish():
map_3d.map = map

Properties

TypeNameDefault
HammeriteMapmap
HammeriteCompileProgressprogress

Methods

ReturnsMethod
voidadd_stage(stage_names: PackedStringArray, run: Callable) static
voidremove_stage(first_stage_name: String) static
voidclear_stages() static
voidstop_all() static
voidstart()
boolis_done()
voidcancel()
boolfinish()

Property descriptions

map

var map: HammeriteMap

The map being compiled, as given to the constructor. Read-only: the worker holds it.

progress

var progress: HammeriteCompileProgress

How far the compile has got; safe to read from the main thread while it runs. Also set as HammeriteMap.compile_progress until finish(). Read-only, as map is.

Method descriptions

add_stage()

static func add_stage(stage_names: PackedStringArray, run: Callable) -> void

Hook run into every compile from now on, called as run(map, progress) on the worker once the worldrep is compiled. It reports under stage_names, which are how far through the whole compile a bar is measured; it should stop early once HammeriteCompileProgress.report() answers false, and whatever it derived goes in HammeriteMap.derived. Replaces a stage already added with the same first name.

remove_stage()

static func remove_stage(first_stage_name: String) -> void

Unhook the stage add_stage() registered under first_stage_name. Compiles already started keep it.

clear_stages()

static func clear_stages() -> void

Drop every hooked stage - see the Hammerite autoload's _exit_tree for why this must happen.

stop_all()

static func stop_all() -> void

Stop every compile under way and wait for its worker. For a game closing while one runs - during a loading screen, say: the worker goes on calling the stages hooked into it, which are other addons' nodes, and the tree frees those as it goes. On Linux that was a segmentation fault on the way out.

start()

func start() -> void

Begin compiling. What must happen on the calling thread happens here, before the worker starts.

is_done()

func is_done() -> bool

Whether the worker has finished, cancelled or not. False until start(), so a loading screen polling it before the compile begins waits rather than moving on.

cancel()

func cancel() -> void

Stop at the next item. finish() then answers false.

finish()

func finish() -> bool

Wait for the worker, and whether the compile ran to the end. A cancelled one leaves the worldrep invalid rather than partial, so the map is still usable - its next query compiles it again.

Hammerite 1.0 · built from a6dd634, 2026-10-10