From fd6aa1d280832ee916ae43a00da70bb27ae97c9a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 13 Jun 2026 06:33:12 +0100 Subject: [PATCH] Isolate legacy catalog boundary --- Assets/Scripts/Gameplay/ActionGameManager.cs | 35 ++++--------------- .../Scripts/Gameplay/LegacyCatalogBoundary.cs | 27 ++++++++++++++ .../Gameplay/LegacyCatalogBoundary.cs.meta | 11 ++++++ Assets/Scripts/UI/MainMenu.cs | 4 +-- .../UI/Properties Panel/PropertiesPanel.cs | 2 +- docs/aetheria-perfect-machine-map.md | 17 ++++----- 6 files changed, 56 insertions(+), 40 deletions(-) create mode 100644 Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs create mode 100644 Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs.meta diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index e3d332a81..571a484cf 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -23,7 +23,6 @@ using UnityEngine.EventSystems; using static Unity.Mathematics.math; using float2 = Unity.Mathematics.float2; using float3 = Unity.Mathematics.float3; -using Path = System.IO.Path; using quaternion = Unity.Mathematics.quaternion; using Random = UnityEngine.Random; @@ -37,33 +36,8 @@ public class ActionGameManager : MonoBehaviour get => _gameDataDirectory ??= new DirectoryInfo(Application.dataPath).Parent.CreateSubdirectory("GameData"); } - public static string AetheriaStateFilePath => Path.Combine(GameDataDirectory.FullName, "aetheria-world.cc"); - public static string LegacyAetherDatabasePath => Path.Combine(GameDataDirectory.FullName, "AetherDB.msgpack"); - - private static CultCache _legacyCultCache; - - public static CultCache LegacyCultCache - { - get - { - if (_legacyCultCache != null) return _legacyCultCache; - - _legacyCultCache = new CultCache(); - _legacyCultCache.AddBackingStore( - new SingleFileMessagePackBackingStore(LegacyAetherDatabasePath)); - - // Particularly heavy objects should be stored in / retrieved from MsgPack files as it's much tighter than JSON - // Such as NameFiles, which are just huge collections of geonames used to condition Markov chains - _legacyCultCache.AddBackingStore(new MultiFileMessagePackBackingStore(GameDataDirectory.FullName), typeof(NameFile)); - - _legacyCultCache.PullAllBackingStores(); - - return _legacyCultCache; - } - } - - [Obsolete("Use LegacyCultCache only for migration-era catalog reads. Live state belongs in GameData/aetheria-world.cc through Aetheria.State.")] - public static CultCache CultCache => LegacyCultCache; + public static string AetheriaStateFilePath => LegacyCatalogBoundary.GetStateFilePath(GameDataDirectory); + public static string LegacyAetherDatabasePath => LegacyCatalogBoundary.GetLegacyCatalogPath(GameDataDirectory); private static PlayerSettings _playerSettings; public static PlayerSettings PlayerSettings @@ -261,7 +235,10 @@ public class ActionGameManager : MonoBehaviour Debug.Log($"Aetheria typed state file: {AetheriaStateFilePath}"); Debug.Log($"Aetheria legacy item catalog: {LegacyAetherDatabasePath}"); - ItemManager = new ItemManager(LegacyCultCache, Settings.GameplaySettings, Debug.Log); + ItemManager = new ItemManager( + LegacyCatalogBoundary.GetCatalogCache(GameDataDirectory), + Settings.GameplaySettings, + Debug.Log); ZoneRenderer.ItemManager = ItemManager; // If hiding minimap asteroids, turn them off to start with diff --git a/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs b/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs new file mode 100644 index 000000000..38677039c --- /dev/null +++ b/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs @@ -0,0 +1,27 @@ +using System.IO; + +public static class LegacyCatalogBoundary +{ + private static CultCache _catalogCache; + + public static string GetStateFilePath(DirectoryInfo gameDataDirectory) + { + return Path.Combine(gameDataDirectory.FullName, "aetheria-world.cc"); + } + + public static string GetLegacyCatalogPath(DirectoryInfo gameDataDirectory) + { + return Path.Combine(gameDataDirectory.FullName, "AetherDB.msgpack"); + } + + public static CultCache GetCatalogCache(DirectoryInfo gameDataDirectory) + { + if (_catalogCache != null) return _catalogCache; + + _catalogCache = new CultCache(); + _catalogCache.AddBackingStore(new SingleFileMessagePackBackingStore(GetLegacyCatalogPath(gameDataDirectory))); + _catalogCache.AddBackingStore(new MultiFileMessagePackBackingStore(gameDataDirectory.FullName), typeof(NameFile)); + _catalogCache.PullAllBackingStores(); + return _catalogCache; + } +} diff --git a/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs.meta b/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs.meta new file mode 100644 index 000000000..ba5030ce6 --- /dev/null +++ b/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f32bcbdbd7db4a3595f11f4540b90a3b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index db0c0ec2e..ff770f843 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -118,7 +118,7 @@ public class MainMenu : MonoBehaviour Settings.SectorGenerationSettings, Settings.SectorBackgroundSettings, Settings.NameGeneratorSettings, - ActionGameManager.LegacyCultCache, + LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory), Debug.Log, setState); Observable.NextFrame().Subscribe(_ => @@ -144,7 +144,7 @@ public class MainMenu : MonoBehaviour Settings.TutorialGenerationSettings, Settings.TutorialBackgroundSettings, Settings.NameGeneratorSettings, - ActionGameManager.LegacyCultCache, + LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory), ActionGameManager.PlayerSettings, ActionGameManager.GameDataDirectory.CreateSubdirectory("Narrative"), Debug.Log, diff --git a/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs b/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs index c2c189224..e5218b57e 100644 --- a/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs +++ b/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs @@ -390,7 +390,7 @@ public class PropertiesPanel : MonoBehaviour AddProperty("Quantity", () => simpleCommodity.Quantity.ToString()); var sheet = AddStatSheet(); - var manufacturer = ActionGameManager.LegacyCultCache.Get(data.Manufacturer); + var manufacturer = LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory).Get(data.Manufacturer); sheet.AddStat("Manufacturer", () => manufacturer?.Name ?? "GameCult"); sheet.AddStat("Mass", () => ActionGameManager.PlayerSettings.Format(GameManager.ItemManager.GetMass(item))); diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index 37a289dbd..93a47bdbd 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -18,9 +18,10 @@ local CultCache, and legacy UI paths should be migration-only or deleted. ## Current Mechanism - Unity client/runtime lives under `Assets/`. Gameplay still reads the legacy - item/name catalog through `ActionGameManager.LegacyCultCache`, but local run - saves, loadouts, player settings files, zone files, and generated keyboard - layout caches no longer write bespoke durable files. + item/name catalog through `LegacyCatalogBoundary`, but `ActionGameManager` no + longer owns a global legacy cache. Local run saves, loadouts, player settings + files, zone files, and generated keyboard layout caches no longer write + bespoke durable files. - Shared domain state is still partly built around `DatabaseEntry`, GUID identity, MessagePack attributes, and static cache references. Newtonsoft, JsonKnownTypes, RethinkDB, LiteNetLib client transport, and the broken @@ -65,8 +66,8 @@ local CultCache, and legacy UI paths should be migration-only or deleted. ## Current Authority Map - Owner: `Aetheria.State` owns the new typed state spine for durable state. - `DatabaseEntry` plus old `CultCache` still own legacy catalog reads inside the - Unity runtime until catalog migration lands. + `LegacyCatalogBoundary` is the only named owner for old MessagePack catalog + reads inside the Unity runtime until catalog migration lands. - Inputs: Unity gameplay code, legacy catalog files, typed state documents, and CultMesh server state. - Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy @@ -80,9 +81,9 @@ local CultCache, and legacy UI paths should be migration-only or deleted. generated keyboard layout caches, and server-side `DatabaseCache` paths. - Shared paths: manual gameplay edits, editor edits, server updates, file load, file save, and migration all need to converge on one typed commit primitive. -- Deletion line: no new behavior should be added to the old `DatabaseEntry`, - legacy `CultCache`, or MessagePack catalog paths except bounded migration - readers that emit typed `Aetheria.State` documents. +- Deletion line: no new behavior should be added to `LegacyCatalogBoundary`, the + old `DatabaseEntry`, legacy `CultCache`, or MessagePack catalog paths except + bounded migration readers that emit typed `Aetheria.State` documents. ## Target Authority Map