Centralize catalog item object lookup
This commit is contained in:
parent
b32a412df2
commit
0cf4591b8f
11 changed files with 24 additions and 21 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,11 +28,7 @@ public class ItemManager
|
|||
|
||||
public AetheriaRuntimeCatalogItem GetRuntimeItem(ItemInstance item)
|
||||
{
|
||||
return item == null
|
||||
? null
|
||||
: !string.IsNullOrWhiteSpace(item.ItemKey)
|
||||
? _runtimeCatalog.FindItem(item.ItemKey)
|
||||
: null;
|
||||
return _runtimeCatalog.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
|
||||
public Behavior[] CreateRuntimeBehaviors(EquippedItem item)
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ public class SchematicDisplay : MonoBehaviour
|
|||
|
||||
private AetheriaRuntimeCatalogItem FindTypedItem(ItemInstance item)
|
||||
{
|
||||
return ResolveCatalog()?.FindItem(item?.ItemKey ?? "");
|
||||
return ResolveCatalog()?.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
|
||||
|
|
|
|||
|
|
@ -1071,7 +1071,7 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
private AetheriaRuntimeCatalogItem FindTypedInventoryItem(ItemInstance item)
|
||||
{
|
||||
return ResolveCatalog()?.FindItem(item?.ItemKey ?? "");
|
||||
return ResolveCatalog()?.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
|
||||
|
|
|
|||
|
|
@ -1030,7 +1030,7 @@ private void Update()
|
|||
|
||||
private AetheriaRuntimeCatalogItem FindTypedInventoryItem(ItemInstance item)
|
||||
{
|
||||
return ResolveCatalog()?.FindItem(item?.ItemKey ?? "");
|
||||
return ResolveCatalog()?.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
|
||||
private void RequestDockedCurrentShip(Ship ship)
|
||||
|
|
|
|||
|
|
@ -232,10 +232,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
public AetheriaRuntimeCatalogItem FindCatalogItem(ItemInstance item)
|
||||
{
|
||||
if (item == null || string.IsNullOrWhiteSpace(item.ItemKey))
|
||||
return null;
|
||||
|
||||
return ResolveCatalog()?.FindItem(item.ItemKey);
|
||||
return ResolveCatalog()?.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
|
||||
void Start()
|
||||
|
|
@ -1201,7 +1198,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
private AetheriaRuntimeCatalogItem FindTypedZoneItem(ItemInstance item)
|
||||
{
|
||||
return FindCatalogItem(item);
|
||||
return ResolveCatalog()?.FindItem(item, x => x.ItemKey);
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCatalogSnapshot ResolveCatalog()
|
||||
|
|
|
|||
Loading…
Reference in a new issue