From 05146a6768a756c9ae771f0c3b2188643741091e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 21 Jun 2026 19:23:54 +0100 Subject: [PATCH] Route inventory current ship through observed state --- Aetheria.State.Verify/Program.cs | 16 ++++++++++++++-- Assets/Scripts/Gameplay/ActionGameManager.cs | 6 ++++++ Assets/Scripts/UI/Menu/InventoryMenu.cs | 18 ++++++++++++------ Assets/Scripts/UI/Menu/InventoryPanel.cs | 10 ++++++++-- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index b3e8d94db..bb8b164cb 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -3999,7 +3999,9 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "AetheriaRuntimeShipSettingsCommandKind.DecrementShutdownThreshold", "AetheriaRuntimeShipSettingsCommandKind.IncrementShutdownThreshold", "AetheriaRuntimeShipSettingsCommandKind.ResetShutdownThreshold", - "AetheriaRuntimeShipSettingsCommandKind.Close" + "AetheriaRuntimeShipSettingsCommandKind.Close", + "GameManager.TryGetObservedCurrentEntity(out var currentEntity)", + "GameManager.TryGetObservedCurrentEntity(out var entity)" }; var missingSymbols = requiredSymbols @@ -4028,7 +4030,10 @@ static void RequireInventoryShipSettingsUseEveSurface(string root) "PropertiesPanel.AddField(\"Shutdown Threshold\"", "() => GameManager.CurrentEntity.Settings.ShutdownPerformance", "f => GameManager.RequestEntityShutdownPerformance(GameManager.CurrentEntity, f)", - "switch (request.Command)" + "switch (request.Command)", + "var entity = GameManager.CurrentEntity", + "GameManager.CurrentEntity == null", + "RenderCurrentShipSettingsSurface(GameManager.CurrentEntity)" }; var hits = forbiddenSymbols @@ -10523,6 +10528,13 @@ static void RequireDockedCurrentShipRequestAuthority(string root) throw new InvalidOperationException("InventoryPanel no longer routes current-ship selection through ActionGameManager."); } + if (!inventoryPanel.Contains("GameManager.TryGetObservedCurrentEntity(out var currentEntity)", StringComparison.Ordinal) || + inventoryPanel.Contains("GameManager.CurrentEntity", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "InventoryPanel must compare current-ship UI state through daemon-observed current entity state instead of peeking GameManager.CurrentEntity directly."); + } + if (inventoryPanel.Contains("Current.targetGraphic.color = ToggleEnabledColor;", StringComparison.Ordinal)) { throw new InvalidOperationException( diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index ddcadc061..5abf2ee19 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -496,6 +496,12 @@ public class ActionGameManager : MonoBehaviour public bool IsObservedDocked => TryGetObservedDockingBay(out _); + public bool TryGetObservedCurrentEntity(out Entity entity) + { + entity = CurrentEntity; + return TryGetDaemonEntitySnapshot(entity, out _); + } + public bool TryGetObservedDockingBay(out EquippedDockingBay dockingBay) { dockingBay = null; diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index e5242ca6d..4877e04db 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -65,14 +65,15 @@ public class InventoryMenu : MonoBehaviour // { // _destroyItem = false; // }); + var hasObservedCurrentEntity = GameManager.TryGetObservedCurrentEntity(out var currentEntity); var cargo = GameManager.TryGetObservedDockingBay(out var dockingBay) ? dockingBay - : GameManager.CurrentEntity?.CargoBays.FirstOrDefault(); + : currentEntity?.CargoBays.FirstOrDefault(); if (cargo!=null) InventoryPanels[0].Display(cargo); else InventoryPanels[0].Clear(); - if(GameManager.CurrentEntity != null) - InventoryPanels[1].Display(GameManager.CurrentEntity); + if(hasObservedCurrentEntity) + InventoryPanels[1].Display(currentEntity); else InventoryPanels[1].Clear(); } @@ -158,9 +159,9 @@ public class InventoryMenu : MonoBehaviour panel.OnBackgroundClick.Subscribe(data => { - if (GameManager.CurrentEntity == null) return; // Only show ship settings if there's a ship, duh! + if (!GameManager.TryGetObservedCurrentEntity(out var currentEntity)) return; - RenderCurrentShipSettingsSurface(GameManager.CurrentEntity); + RenderCurrentShipSettingsSurface(currentEntity); }); } } @@ -185,7 +186,12 @@ public class InventoryMenu : MonoBehaviour private void HandleCurrentShipSettingsSurfaceCommand(EveSurfaceCommandRequest request) { - var entity = GameManager.CurrentEntity; + if (!GameManager.TryGetObservedCurrentEntity(out var entity)) + { + HideCurrentShipSettingsSurface(); + return; + } + if (entity?.Settings == null) { HideCurrentShipSettingsSurface(); diff --git a/Assets/Scripts/UI/Menu/InventoryPanel.cs b/Assets/Scripts/UI/Menu/InventoryPanel.cs index 8b0d9a1f2..4ae18e690 100644 --- a/Assets/Scripts/UI/Menu/InventoryPanel.cs +++ b/Assets/Scripts/UI/Menu/InventoryPanel.cs @@ -134,7 +134,10 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler Current.onClick.AddListener(() => { HideDropdownSurface(); - if (_displayedEntity != GameManager.CurrentEntity) + var isDisplayedCurrentEntity = + GameManager.TryGetObservedCurrentEntity(out var currentEntity) && + _displayedEntity == currentEntity; + if (!isDisplayedCurrentEntity) { if(_displayedEntity is Ship ship) { @@ -533,7 +536,10 @@ private void Update() if (Current) { Current.gameObject.SetActive(true); - Current.targetGraphic.color = entity == GameManager.CurrentEntity ? ToggleEnabledColor : ToggleDisabledColor; + Current.targetGraphic.color = + GameManager.TryGetObservedCurrentEntity(out var currentEntity) && entity == currentEntity + ? ToggleEnabledColor + : ToggleDisabledColor; } if (Thermal) {