diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index edd5406f3..9f15ebdfd 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -234,7 +234,7 @@ public class ActionGameManager : MonoBehaviour Debug.Log($"Aetheria typed state file: {AetheriaStateFilePath}"); Debug.Log($"Aetheria legacy item catalog: {LegacyAetherDatabasePath}"); ItemManager = new ItemManager( - LegacyCatalogBoundary.GetCatalogCache(GameDataDirectory), + LegacyCatalogBoundary.GetCatalog(GameDataDirectory), Settings.GameplaySettings, Debug.Log); ZoneRenderer.ItemManager = ItemManager; diff --git a/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs b/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs index 4e17620c9..fe809f94d 100644 --- a/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs +++ b/Assets/Scripts/Gameplay/LegacyCatalogBoundary.cs @@ -14,7 +14,7 @@ public static class LegacyCatalogBoundary return Path.Combine(gameDataDirectory.FullName, "AetherDB.msgpack"); } - public static LegacyCatalogCache GetCatalogCache(DirectoryInfo gameDataDirectory) + public static ILegacyCatalogReader GetCatalog(DirectoryInfo gameDataDirectory) { if (_catalogCache != null) return _catalogCache; diff --git a/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs b/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs index e4f06542d..eb82a61f1 100644 --- a/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs +++ b/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs @@ -78,21 +78,21 @@ public class DatabaseLinkBase public Guid LinkID; [IgnoreMember] - private static LegacyCatalogCache CatalogCache { get; set; } + private static ILegacyCatalogReader Catalog { get; set; } protected static T ResolveLegacyCatalog(Guid linkId) where T : DatabaseEntry { - if (CatalogCache == null) + if (Catalog == null) throw new InvalidOperationException("Legacy DatabaseLink resolution is not bound. Open LegacyCatalogBoundary before reading legacy catalog object graphs."); - return CatalogCache.Get(linkId); + return Catalog.Get(linkId); } - public static void BindLegacyCatalog(LegacyCatalogCache cache) + public static void BindLegacyCatalog(ILegacyCatalogReader catalog) { - if (cache == null) throw new ArgumentNullException(nameof(cache)); + if (catalog == null) throw new ArgumentNullException(nameof(catalog)); - CatalogCache = cache; + Catalog = catalog; } } diff --git a/Assets/Scripts/ServerShared/CultCache/LegacyCatalogCache.cs b/Assets/Scripts/ServerShared/CultCache/LegacyCatalogCache.cs index 288644897..f67211dd3 100644 --- a/Assets/Scripts/ServerShared/CultCache/LegacyCatalogCache.cs +++ b/Assets/Scripts/ServerShared/CultCache/LegacyCatalogCache.cs @@ -10,7 +10,14 @@ using System.Reflection; using MessagePack; using UniRx; -public class LegacyCatalogCache +public interface ILegacyCatalogReader +{ + DatabaseEntry Get(Guid guid); + T Get(Guid guid) where T : DatabaseEntry; + IEnumerable GetAll() where T : DatabaseEntry; +} + +public class LegacyCatalogCache : ILegacyCatalogReader { private readonly object addLock = new object(); diff --git a/Assets/Scripts/ServerShared/Galaxy.cs b/Assets/Scripts/ServerShared/Galaxy.cs index 57e3c9799..b697dd53d 100644 --- a/Assets/Scripts/ServerShared/Galaxy.cs +++ b/Assets/Scripts/ServerShared/Galaxy.cs @@ -32,7 +32,7 @@ public class Galaxy private HashSet _containedFactions; private GalaxyZone[] _exitPath; private Dictionary _nameGenerators = new Dictionary(); - private readonly LegacyCatalogCache _cache; + private readonly ILegacyCatalogReader _catalog; public GalaxyZone[] ExitPath { @@ -48,16 +48,16 @@ public class Galaxy SectorGenerationSettings settings, SectorBackgroundSettings background, NameGeneratorSettings nameGeneratorSettings, - LegacyCatalogCache cache, + ILegacyCatalogReader catalog, Action log, Action progressCallback = null, uint seed = 0) { - _cache = cache; + _catalog = catalog; IsPrelude = false; Background = background; Log = log; - var factions = cache.GetAll(); + var factions = catalog.GetAll(); var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed); Factions = factions.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray(); foreach (var f in Factions) FactionRelationships[f] = FactionRelationship.Neutral; @@ -81,7 +81,7 @@ public class Galaxy CalculateFactionInfluence(progressCallback); - GenerateNames(cache, nameGeneratorSettings, ref random, progressCallback); + GenerateNames(catalog, nameGeneratorSettings, ref random, progressCallback); progressCallback?.Invoke("Done!"); if(progressCallback!=null) Thread.Sleep(500); // Inserting Delay to make it seem like it's doing more work lmao @@ -89,21 +89,21 @@ public class Galaxy public Faction ResolveFaction(string name) { - return _cache.GetAll().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); + return _catalog.GetAll().FirstOrDefault(f => f.Name.StartsWith(name, StringComparison.InvariantCultureIgnoreCase)); } public Galaxy( TutorialGenerationSettings settings, SectorBackgroundSettings background, NameGeneratorSettings nameGeneratorSettings, - LegacyCatalogCache cache, + ILegacyCatalogReader catalog, PlayerSettings playerSettings, DirectoryInfo narrativeDirectory, Action log, Action progressCallback = null, uint seed = 0) { - _cache = cache; + _catalog = catalog; IsPrelude = true; Background = background; @@ -189,7 +189,7 @@ public class Galaxy CalculateFactionInfluence(progressCallback); - GenerateNames(cache, nameGeneratorSettings, ref random, progressCallback); + GenerateNames(catalog, nameGeneratorSettings, ref random, progressCallback); // progressCallback?.Invoke("Weaving Narrative"); // var processor = new StoryProcessor(playerSettings, narrativeDirectory, this, ref random, Log); @@ -280,7 +280,7 @@ public class Galaxy } } - private void GenerateNames(LegacyCatalogCache cache, + private void GenerateNames(ILegacyCatalogReader catalog, NameGeneratorSettings nameGeneratorSettings, ref Random random, Action progressCallback = null) @@ -290,7 +290,7 @@ public class Galaxy progressCallback?.Invoke($"Feeding Markov Chains: {i + 1} / {Factions.Length}"); //if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao var faction = Factions[i]; - _nameGenerators[faction] = new MarkovNameGenerator(ref random, cache.Get(faction.GeonameFile).Names, nameGeneratorSettings); + _nameGenerators[faction] = new MarkovNameGenerator(ref random, catalog.Get(faction.GeonameFile).Names, nameGeneratorSettings); } // Generate zone name using the owner's name generator, otherwise assign catalogue ID diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 6721a3c7f..b79d61433 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -31,7 +31,7 @@ public class ItemManager // private Guid _forceLoadZone; // public GlobalData GlobalData => _globalData ?? (_globalData = ItemData.GetAll().FirstOrDefault()); - public LegacyCatalogCache ItemData { get; } + public ILegacyCatalogReader ItemData { get; } public GameplaySettings GameplaySettings { get; } // public double Time @@ -47,7 +47,7 @@ public class ItemManager // private readonly Dictionary Tier = new Dictionary(); - public ItemManager(LegacyCatalogCache itemData, GameplaySettings settings, Action logger) + public ItemManager(ILegacyCatalogReader itemData, GameplaySettings settings, Action logger) { ItemData = itemData; GameplaySettings = settings; diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index 48eff3262..29392bbec 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -117,7 +117,7 @@ public class MainMenu : MonoBehaviour Settings.SectorGenerationSettings, Settings.SectorBackgroundSettings, Settings.NameGeneratorSettings, - LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory), + LegacyCatalogBoundary.GetCatalog(ActionGameManager.GameDataDirectory), Debug.Log, setState); Observable.NextFrame().Subscribe(_ => @@ -143,7 +143,7 @@ public class MainMenu : MonoBehaviour Settings.TutorialGenerationSettings, Settings.TutorialBackgroundSettings, Settings.NameGeneratorSettings, - LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory), + LegacyCatalogBoundary.GetCatalog(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 e5218b57e..0044bfe71 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 = LegacyCatalogBoundary.GetCatalogCache(ActionGameManager.GameDataDirectory).Get(data.Manufacturer); + var manufacturer = LegacyCatalogBoundary.GetCatalog(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 c8d1a7d2a..6db77c5c6 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -32,13 +32,14 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. `GameData/KeyboardLayouts/*.msgpack` authority paths are disabled or deleted. The old `SavedGame`/`SavedZone` DTOs and `Galaxy` save-loader constructor are deleted. -- `LegacyCatalogBoundary` opens `LegacyCatalogCache` as a pull-only catalog - cache. Old MessagePack backing stores may hydrate in-memory domain objects - for the current Unity runtime, but this path cannot push or delete legacy - files. The legacy backing-store write/realtime APIs and public cache mutation - methods have been deleted; only backing-store pull hydration can populate it. - The backing-store serializer methods are also deleted, so the legacy cache - interface exposes deserialization only. +- `LegacyCatalogBoundary` opens `LegacyCatalogCache` as the only concrete + pull-only catalog cache. Runtime consumers receive `ILegacyCatalogReader`, + so old MessagePack backing stores may hydrate in-memory domain objects for + the current Unity runtime, but this path cannot push or delete legacy files. + The legacy backing-store write/realtime APIs and public cache mutation methods + have been deleted; only backing-store pull hydration can populate it. The + backing-store serializer methods are also deleted, so the legacy cache + implementation exposes deserialization only. - `DatabaseLink.Value` can resolve legacy links only after `LegacyCatalogBoundary` binds the pull-only catalog cache. Legacy catalog construction no longer grabs global `DatabaseLinkBase` authority. @@ -93,8 +94,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. - Owner: `Aetheria.State` owns the new typed state spine for durable state. `LegacyCatalogBoundary` is the only named owner for old MessagePack catalog reads and legacy `DatabaseLink` resolution inside the Unity runtime until - catalog migration lands. The legacy cache no longer has a public mutation - surface. + catalog migration lands. Runtime code receives `ILegacyCatalogReader`, not the + concrete cache. The legacy cache no longer has a public mutation surface. - Inputs: Unity gameplay code, legacy catalog files, typed state documents, and CultMesh server state. - Outputs: `Aetheria.State` emits `.cc` state and CultMesh documents. Legacy