From fabbd088e2f61bca78e3075a5c0697cecf3b3ab9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 13 Jun 2026 10:49:29 +0100 Subject: [PATCH] Hide legacy catalog reader behind ItemManager --- .voidbot/state/aetheria.cc | Bin 23990 -> 24688 bytes Assets/Scripts/Gameplay/ActionGameManager.cs | 2 +- .../Scripts/ServerShared/EntitySerializer.cs | 2 +- Assets/Scripts/ServerShared/ItemManager.cs | 16 ++++++++++--- .../Scripts/ServerShared/LoadoutGenerator.cs | 6 ++--- Assets/Scripts/UI/Menu/TradeMenuDebug.cs | 2 +- .../UI/Properties Panel/PropertiesPanel.cs | 2 +- docs/aetheria-perfect-machine-map.md | 21 ++++++++++++------ 8 files changed, 34 insertions(+), 17 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 8de3ab32db87ae27e7f168a01d6843e5a36f8612..24c46fd7bbd3f8817cd1e79b26e7c4268badf5b6 100644 GIT binary patch delta 1552 zcmZWp&ubl36gEGwO=({VCe_wRZ%fjO9i}fYZGKcKgtYG&nv|r8VCzC|?wmJoaOU3W zy?4@%n}9BLcXzG~D#afQtJnMU7QA4s!ISoM)E-;tdFL;;=1&Y|eHxQOkMQ8~`VhAbAi3A#e^vOKak>D+C zrov%@D-i=>B1y0}<&m3QM>=2Ivfang=U734(n5kqmIMt%rdz;4QVbCVF%*y(c{ags?x_ z_$Lqvjd;bJ|40K@IMnXH>&PFcQeu%_rcxm_Q98o10k#`bjbv%zIF7gm$+4x}b=;yc zeVCWeDPxdoe2l;ch%EZx$RY_H6+RQn#w=`bAY^Ae76%N60(SR)4)V z(LH}Lc)i(NrYRyZAp(_wWvyHXDigOrWxnr&iXgikGd4Ze9q?<%j(qu@g!b-b zv*V4JbmYXKo!;Dqd@?H@9?iw_$Lnu z+N@5WetV`2?u)z7ZH68*e~*uzED;Z5nc++CF3vjhRE{YU(LEyGM9ra@?P8G_DYCHB zD^mX#*o-XA;OITmJvV!)He9s(SccasZ<~K^USJ>JM(;%+wvZp=0AeXnVV+8ghF)7-9GU-UwIahnO`weN+|xc?>$gH&taqX8ue z1YaeWDgSQWB8zGuHiq zs(_;+xvZuI8v4sBlpg8`xHTjy#T`r1a3#O}S@gL9_bDkNK-k!i%snl_zRkvRA;6D3 zjn;|F1?5as`JwavK)~(P`{~U3X=FYPKtFwU5g}mB*?w0G&~Mbqa*7^=a9@)d)n~>p-yKe zBOS7AUb~D6HKXDyl+0Ipfhy+5k)C=}pLeW)@vnPlW|Em;B&|llpE~7@_U0W(ZlXYO zY17v<)!Z~DqmXh;ycCXH{B!hd{o`Oq`|;Pb$~}^dvZqefpHE)uh`+3yh&xLCo!M%R zjjX)1SanP;)Nhsc3iX-Uj<(kPF8 { var itemName = string.Join(" ", args); - var item = ItemManager.ItemData.GetAll() + var item = ItemManager.GetCatalogEntries() .FirstOrDefault(itemData => string.Equals(itemData.Name, itemName, StringComparison.InvariantCultureIgnoreCase)); if (item != null) { diff --git a/Assets/Scripts/ServerShared/EntitySerializer.cs b/Assets/Scripts/ServerShared/EntitySerializer.cs index bf3db2a7f..2401da934 100644 --- a/Assets/Scripts/ServerShared/EntitySerializer.cs +++ b/Assets/Scripts/ServerShared/EntitySerializer.cs @@ -90,7 +90,7 @@ public static class EntitySerializer private static void Restore(ItemManager itemManager, Zone zone, EntityPack pack, Entity entity, bool instantiate = false) { entity.Name = pack.Name; - entity.Faction = itemManager.ItemData.Get(pack.Faction); + entity.Faction = itemManager.GetCatalogEntry(pack.Faction); entity.Children = pack.Children.Select(c => { var child = Unpack(itemManager, zone, c, instantiate); diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index b79d61433..9533506a5 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -30,8 +30,8 @@ public class ItemManager // private Guid _forceLoadZone; - // public GlobalData GlobalData => _globalData ?? (_globalData = ItemData.GetAll().FirstOrDefault()); - public ILegacyCatalogReader ItemData { get; } + // public GlobalData GlobalData => _globalData ?? (_globalData = GetCatalogEntries().FirstOrDefault()); + private readonly ILegacyCatalogReader _itemData; public GameplaySettings GameplaySettings { get; } // public double Time @@ -49,11 +49,21 @@ public class ItemManager public ItemManager(ILegacyCatalogReader itemData, GameplaySettings settings, Action logger) { - ItemData = itemData; + _itemData = itemData; GameplaySettings = settings; _logger = logger; } + public T GetCatalogEntry(Guid id) where T : DatabaseEntry + { + return _itemData.Get(id); + } + + public IEnumerable GetCatalogEntries() where T : DatabaseEntry + { + return _itemData.GetAll(); + } + public void Log(string s) { _logger(s); diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index cab72975c..667cf6426 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -127,7 +127,7 @@ public class LoadoutGenerator public T[] RandomItems(int count, float sizeExponent, Predicate filter = null) where T : EquippableItemData { - return ItemManager.ItemData.GetAll() + return ItemManager.GetCatalogEntries() .Where(item => item.Price > 0 && item.Manufacturer != Guid.Empty && @@ -137,7 +137,7 @@ public class LoadoutGenerator .WeightedRandomElements(ref Random, item => Faction == null ? 1 : (item.Manufacturer == Faction.ID ? 1 : Faction.Allegiance.ContainsKey(item.Manufacturer) ? Faction.Allegiance[item.Manufacturer] : 0.0f / // Prioritize items from allied manufacturers - (Galaxy?.ContainsFaction(item.Manufacturer) ?? false ? Zone?.Distance[Galaxy.HomeZones[ItemManager.ItemData.Get(item.Manufacturer)]] ?? 1 : 1)) * // Penalize distance to manufacturer headquarters + (Galaxy?.ContainsFaction(item.Manufacturer) ?? false ? Zone?.Distance[Galaxy.HomeZones[ItemManager.GetCatalogEntry(item.Manufacturer)]] ?? 1 : 1)) * // Penalize distance to manufacturer headquarters pow(item.Shape.Coordinates.Length, sizeExponent) / // Prioritize larger items pow(item.Price, PriceExponent), // Penalize item price to a controllable degree count @@ -243,4 +243,4 @@ public class InvalidLoadoutException : Exception : base(message, inner) { } -} \ No newline at end of file +} diff --git a/Assets/Scripts/UI/Menu/TradeMenuDebug.cs b/Assets/Scripts/UI/Menu/TradeMenuDebug.cs index f6d60355d..e5a07d57d 100644 --- a/Assets/Scripts/UI/Menu/TradeMenuDebug.cs +++ b/Assets/Scripts/UI/Menu/TradeMenuDebug.cs @@ -205,7 +205,7 @@ public class TradeMenuDebug : MonoBehaviour data => () => $"{data.Shape.Width}x{data.Shape.Height}", data => data.Shape.Width*data.Shape.Height)); - var items = GameManager.ItemManager.ItemData.GetAll().Where(i=>i.Price!=0); + var items = GameManager.ItemManager.GetCatalogEntries().Where(i=>i.Price!=0); if (MinimumSizeFilter.gameObject.activeSelf) items = items.Where(i => diff --git a/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs b/Assets/Scripts/UI/Properties Panel/PropertiesPanel.cs index 02f7a33e5..44b516de8 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 = GameManager.ItemManager.ItemData.Get(data.Manufacturer); + var manufacturer = GameManager.ItemManager.GetCatalogEntry(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 0aa174eba..b16929714 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -71,6 +71,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. methods are also deleted, so the legacy cache implementation exposes deserialization only. UI code no longer reaches into `LegacyCatalogBoundary.GetCatalog` directly. +- `ItemManager` no longer exposes the raw `ILegacyCatalogReader` as public + gameplay/UI API. Item, faction, loadout, trade, and entity restore consumers + now go through narrow `ItemManager.GetCatalogEntry` and + `GetCatalogEntries` methods. This does not remove the legacy reader under + the hood; it prevents old catalog authority from leaking into every caller + that only needs a domain lookup. - `DatabaseLink.Value` can resolve legacy links only after `LegacyCatalogBoundary` binds the pull-only catalog cache. Legacy catalog construction no longer grabs global `DatabaseLinkBase` authority. @@ -176,11 +182,12 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. `ActionGameManager.LegacyCatalog` is the only Unity runtime access point for old MessagePack catalog reads, and `LegacyCatalogBoundary` is the only named owner for opening the old catalog and binding legacy `DatabaseLink` - resolution until catalog migration lands. Runtime code receives - `ILegacyCatalogReader`, not the concrete cache. `Aetheria.State.Unity` owns a - read-only typed catalog facade for future Unity consumers; it does not write - state or own simulation. The legacy cache no longer has a public mutation - surface. + resolution until catalog migration lands. Runtime code receives narrow + `ItemManager` catalog methods where gameplay only needs lookups; `ItemManager` + and `Galaxy` still receive `ILegacyCatalogReader` until typed runtime catalog + boot replaces them. `Aetheria.State.Unity` owns a read-only typed catalog + facade for future Unity consumers; it does not write state or own simulation. + 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 @@ -221,8 +228,8 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. - Shared paths: gameplay input, editor edits, import/deep-load, replication, simulation ticks, and tests all call the same typed state service. - Deletion line: after catalog migration smokes pass, replace - `ActionGameManager.LegacyCatalog`/`ItemManager` boot with the typed runtime - catalog package, then delete or quarantine the remaining + `ActionGameManager.LegacyCatalog`/`ItemManager`/`Galaxy` boot with the typed + runtime catalog package, then delete or quarantine the remaining `LegacyCatalogCache`/`DatabaseEntry` runtime catalog dependency and remove old MessagePack backing store classes from live Unity source.