Narrow action bar runtime access

This commit is contained in:
Meta Vens 2026-06-29 06:30:24 +01:00
commit cf58dc03c3
5 changed files with 39 additions and 38 deletions

View file

@ -5657,7 +5657,7 @@ static void RequireInventoryEquippedItemDetailsUseEveSurface(string root)
{
"public void ConfigureActionBarPresentation(",
"actionBarPresentation?.Bind(",
"resolveActionBarClient);",
"resolveActionBarControl);",
"Inventory?.SetActionBarPresentation(actionBarPresentation)"
};
var missingActionBarSceneWiringSymbols = requiredActionBarSceneWiringSymbols
@ -7555,7 +7555,8 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root)
{
"public abstract class ActionBarBinding : IDisposable",
"CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog",
"Client.State.Reactive<AetheriaRuntimeCatalogSnapshot>()",
"AetheriaUnityRuntimeClientProvider",
".Reactive<AetheriaRuntimeCatalogSnapshot>(\"unity-action-bar\")",
"_catalog?.Current?.FindItem(item, x => x.ItemKey)",
"binding?.Dispose()",
"private void OnDestroy()"
@ -7571,10 +7572,11 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root)
}
if (actionBarSlot.Contains("AetheriaRuntimeCatalogSession _catalog", StringComparison.Ordinal) ||
actionBarSlot.Contains("Client.State.ObserveCatalog()", StringComparison.Ordinal))
actionBarSlot.Contains("Client.State.ObserveCatalog()", StringComparison.Ordinal) ||
actionBarSlot.Contains("Client.State.Reactive<AetheriaRuntimeCatalogSnapshot>()", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"ActionBarSlot still routes through AetheriaRuntimeCatalogSession instead of its managed reactive typed catalog document.");
"ActionBarSlot still routes through client/session catalog plumbing instead of its managed reactive typed catalog document.");
}
var schematicDisplay = File.ReadAllText(Path.Combine(
@ -17303,7 +17305,7 @@ static void RequireActionBarBindingRequestAuthority(string root)
"public void ConfigureActionBarPresentation(",
"gameplayInputShell?.ActionBarSlots ?? Array.Empty<ActionBarSlot>()",
"actionBarPresentation?.Bind(",
"resolveActionBarClient);"
"resolveActionBarControl);"
};
var missingSceneWiringSymbols = requiredSceneWiringSymbols
.Where(symbol => !gameplaySceneWiring.Contains(symbol, StringComparison.Ordinal))
@ -17502,10 +17504,10 @@ static void RequireActionBarBindingRequestAuthority(string root)
if (actionBarSlot.Contains("ActionGameManager.Instance", StringComparison.Ordinal) ||
!actionBarSlot.Contains("protected GameSettings Settings { get; }", StringComparison.Ordinal) ||
!actionBarPresentation.Contains("new ActionBarGearBinding(entity, slot, client, _settings,", StringComparison.Ordinal))
!actionBarPresentation.Contains("new ActionBarGearBinding(entity, slot, _resolveControl, _settings,", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"ActionBarSlot must receive icon presentation settings explicitly instead of reaching through ActionGameManager.Instance.");
"ActionBarSlot must receive icon presentation settings explicitly and submit through a narrow control handle.");
}
}

View file

@ -55,7 +55,7 @@ public class ActionBarSlot : MonoBehaviour
public abstract class ActionBarBinding : IDisposable
{
public Entity Entity { get; }
protected AetheriaClient Client { get; }
private readonly Func<AetheriaControl> _resolveControl;
protected ActionBarSlot Slot { get; }
protected GameSettings Settings { get; }
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
@ -63,22 +63,30 @@ public abstract class ActionBarBinding : IDisposable
public abstract void Deactivate();
public abstract void Update();
protected ActionBarBinding(Entity entity, ActionBarSlot slot, AetheriaClient client, GameSettings settings)
protected ActionBarBinding(
Entity entity,
ActionBarSlot slot,
Func<AetheriaControl> resolveControl,
GameSettings settings)
{
Entity = entity;
Slot = slot;
Client = client;
_resolveControl = resolveControl ?? (() => null);
Settings = settings;
}
protected bool TrySubmit(Action<AetheriaControl> submit, string label)
{
if (Client == null || submit == null)
if (submit == null)
return false;
try
{
submit(Client.Control);
var control = _resolveControl();
if (control == null)
return false;
submit(control);
return true;
}
catch (Exception ex)
@ -90,12 +98,10 @@ public abstract class ActionBarBinding : IDisposable
protected AetheriaRuntimeCatalogItem FindCatalogItem(ItemInstance item)
{
if (Client == null)
return null;
try
{
_catalog ??= Client.State.Reactive<AetheriaRuntimeCatalogSnapshot>();
_catalog ??= AetheriaUnityRuntimeClientProvider
.Reactive<AetheriaRuntimeCatalogSnapshot>("unity-action-bar");
return _catalog?.Current?.FindItem(item, x => x.ItemKey);
}
catch (Exception ex)
@ -119,9 +125,9 @@ public class ActionBarConsumableBinding : ActionBarBinding
public ActionBarConsumableBinding(
Entity entity,
ActionBarSlot slot,
AetheriaClient client,
Func<AetheriaControl> resolveControl,
GameSettings settings,
AetheriaRuntimeCatalogItem target) : base(entity, slot, client, settings)
AetheriaRuntimeCatalogItem target) : base(entity, slot, resolveControl, settings)
{
Target = target;
Slot.QuantityRemaining.gameObject.SetActive(true);
@ -174,10 +180,10 @@ public class ActionBarGearBinding : ActionBarBinding
public ActionBarGearBinding(
Entity entity,
ActionBarSlot slot,
AetheriaClient client,
Func<AetheriaControl> resolveControl,
GameSettings settings,
EquippedItem item,
IActivatedBehavior behavior) : base(entity, slot, client, settings)
IActivatedBehavior behavior) : base(entity, slot, resolveControl, settings)
{
Item = item;
Behavior = behavior;
@ -249,9 +255,9 @@ public class ActionBarWeaponGroupBinding : ActionBarBinding
public ActionBarWeaponGroupBinding(
Entity entity,
ActionBarSlot slot,
AetheriaClient client,
Func<AetheriaControl> resolveControl,
GameSettings settings,
int group) : base(entity, slot, client, settings)
int group) : base(entity, slot, resolveControl, settings)
{
Group = group;
slot.Label.gameObject.SetActive(true);

View file

@ -293,11 +293,6 @@ public class ActionGameManager : MonoBehaviour
private readonly AetheriaUnityDragSession _dragSession = new AetheriaUnityDragSession();
private readonly AetheriaUnityActionBarPresentation _actionBarPresentation = new AetheriaUnityActionBarPresentation();
private AetheriaClient ResolveActionBarClient()
{
return ResolveCurrentRuntimeClient();
}
private static AetheriaClient ResolveCurrentRuntimeClient()
{
return AetheriaUnityRuntimeClientProvider.CurrentClientForStateFile(
@ -334,7 +329,7 @@ public class ActionGameManager : MonoBehaviour
boot.RuntimeCatalog,
Settings,
() => CurrentEntity,
ResolveActionBarClient);
() => AetheriaUnityRuntimeClientProvider.Control("unity-action-bar"));
SceneWiring.ConfigureRuntimeInputScreenShell(MenuShell);
SceneWiring.ConfigureObservedEntityIndex(_observedEntityIndex);

View file

@ -10,7 +10,7 @@ public sealed class AetheriaUnityActionBarPresentation
private AetheriaRuntimeCatalogSnapshot _catalog;
private GameSettings _settings;
private Func<Entity> _resolveEntity = () => null;
private Func<AetheriaClient> _resolveClient = () => null;
private Func<AetheriaControl> _resolveControl = () => null;
private IReadOnlyList<AetheriaUnityActionBarBinding> _localBindings =
Array.Empty<AetheriaUnityActionBarBinding>();
@ -19,13 +19,13 @@ public sealed class AetheriaUnityActionBarPresentation
AetheriaRuntimeCatalogSnapshot catalog,
GameSettings settings,
Func<Entity> resolveEntity,
Func<AetheriaClient> resolveClient)
Func<AetheriaControl> resolveControl)
{
_slots = slots ?? Array.Empty<ActionBarSlot>();
_catalog = catalog;
_settings = settings;
_resolveEntity = resolveEntity ?? (() => null);
_resolveClient = resolveClient ?? (() => null);
_resolveControl = resolveControl ?? (() => null);
}
public int SlotCount => _slots?.Count ?? 0;
@ -215,15 +215,13 @@ public sealed class AetheriaUnityActionBarPresentation
if (slot == null || entity == null || binding == null)
return null;
var client = _resolveClient();
switch (binding.Kind)
{
case "consumable":
var consumable = _catalog?.FindItem(binding.ItemKey ?? "");
return consumable != null &&
string.Equals(consumable.Category, AetheriaRuntimeItemCategories.Consumable, StringComparison.Ordinal)
? new ActionBarConsumableBinding(entity, slot, client, _settings, consumable)
? new ActionBarConsumableBinding(entity, slot, _resolveControl, _settings, consumable)
: null;
case "gear":
if (binding.EquipmentIndex < 0 || binding.EquipmentIndex >= entity.Equipment.Count)
@ -243,12 +241,12 @@ public sealed class AetheriaUnityActionBarPresentation
if (!(behaviors[binding.BehaviorIndex] is IActivatedBehavior activatedBehavior))
return null;
return new ActionBarGearBinding(entity, slot, client, _settings, equippedItem, activatedBehavior);
return new ActionBarGearBinding(entity, slot, _resolveControl, _settings, equippedItem, activatedBehavior);
case "weapon_group":
return entity.WeaponGroups != null &&
binding.WeaponGroup >= 0 &&
binding.WeaponGroup < entity.WeaponGroups.Length
? new ActionBarWeaponGroupBinding(entity, slot, client, _settings, binding.WeaponGroup)
? new ActionBarWeaponGroupBinding(entity, slot, _resolveControl, _settings, binding.WeaponGroup)
: null;
default:
return null;

View file

@ -120,14 +120,14 @@ public sealed class AetheriaUnityGameplaySceneWiring
AetheriaRuntimeCatalogSnapshot runtimeCatalog,
GameSettings settings,
Func<Entity> resolveCurrentEntity,
Func<AetheriaClient> resolveActionBarClient)
Func<AetheriaControl> resolveActionBarControl)
{
actionBarPresentation?.Bind(
gameplayInputShell?.ActionBarSlots ?? Array.Empty<ActionBarSlot>(),
runtimeCatalog,
settings,
resolveCurrentEntity,
resolveActionBarClient);
resolveActionBarControl);
Inventory?.SetActionBarPresentation(actionBarPresentation);
}