From ffe9d6d7bf12fbdda33880482476f4221fbbbccf Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 15 Jun 2026 01:31:16 +0100 Subject: [PATCH] Make runtime item catalog key-only --- .voidbot/state/aetheria.cc | Bin 92944 -> 93601 bytes Aetheria.State/README.md | 4 +++ .../AetheriaRuntimeItemCatalog.cs | 23 ++----------- .../AetheriaRuntimeItemReference.cs | 5 --- Assets/Scripts/ServerShared/Entity.cs | 11 +----- Assets/Scripts/ServerShared/ItemManager.cs | 32 +++--------------- docs/aetheria-perfect-machine-map.md | 8 ++++- 7 files changed, 20 insertions(+), 63 deletions(-) diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 04673968ee5a67f24ce88a927a210da3368da7e9..16fea513c11a46fad27fcfd2b81cdf4609f72a39 100644 GIT binary patch delta 1794 zcmZ`)-)me&6m}9*lYmH5O$d>49yB(vyUpgu(!^?Qeh^}kYSKg@D(&Rn+1)Ys-npHb zn`BEQL_q{!jQ8O_`5;>RBv=+nAH>oJABtex7ok_!u8z{hX zm4U+g%x&VBS(%*z9=L2P2M5w;BJK`ANOd&_rrrV#XoblX)a+D0l&R;fQD;2|lh}o3 zORUT!3mkUBrsjYKF2r}&kHxot>DWmR!4U!CiX1H@Y+^XL%ww9l1<0UhJei7I1h$6B ziF~@|F~b{XNWPJN-Jl+K@oKq1 zMcRZTgJ_gMfK}4vj^@WjfL1b;*t67OKqFlh5>w+#Up~J4`;@>Wjif15f*q=T4lYhFJC+A-yWBYHnlk1Ppz4Hl@ckhy{9BQcTL;bXUsGYVOZaSJRj-kP! zQhuqCY+|{NcB~$znHox+{A^iesyvYFbf0KD4&~UN@O& zYv<@-bLIZ6J~A-b(Tt1lwDvZhqOno)6eYtK$c^Sv`d*3FBT3IiBC=zo&_-UlNOqe? QHhF)VlA9gPv$55G0AF;2UH||9 delta 1466 zcmZux&u<$=6lN1bnv_VifkH0mA%2LW*s0q%Q79Zp8cal6xusRrL`2N)K6|I0-Pz8} z+BFi&AJ9wC9`=kxX>U|AC>0kGBZLpAtoSQXnHmxA;7idL+K-Ugk7}jpx;E&6IPDb>);}FLs&$l zW2THQL!EgoMkQ{-g`XQlCx*^L*`lc?W2QC9Z&{dtYw!}2Ui|Xuja$bgMA8s7ZEVkC zh?49?RK4r`j*z8YA#;uMSWwTPP!f!lk|;IN0QX66>nxna&i@6{M{ki^B{k?kCdAuD zX~%#h5~#_!OR?Y{H=+y70E3V>$r>AAS0<6qRPVyQc>KlMa=)%0MHd4`*4rq=G5JUX zWq+(WQ+p{B@&bCcLpn2GUtd4LVw&EQ$|qHbxtwA7X~|`3#wbQUaPqli*T>4Dbim_W z;axiiXg1kEmm*zkS^CX`we#msCnQ8@{WQ#4u4pNU6KO6*o7^e3$D-IJrO42JwGb)) z0-Mb1Lf%$L*-8jmLxTz7lHut`=T7y$`uWEG6DMsleao@b;7XI9eaO7&VAY|+O)%KS ze>eAJNI~Q-7u=-Rn=faZZ#(0?-~ar3*g4Ys<>ADn>(=uKO;ZXzk@z;nZr5N*U>gN2 zCBiH*S~|dpzGaL=lpdknDVw?&qx?=0OFQ9mn-r1s^3eYcPG)D9_c^a+o1@OY^zNgP z^yZ^ivhUt^4m?>dkaP0csR?H?8(nt}Y~9)8+?dF2J?Ff!zjz+2)%n#=4QuKLkFl+% zrkur*t+nT!SC_^H$LZbSsr)USEzd5@*|#*i&77|XKP~j1*C(=Tt|Rk%v*qfcxePof U8+` abstraction, `ItemManager.GetData` hydration path, vague `ItemInstance.Data` identity field, and old `RuntimeItemReference.Projection` cache have been deleted; runtime item facts diff --git a/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs b/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs index 2b3754f23..69d0e8042 100644 --- a/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs +++ b/Assets/Scripts/ServerShared/AetheriaRuntimeItemCatalog.cs @@ -6,7 +6,6 @@ using GameCult.Aetheria.State.Unity; public interface IRuntimeItemCatalogReader { AetheriaRuntimeCatalogItem GetRuntimeItem(string itemKey); - AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid); } public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader @@ -15,19 +14,14 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader private const string LegacyItemDefinitionPrefix = "aetheria.item_definition:legacy:"; private readonly Dictionary _typedItemsByKey; - private readonly Dictionary _typedItemsByLegacyId; public AetheriaRuntimeItemCatalog(AetheriaRuntimeCatalogSnapshot catalog) { if (catalog == null) throw new ArgumentNullException(nameof(catalog)); _typedItemsByKey = catalog.Items - .Where(item => !string.IsNullOrWhiteSpace(item.LegacyId)) - .ToDictionary(item => ToItemKey(item.LegacyId), item => item, StringComparer.OrdinalIgnoreCase); - - _typedItemsByLegacyId = catalog.Items - .Where(item => Guid.TryParse(item.LegacyId, out _)) - .ToDictionary(item => Guid.Parse(item.LegacyId), item => item); + .Where(item => !string.IsNullOrWhiteSpace(item.ItemKey)) + .ToDictionary(item => item.ItemKey, item => item, StringComparer.OrdinalIgnoreCase); } public AetheriaRuntimeCatalogItem GetRuntimeItem(string itemKey) @@ -39,21 +33,10 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader return item; return Guid.TryParse(RemoveItemPrefix(itemKey), out var legacyId) - ? GetRuntimeItem(legacyId) + ? GetRuntimeItem(AetheriaRuntimeItemReference.FromLegacyId(legacyId)) : null; } - public AetheriaRuntimeCatalogItem GetRuntimeItem(Guid guid) - { - _typedItemsByLegacyId.TryGetValue(guid, out var item); - return item; - } - - private static string ToItemKey(string legacyId) - { - return string.IsNullOrWhiteSpace(legacyId) ? "" : $"{LegacyItemDefinitionPrefix}{legacyId}"; - } - private static string RemoveItemPrefix(string itemKey) { if (itemKey.StartsWith(LegacyItemDefinitionPrefix, StringComparison.OrdinalIgnoreCase)) diff --git a/Assets/Scripts/ServerShared/AetheriaRuntimeItemReference.cs b/Assets/Scripts/ServerShared/AetheriaRuntimeItemReference.cs index df6c7d949..1e6eccf4a 100644 --- a/Assets/Scripts/ServerShared/AetheriaRuntimeItemReference.cs +++ b/Assets/Scripts/ServerShared/AetheriaRuntimeItemReference.cs @@ -26,11 +26,6 @@ public class AetheriaRuntimeItemReference ItemKey = itemKey; } - public AetheriaRuntimeItemReference(Guid legacyItemId) - : this(FromLegacyId(legacyItemId)) - { - } - public Guid LegacyItemId => TryParseLegacyId(ItemKey, out var itemId) ? itemId : Guid.Empty; public static string FromLegacyId(Guid legacyItemId) diff --git a/Assets/Scripts/ServerShared/Entity.cs b/Assets/Scripts/ServerShared/Entity.cs index d8b159b6e..75b6afd84 100644 --- a/Assets/Scripts/ServerShared/Entity.cs +++ b/Assets/Scripts/ServerShared/Entity.cs @@ -347,16 +347,7 @@ public abstract class Entity private static string GetItemKey(AetheriaRuntimeCatalogItem item) { - return GetLegacyGuid(item) is var itemId && itemId != Guid.Empty - ? AetheriaRuntimeItemReference.FromLegacyId(itemId) - : ""; - } - - private static Guid GetLegacyGuid(AetheriaRuntimeCatalogItem item) - { - return item != null && Guid.TryParse(item.LegacyId, out var legacyId) - ? legacyId - : Guid.Empty; + return item?.ItemKey ?? ""; } private void MapEntity() diff --git a/Assets/Scripts/ServerShared/ItemManager.cs b/Assets/Scripts/ServerShared/ItemManager.cs index 41aa13052..fdbffa6c8 100644 --- a/Assets/Scripts/ServerShared/ItemManager.cs +++ b/Assets/Scripts/ServerShared/ItemManager.cs @@ -56,12 +56,7 @@ public class ItemManager ? null : !string.IsNullOrWhiteSpace(item.ItemKey) ? _runtimeItems.GetRuntimeItem(item.ItemKey) - : GetRuntimeItem(item.ItemId); - } - - public AetheriaRuntimeCatalogItem GetRuntimeItem(Guid itemId) - { - return itemId == Guid.Empty ? null : _runtimeItems.GetRuntimeItem(itemId); + : null; } public Behavior[] CreateRuntimeBehaviors(EquippedItem item) @@ -548,16 +543,9 @@ public class ItemManager return new AetheriaRuntimeItemReference(ToItemKey(item)); } - public AetheriaRuntimeItemReference CreateReference(Guid itemId) - { - return new AetheriaRuntimeItemReference(itemId); - } - private static string ToItemKey(AetheriaRuntimeCatalogItem item) { - return item != null && Guid.TryParse(item.LegacyId, out var itemId) - ? AetheriaRuntimeItemReference.FromLegacyId(itemId) - : ""; + return item?.ItemKey ?? ""; } public void Log(string s) @@ -646,8 +634,7 @@ public class ItemManager public SimpleCommodity CreateSimpleCommodityInstance(AetheriaRuntimeCatalogItem item, int count) { - var itemId = GetLegacyGuid(item); - if (itemId != Guid.Empty) + if (!string.IsNullOrWhiteSpace(item?.ItemKey)) { return new SimpleCommodity { @@ -687,8 +674,7 @@ public class ItemManager if (IsEquippable(item)) return CreateEquippableInstance(item, quality); - var itemId = GetLegacyGuid(item); - if (itemId == Guid.Empty) + if (string.IsNullOrWhiteSpace(item?.ItemKey)) { throw new NullReferenceException("Attempted to create crafted item instance using missing typed item data!"); } @@ -716,8 +702,7 @@ public class ItemManager public EquippableItem CreateEquippableInstance(AetheriaRuntimeCatalogItem item, float quality) { - var itemId = GetLegacyGuid(item); - if (itemId == Guid.Empty) + if (string.IsNullOrWhiteSpace(item?.ItemKey)) { throw new NullReferenceException("Attempted to create equippable item instance using missing typed item data!"); } @@ -748,13 +733,6 @@ public class ItemManager return tier.Quality; } - private static Guid GetLegacyGuid(AetheriaRuntimeCatalogItem item) - { - return item != null && Guid.TryParse(item.LegacyId, out var itemId) - ? itemId - : Guid.Empty; - } - private static bool IsEquippable(AetheriaRuntimeCatalogItem item) { return !string.IsNullOrWhiteSpace(item?.HardpointType) || diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index abaee19fd..6055ec893 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -634,7 +634,9 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. ID fields demoted to compatibility. The package runtime catalog snapshot now indexes items by canonical item key, and Unity gameplay/UI/zone helper lookups resolve `ItemKey` directly rather than deriving legacy GUIDs for - `FindItemByLegacyId`; + `FindItemByLegacyId`. The shared runtime item catalog reader no longer has a + GUID index or `GetRuntimeItem(Guid)` entry point; item-key strings are the + only lookup authority; there is no remaining `ItemInstance.Data` identity/backing field. The reader interface for this bridge is named `IRuntimeItemCatalogReader` and exposes only typed catalog row lookup. Behavior @@ -1352,6 +1354,10 @@ First Aetheria surfaces to publish: - Done: move server-shared weapon grouping, generated loadout previous-item reuse, and hauling task item target identity off derived item GUIDs and onto typed `ItemKey` strings. + - Done: delete the shared runtime item catalog GUID index, `GetRuntimeItem(Guid)` + reader path, `ItemManager` item-ID fallback, and unused + `AetheriaRuntimeItemReference(Guid)` constructor. Runtime item lookup is + item-key-only outside explicit compatibility projection helpers. - Done: delete the dead `ItemManager.GetRuntimeItemProjection` bridge after loadout generation stopped hydrating selected typed rows into `EquippableItemData` merely to instantiate equipment.