From cf58dc03c32fdf3517aee8244059cf35f5ad666f Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 06:30:24 +0100 Subject: [PATCH] Narrow action bar runtime access --- Aetheria.State.Verify/Program.cs | 16 +++++---- Assets/Scripts/Gameplay/ActionBarSlot.cs | 36 +++++++++++-------- Assets/Scripts/Gameplay/ActionGameManager.cs | 7 +--- .../AetheriaUnityActionBarPresentation.cs | 14 ++++---- .../AetheriaUnityGameplaySceneWiring.cs | 4 +-- 5 files changed, 39 insertions(+), 38 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 316a6963b..1c9a1a68a 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -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 _catalog", - "Client.State.Reactive()", + "AetheriaUnityRuntimeClientProvider", + ".Reactive(\"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()", 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()", "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."); } } diff --git a/Assets/Scripts/Gameplay/ActionBarSlot.cs b/Assets/Scripts/Gameplay/ActionBarSlot.cs index 8519e921e..a7b9bc90e 100644 --- a/Assets/Scripts/Gameplay/ActionBarSlot.cs +++ b/Assets/Scripts/Gameplay/ActionBarSlot.cs @@ -55,7 +55,7 @@ public class ActionBarSlot : MonoBehaviour public abstract class ActionBarBinding : IDisposable { public Entity Entity { get; } - protected AetheriaClient Client { get; } + private readonly Func _resolveControl; protected ActionBarSlot Slot { get; } protected GameSettings Settings { get; } private CultMeshReactiveDocument _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 resolveControl, + GameSettings settings) { Entity = entity; Slot = slot; - Client = client; + _resolveControl = resolveControl ?? (() => null); Settings = settings; } protected bool TrySubmit(Action 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(); + _catalog ??= AetheriaUnityRuntimeClientProvider + .Reactive("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 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 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 resolveControl, GameSettings settings, - int group) : base(entity, slot, client, settings) + int group) : base(entity, slot, resolveControl, settings) { Group = group; slot.Label.gameObject.SetActive(true); diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index fbfb49267..2c57fe2c3 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -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); diff --git a/Assets/Scripts/Gameplay/AetheriaUnityActionBarPresentation.cs b/Assets/Scripts/Gameplay/AetheriaUnityActionBarPresentation.cs index 727e08a1a..485a2dfc7 100644 --- a/Assets/Scripts/Gameplay/AetheriaUnityActionBarPresentation.cs +++ b/Assets/Scripts/Gameplay/AetheriaUnityActionBarPresentation.cs @@ -10,7 +10,7 @@ public sealed class AetheriaUnityActionBarPresentation private AetheriaRuntimeCatalogSnapshot _catalog; private GameSettings _settings; private Func _resolveEntity = () => null; - private Func _resolveClient = () => null; + private Func _resolveControl = () => null; private IReadOnlyList _localBindings = Array.Empty(); @@ -19,13 +19,13 @@ public sealed class AetheriaUnityActionBarPresentation AetheriaRuntimeCatalogSnapshot catalog, GameSettings settings, Func resolveEntity, - Func resolveClient) + Func resolveControl) { _slots = slots ?? Array.Empty(); _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; diff --git a/Assets/Scripts/Gameplay/AetheriaUnityGameplaySceneWiring.cs b/Assets/Scripts/Gameplay/AetheriaUnityGameplaySceneWiring.cs index 10d2b8e4d..085c2a917 100644 --- a/Assets/Scripts/Gameplay/AetheriaUnityGameplaySceneWiring.cs +++ b/Assets/Scripts/Gameplay/AetheriaUnityGameplaySceneWiring.cs @@ -120,14 +120,14 @@ public sealed class AetheriaUnityGameplaySceneWiring AetheriaRuntimeCatalogSnapshot runtimeCatalog, GameSettings settings, Func resolveCurrentEntity, - Func resolveActionBarClient) + Func resolveActionBarControl) { actionBarPresentation?.Bind( gameplayInputShell?.ActionBarSlots ?? Array.Empty(), runtimeCatalog, settings, resolveCurrentEntity, - resolveActionBarClient); + resolveActionBarControl); Inventory?.SetActionBarPresentation(actionBarPresentation); }