diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 04673968e..16fea513c 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Aetheria.State/README.md b/Aetheria.State/README.md index 6f23f55a8..622325cb4 100644 --- a/Aetheria.State/README.md +++ b/Aetheria.State/README.md @@ -94,6 +94,10 @@ only; the commit applier prefers typed keys whenever present. The package runtime catalog snapshot indexes items by canonical item key; Unity gameplay, HUD, inventory, trade, ship, and zone helper lookups use `ItemKey` directly instead of deriving `ItemId` and searching by legacy GUID. +The shared runtime item catalog reader is also item-key-only now: its GUID index, +`GetRuntimeItem(Guid)` entry point, and `AetheriaRuntimeItemReference(Guid)` +constructor have been deleted. Legacy GUID helpers remain only as explicit +compatibility projections. The old generic `RuntimeCatalogLink` 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.