Lifecycle-safe patterns from WBML
✅ Evidence-backed recipes WorldBox 0.51.2 baseline
Wait for world generation
Section titled “Wait for world generation”Prefer: persistent runner → finishMakingWorld → live collections → short stability window → heavy validation once. Do not wait for reference replacement.
Prove a reload
Section titled “Prove a reload”Use several independent signals: load lifecycle signal, changed marker disappearing, live collections, stable post-load polls. Do not require exact Height equality.
Hold references across lifecycle boundaries
Section titled “Hold references across lifecycle boundaries”Treat identity reuse as possible but not guaranteed. After load/worldgen/destruction, revalidate against the current manager/collection. Stable IDs plus re-query are safer than assuming the wrapper is current.
Scan the map
Section titled “Scan the map”Chunk large scans and yield between chunks. Cheap polling belongs in wait loops; a rich 65,536-object reflection pass does not.
Use SaveManager
Section titled “Use SaveManager”Do not guess paths/slots/arguments. Inspect signatures first and invoke only a path whose parameters are understood. Use disposable worlds for destructive research.
Check Unity liveness
Section titled “Check Unity liveness”Do not use only ReferenceEquals(x, null). Unity fake-null and end-of-frame destruction semantics matter; avoid member access on destroyed wrappers unless the behavior is deliberately being probed.
Diagnose mod conflicts
Section titled “Diagnose mod conflicts”Do not compare only total assembly count. Compare concrete added/removed assemblies, core type uniqueness, Harmony owners and live manager/map state.
Version changes
Section titled “Version changes”A green 0.51.2 result becomes a baseline for diffing, not an eternal contract. Re-run the smallest affected probes when WorldBox/NML changes.