diff --git a/.voidbot/state/aetheria.cc b/.voidbot/state/aetheria.cc index 6ca42983b..6bca45e8d 100644 Binary files a/.voidbot/state/aetheria.cc and b/.voidbot/state/aetheria.cc differ diff --git a/Assets/Scripts/Gameplay/ActionBarSlot.cs b/Assets/Scripts/Gameplay/ActionBarSlot.cs index 8d701df4a..e09d701f8 100644 --- a/Assets/Scripts/Gameplay/ActionBarSlot.cs +++ b/Assets/Scripts/Gameplay/ActionBarSlot.cs @@ -57,25 +57,27 @@ public abstract class ActionBarBinding public class ActionBarConsumableBinding : ActionBarBinding { - public ConsumableItemData Target; + public AetheriaRuntimeCatalogItem Target { get; } + private readonly Func _resolveLegacyTarget; - public ActionBarConsumableBinding(Entity entity, ActionBarSlot slot, ConsumableItemData target) : base(entity, slot) + public ActionBarConsumableBinding( + Entity entity, + ActionBarSlot slot, + AetheriaRuntimeCatalogItem target, + Func resolveLegacyTarget) : base(entity, slot) { Target = target; + _resolveLegacyTarget = resolveLegacyTarget; Slot.QuantityRemaining.gameObject.SetActive(true); - var data = Target; - if(!string.IsNullOrEmpty(data.Icon)) - { - Slot.Label.gameObject.SetActive(false); - Slot.Icon.gameObject.SetActive(true); - Slot.Icon.texture = Resources.Load(data.Icon.Substring("Assets/Resources/".Length).Split('.').First()); - } - else Slot.Icon.gameObject.SetActive(false); + Slot.Label.gameObject.SetActive(false); + Slot.Icon.gameObject.SetActive(false); } public override void Activate() { - Entity.TryActivateConsumable(Target); + var legacyTarget = ResolveLegacyTarget(); + if (legacyTarget != null) + Entity.TryActivateConsumable(legacyTarget); } public override void Deactivate() @@ -84,11 +86,26 @@ public class ActionBarConsumableBinding : ActionBarBinding public override void Update() { - Slot.QuantityRemaining.text = $"{Entity.CountItemsInCargo(Target.ID)}"; - var instance = Entity.FindActiveConsumable(Target); + Slot.QuantityRemaining.text = $"{Entity.CountItemsInCargo(TargetLegacyId)}"; + var legacyTarget = ResolveLegacyTarget(); + if (legacyTarget == null) + { + Slot.Fill.fillAmount = 0; + return; + } + + var instance = Entity.FindActiveConsumable(legacyTarget); if (instance == null) Slot.Fill.fillAmount = 0; else Slot.Fill.fillAmount = instance.RemainingDuration / instance.Data.Duration; } + + private Guid TargetLegacyId => + Guid.TryParse(Target.LegacyId, out var legacyId) ? legacyId : Guid.Empty; + + private ConsumableItemData ResolveLegacyTarget() + { + return _resolveLegacyTarget?.Invoke(); + } } public class ActionBarGearBinding : ActionBarBinding diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index c11452367..5fa47466e 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -729,9 +729,13 @@ public class ActionGameManager : MonoBehaviour slot.Binding = new ActionBarGearBinding(CurrentEntity, slot, equippedItemDragAction.EquippedItem, trigger); return true; case ItemInstanceDragObject itemInstanceDragAction: - if (!IsRuntimeConsumableItem(itemInstanceDragAction.Item)) return false; - if (!(ItemManager.GetData(itemInstanceDragAction.Item) is ConsumableItemData consumable)) return false; - slot.Binding = new ActionBarConsumableBinding(CurrentEntity, slot, consumable); + var consumable = FindTypedActionBarConsumable(itemInstanceDragAction.Item); + if (consumable == null) return false; + slot.Binding = new ActionBarConsumableBinding( + CurrentEntity, + slot, + consumable, + () => ItemManager.GetData(itemInstanceDragAction.Item) as ConsumableItemData); return true; case WeaponGroupDragObject weaponGroupDragAction: slot.Binding = new ActionBarWeaponGroupBinding(CurrentEntity, slot, weaponGroupDragAction.Group); @@ -749,11 +753,13 @@ public class ActionGameManager : MonoBehaviour return slot; } - bool IsRuntimeConsumableItem(ItemInstance item) + AetheriaRuntimeCatalogItem FindTypedActionBarConsumable(ItemInstance item) { var typedItem = FindTypedActionBarItem(item); return typedItem != null && - string.Equals(typedItem.Category, nameof(ConsumableItemData), StringComparison.Ordinal); + string.Equals(typedItem.Category, nameof(ConsumableItemData), StringComparison.Ordinal) + ? typedItem + : null; } AetheriaRuntimeCatalogItem FindTypedActionBarItem(ItemInstance item) diff --git a/docs/aetheria-perfect-machine-map.md b/docs/aetheria-perfect-machine-map.md index f7be28e29..fbee86845 100644 --- a/docs/aetheria-perfect-machine-map.md +++ b/docs/aetheria-perfect-machine-map.md @@ -79,9 +79,13 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted. the durable owner. Binding drag/drop and action-bar remapping both queue the same typed player-settings commit after mutating the runtime projection. The action bar also uses typed runtime catalog category rows to reject - non-consumable inventory drops before hydrating the legacy consumable DTO - still required by activation APIs. Missing typed rows are rejected for - consumable binding instead of falling through to legacy DTO classification. + non-consumable inventory drops and creates consumable bindings around typed + catalog rows before hydrating any legacy DTO. Missing typed rows are rejected + for consumable binding instead of falling through to legacy DTO classification. + Consumable activation and active-duration fill still resolve legacy + `ConsumableItemData` lazily because runtime effects and duration are not typed + execution surfaces yet; consumable icon projection is hidden until typed icon + fields exist. Gear action-bar bindings use typed weapon and hardpoint facets for fallback icon selection and fall back to a generic tool icon when typed facets are incomplete; legacy custom action-bar icon paths remain fallback projection @@ -622,6 +626,9 @@ First Aetheria surfaces to publish: `TradeRow` fields; legacy `ItemData` hydration is lazy and bounded to commodity subtype detail, behavior reflection columns, missing typed rows, and buy mechanics. + - Done: move action-bar consumable drop binding onto typed catalog rows; + legacy `ConsumableItemData` resolution is lazy and bounded to activation + and active-duration fill until typed consumable effect execution exists. - Done: delete the console `give` command instead of preserving a debug operator path that hydrated typed item rows back into legacy item DTOs. - Done: delete `ItemManager.GetCatalogEntries` after all live callers