Make runtime item catalog key-only
This commit is contained in:
parent
eac886d783
commit
c2f5d04e91
5 changed files with 9 additions and 45 deletions
Binary file not shown.
|
|
@ -100,9 +100,10 @@ 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.
|
||||
`GetRuntimeItem(Guid)` entry point, raw GUID string fallback,
|
||||
`AetheriaRuntimeItemReference(Guid)` constructor, and reverse legacy-GUID
|
||||
projections have been deleted. `FromLegacyId` remains only as an explicit
|
||||
migration/projection helper.
|
||||
The old generic `RuntimeCatalogLink<T>` abstraction, `ItemManager.GetData`
|
||||
hydration path, vague `ItemInstance.Data` identity field, and old
|
||||
`RuntimeItemReference.Projection` cache have been deleted; runtime item facts
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Unity;
|
||||
|
|
@ -10,9 +9,6 @@ public interface IRuntimeItemCatalogReader
|
|||
|
||||
public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
|
||||
{
|
||||
private const string ItemDefinitionPrefix = "aetheria.item_definition:";
|
||||
private const string LegacyItemDefinitionPrefix = "aetheria.item_definition:legacy:";
|
||||
|
||||
private readonly Dictionary<string, AetheriaRuntimeCatalogItem> _typedItemsByKey;
|
||||
|
||||
public AetheriaRuntimeItemCatalog(AetheriaRuntimeCatalogSnapshot catalog)
|
||||
|
|
@ -29,21 +25,8 @@ public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
|
|||
if (string.IsNullOrWhiteSpace(itemKey))
|
||||
return null;
|
||||
|
||||
if (_typedItemsByKey.TryGetValue(itemKey, out var item))
|
||||
return item;
|
||||
|
||||
return Guid.TryParse(RemoveItemPrefix(itemKey), out var legacyId)
|
||||
? GetRuntimeItem(AetheriaRuntimeItemReference.FromLegacyId(legacyId))
|
||||
return _typedItemsByKey.TryGetValue(itemKey, out var item)
|
||||
? item
|
||||
: null;
|
||||
}
|
||||
|
||||
private static string RemoveItemPrefix(string itemKey)
|
||||
{
|
||||
if (itemKey.StartsWith(LegacyItemDefinitionPrefix, StringComparison.OrdinalIgnoreCase))
|
||||
return itemKey.Substring(LegacyItemDefinitionPrefix.Length);
|
||||
|
||||
return itemKey.StartsWith(ItemDefinitionPrefix, StringComparison.OrdinalIgnoreCase)
|
||||
? itemKey.Substring(ItemDefinitionPrefix.Length)
|
||||
: itemKey;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ public interface INamedEntry
|
|||
|
||||
public class AetheriaRuntimeItemReference
|
||||
{
|
||||
private const string ItemDefinitionPrefix = "aetheria.item_definition:";
|
||||
private const string LegacyItemDefinitionPrefix = "aetheria.item_definition:legacy:";
|
||||
|
||||
public string ItemKey;
|
||||
|
|
@ -26,32 +25,10 @@ public class AetheriaRuntimeItemReference
|
|||
ItemKey = itemKey;
|
||||
}
|
||||
|
||||
public Guid LegacyItemId => TryParseLegacyId(ItemKey, out var itemId) ? itemId : Guid.Empty;
|
||||
|
||||
public static string FromLegacyId(Guid legacyItemId)
|
||||
{
|
||||
return legacyItemId == Guid.Empty ? "" : $"{LegacyItemDefinitionPrefix}{legacyItemId:D}";
|
||||
}
|
||||
|
||||
public static Guid ToLegacyId(string itemKey)
|
||||
{
|
||||
return TryParseLegacyId(itemKey, out var itemId) ? itemId : Guid.Empty;
|
||||
}
|
||||
|
||||
private static bool TryParseLegacyId(string itemKey, out Guid itemId)
|
||||
{
|
||||
itemId = Guid.Empty;
|
||||
if (string.IsNullOrWhiteSpace(itemKey))
|
||||
return false;
|
||||
|
||||
var legacyId = itemKey.StartsWith(LegacyItemDefinitionPrefix, StringComparison.OrdinalIgnoreCase)
|
||||
? itemKey.Substring(LegacyItemDefinitionPrefix.Length)
|
||||
: itemKey.StartsWith(ItemDefinitionPrefix, StringComparison.OrdinalIgnoreCase)
|
||||
? itemKey.Substring(ItemDefinitionPrefix.Length)
|
||||
: itemKey;
|
||||
|
||||
return Guid.TryParse(legacyId, out itemId);
|
||||
}
|
||||
}
|
||||
|
||||
public interface ITintInspector
|
||||
|
|
|
|||
|
|
@ -1232,6 +1232,9 @@ First Aetheria surfaces to publish:
|
|||
- Done: delete `Entity`/`EquippedCargoBay` cargo and consumable GUID lookup
|
||||
overloads; transfer, count, active-consumable, and first-item APIs now
|
||||
expose item-key contracts only.
|
||||
- Done: delete the runtime catalog raw-GUID string fallback and unused
|
||||
reverse legacy-GUID projections from `AetheriaRuntimeItemReference`; catalog
|
||||
lookup accepts canonical item keys only.
|
||||
- Remove runtime dependency on `ItemData` DTOs as item instance owners.
|
||||
|
||||
5. Mesh host
|
||||
|
|
|
|||
Loading…
Reference in a new issue