Sep 30, 2026 · From Ashes to Orbit
Saving a colony by replaying it
The save system loads a fresh scene and replays the colony onto it. Two traps along the way: corridors that placed themselves, and XP awarded twice.
A colony game has a huge amount of state: buildings, workers, storage, research, a launch programme in progress. There are two ways to restore it. You can diff the saved state against the running game and patch the differences, or you can load a clean scene and rebuild everything from the save.
Reload first, then replay
I chose the second. Capturing sweeps the live scene into a save. Loading first reloads the scene from scratch and then applies the save on top. Starting from a known-clean scene is far more reliable than trying to nudge a running game into shape.
Everything is keyed by the string ids on the definition assets, never by asset path, so a save survives assets being moved or renamed. The file is written to a temporary name and swapped into place, so a crash mid-write cannot leave a half-written save.
Buildings use the normal path
Buildings are restored through the same placement code the player uses, with a flag that skips the cost, the research check and the flatness check, but keeps the bounds and occupancy checks. Reusing the real path means the save never drifts from how the game really works.
Trap one: corridors that place themselves
When two modules are placed edge to edge, a connector automatically builds a corridor between them. During a restore, that means the last entry in the list of placed buildings is often an auto-built corridor, not the module I had just restored. The loader now disables the connector during a restore and tracks the real building through the placement event.
Trap two: XP awarded twice
Replaying construction re-checks milestones and re-awards experience and research points for work the player had already done. A single flag now suppresses awards for the whole replay, and progression is written last so its saved values win.
What I would tell my past self
The save bugs were not in the saving. They were in the side effects of rebuilding: things that react to the player’s actions also react to the loader’s. Any system that listens for “a building was placed” has to ask whether the loader is the one placing it.