RuntimeSaveLoadManager

Overview

Manages save/load for runtime-instantiated objects implementing IRuntimeSaveable, such as Laboratory, Distribution Spot (code: LocalLaboratory), and Route prefabs. Each saveable writes a standardized header with PrefabType and RegionId; the manager uses this to sort and restore objects deterministically.

Disk File

  • runtime_save.json in Application.persistentDataPath.
  • interface IRuntimeSaveable { void OnSave(StringWriter); void OnLoad(StringReader); }
  • RuntimeSaveableHelper — writes/reads header lines: PrefabType:<type> and RegionId:<id>.

Prefab Order (load first → last)

  1. Laboratory
  2. LocalLaboratory (= Distribution Spot)
  3. Route

Public API

  • void SaveAll() — finds all IRuntimeSaveable, orders them by PrefabType, captures their text payload, and writes a JSON list.
  • void LoadAll() — reads JSON, sorts entries by PrefabType, instantiates the correct prefab, and dispatches OnLoad for each.

Inspector

  • Assign laboratoryPrefab, localLaboratoryPrefab (Distribution Spot), and routePrefab.
  • Editor adds Save Runtime Objects / Load Runtime Objects buttons.