Use typed facets for action bar gear icons

This commit is contained in:
Meta Vens 2026-06-14 00:22:50 +01:00
commit e3ae2ecbeb
3 changed files with 33 additions and 7 deletions

Binary file not shown.

View file

@ -1,4 +1,6 @@
using System;
using System.Linq;
using GameCult.Aetheria.State.Unity;
using TMPro;
using UniRx.Triggers;
using UnityEngine;
@ -99,16 +101,38 @@ public class ActionBarGearBinding : ActionBarBinding
public ActionBarGearBinding(Entity entity, ActionBarSlot slot, EquippedItem item, IActivatedBehavior behavior) : base(entity, slot)
{
Item = item;
var data = entity.ItemManager.GetData(item.EquippableItem);
Behavior = behavior;
Slot.QuantityRemaining.gameObject.SetActive(false);
Slot.Icon.gameObject.SetActive(true);
Slot.Label.gameObject.SetActive(false);
if (!string.IsNullOrEmpty(Item.Data.ActionBarIcon))
Slot.Icon.texture = Resources.Load<Texture2D>(Item.Data.ActionBarIcon.Substring("Assets/Resources/".Length).Split('.').First());
else if (data is WeaponItemData weaponItemData)
Slot.Icon.texture = ActionGameManager.Instance.Settings.GetIcon(weaponItemData.WeaponType).texture;
else Slot.Icon.texture = ActionGameManager.Instance.Settings.GetIcon(data.HardpointType).texture;
else Slot.Icon.texture = ResolveIconTexture();
}
private Texture2D ResolveIconTexture()
{
var typedItem = FindTypedGearItem(Item.EquippableItem);
if (typedItem != null)
{
if (Enum.TryParse<WeaponType>(typedItem.WeaponType, out var weaponType))
return ActionGameManager.Instance.Settings.GetIcon(weaponType).texture;
if (Enum.TryParse<HardpointType>(typedItem.HardpointType, out var hardpointType))
return ActionGameManager.Instance.Settings.GetIcon(hardpointType).texture;
}
return Item.Data is WeaponItemData weaponItemData
? ActionGameManager.Instance.Settings.GetIcon(weaponItemData.WeaponType).texture
: ActionGameManager.Instance.Settings.GetIcon(Item.Data.HardpointType).texture;
}
private static AetheriaRuntimeCatalogItem FindTypedGearItem(ItemInstance item)
{
var itemId = item?.Data?.ItemId ?? Guid.Empty;
return itemId == Guid.Empty
? null
: ActionGameManager.RuntimeCatalog?.FindItemByLegacyId(itemId.ToString("D"));
}
public override void Activate()

View file

@ -80,9 +80,11 @@ legacy catalog cache, and legacy UI paths should be migration-only or deleted.
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. Unity boot reads typed player settings
back through the package-owned CultCache reader before falling back to
defaults.
still required by activation APIs. Gear action-bar bindings use typed weapon
and hardpoint facets for fallback icon selection instead of hydrating item
DTOs to classify the icon; legacy custom action-bar icon paths remain fallback
projection data. Unity boot reads typed player settings back through the
package-owned CultCache reader before falling back to defaults.
- `Aetheria.State` now exposes typed node put/get ports for run state, zone
state, and entity snapshots. The state smoke writes a run referencing a zone,
a zone referencing an entity snapshot, and an entity snapshot carrying