Centralize catalog item object lookup

This commit is contained in:
Meta Vens 2026-06-28 12:21:38 +01:00
commit 0cf4591b8f
11 changed files with 24 additions and 21 deletions

View file

@ -90,13 +90,13 @@ public abstract class ActionBarBinding : IDisposable
protected AetheriaRuntimeCatalogItem FindCatalogItem(ItemInstance item)
{
if (item == null || string.IsNullOrWhiteSpace(item.ItemKey) || Client == null)
if (Client == null)
return null;
try
{
_catalog ??= Client.Aetheria().ReactiveCatalog();
return _catalog?.Current?.FindItem(item.ItemKey);
return _catalog?.Current?.FindItem(item, x => x.ItemKey);
}
catch (Exception ex)
{

View file

@ -53,7 +53,7 @@ public sealed class AetheriaUnityActionBarPresentation
{
ActionBarWeaponGroupBinding weaponGroup => $"G{weaponGroup.Group + 1}",
ActionBarConsumableBinding consumable => consumable.Target?.Name ?? "Consumable",
ActionBarGearBinding gear => _catalog?.FindItem(gear.Item?.EquippableItem?.ItemKey ?? "")?.Name ?? "Gear",
ActionBarGearBinding gear => _catalog?.FindItem(gear.Item?.EquippableItem, x => x.ItemKey)?.Name ?? "Gear",
_ => "Empty"
};
}
@ -257,7 +257,7 @@ public sealed class AetheriaUnityActionBarPresentation
private AetheriaRuntimeCatalogItem FindConsumable(ItemInstance item)
{
var typedItem = _catalog?.FindItem(item?.ItemKey ?? "");
var typedItem = _catalog?.FindItem(item, x => x.ItemKey);
return typedItem != null &&
string.Equals(typedItem.Category, AetheriaRuntimeItemCategories.Consumable, StringComparison.Ordinal)
? typedItem

View file

@ -184,7 +184,7 @@ public sealed class AetheriaUnityTargetPresentation
var visibilityToTarget = ResolveInfoGathered?.Invoke(target, currentEntity) ?? 0f;
TargetVisibilityFill.fillAmount = (float)renderSettings.NormalizeTargetVisibilityFill(targetInfoGathered);
VisibilityToTargetFill.fillAmount = (float)renderSettings.NormalizeVisibilityToTargetFill(visibilityToTarget);
var targetHull = RuntimeCatalog?.FindItem(target.Hull?.ItemKey ?? "");
var targetHull = RuntimeCatalog?.FindItem(target.Hull, x => x.ItemKey);
var targetMaxDurability = targetHull?.Durability > 0
? (float)targetHull.Durability
: Math.Max(target.Hull.Durability, 1f);

View file

@ -21,7 +21,7 @@ public static class AetheriaUnityWeaponPresentationPolicy
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
EquippedItem item)
{
var typedItem = runtimeCatalog?.FindItem(item?.EquippableItem?.ItemKey ?? "");
var typedItem = runtimeCatalog?.FindItem(item?.EquippableItem, x => x.ItemKey);
if (typedItem?.BehaviorKinds == null)
return false;