Refactoring a Monolith Making Project: Hadean Truly Moddable

Archived footage of a star system view before the global refactoring.

If you’re fighting a big monolithic controller in Godot, maybe this will be useful.

The mess I had

Progress had basically stalled. The project was held together by a single massive generation/logic controller that touched everything. Tiny changes in one area kept snapping unrelated systems like a twig.

  • Edit a spawn rule? Suddenly the save system complains.
  • Tweak some UI logic? Map gen throws a fit.

The real villain was the legacy global singleton. Everyone just assumed it was there, always initialized, always ready. Removing it was like pulling one Jenga block and watching the whole tower tip. Builds exploded into cascading compile errors.

To make things worse, subsystems were being instantiated before they were attached to the scene tree, so config loading hit null pointers during startup.

The traps along the way

First I tried the naive approach: trim the singleton bit by bit. That died fast. Without changing the architecture, the project just refused to build.

There were other pain points:

  • Directory paths were hardcoded against a very specific folder layout.
  • The whole thing was too rigid for players to drop in custom content.
  • Modding was basically a non-starter.

What actually fixed it

I stopped trying to patch around the singleton and just redesigned it.

Change Why it mattered
Split the monolith into independent submodules using SRP Each module does one thing and owns its own state
Replaced global singletons with explicit dependency injection Systems get what they need passed in — no more magic access
Fixed async races by checking the scene tree before running generation No more initializing subsystems too early
Made resource discovery dynamic Content is found no matter how folders are arranged
Moved from GDScript to C# Made the modular setup way cleaner to maintain

Result

The codebase is now easier to reason about, way less fragile, and players can finally drop in their own mods without fiddling with folder black magic.

1 Like