From e5799e495030b816e8a0d84df7107b8c4b47766c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 09:02:22 +0100 Subject: [PATCH] Use reactive shared state in inventory menu --- Aetheria.State.Verify/Program.cs | 30 +++++++++++++++++++++++++ Assets/Scripts/UI/Menu/InventoryMenu.cs | 25 ++++++++++++--------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index bcc37c025..4150fd304 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7137,6 +7137,36 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) string.Join(", ", missingTradeMenuSharedDocumentSymbols)); } + var inventoryMenu = File.ReadAllText(Path.Combine( + root, + "Assets", + "Scripts", + "UI", + "Menu", + "InventoryMenu.cs")); + var requiredInventoryMenuSharedDocumentSymbols = new[] + { + "CultMeshReactiveDocument _catalog", + "CultMeshReactiveDocument _playerSettings", + "ResolveClient().Aetheria().ReactiveCatalog()", + ".Settings", + ".ReactivePlayer()", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()", + "_catalog?.Current", + "_playerSettings?.Current", + "private void OnDestroy()" + }; + var missingInventoryMenuSharedDocumentSymbols = requiredInventoryMenuSharedDocumentSymbols + .Where(symbol => !inventoryMenu.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingInventoryMenuSharedDocumentSymbols.Length > 0) + { + throw new InvalidOperationException( + "InventoryMenu should bind shared catalog/settings through managed reactive Aetheria documents with menu lifetime disposal: " + + string.Join(", ", missingInventoryMenuSharedDocumentSymbols)); + } + var volumeCloudRenderer = File.ReadAllText(Path.Combine( root, "Assets", diff --git a/Assets/Scripts/UI/Menu/InventoryMenu.cs b/Assets/Scripts/UI/Menu/InventoryMenu.cs index 462c68ad0..3b6997563 100644 --- a/Assets/Scripts/UI/Menu/InventoryMenu.cs +++ b/Assets/Scripts/UI/Menu/InventoryMenu.cs @@ -6,6 +6,7 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; +using GameCult.Mesh; using GameCult.Aetheria.EveRuntime; using GameCult.Aetheria.State.Verse; using GameCult.Eve.Surface; @@ -31,8 +32,8 @@ public class InventoryMenu : MonoBehaviour private UIDocument _cargoItemDetailsSurfaceDocument; private UIDocument _equippedItemDetailsSurfaceDocument; private string _clientStatePath = ""; - private AetheriaRuntimeCatalogSnapshot _catalog; - private AetheriaRuntimePlayerSettingsDocument _playerSettings; + private CultMeshReactiveDocument _catalog; + private CultMeshReactiveDocument _playerSettings; private AetheriaUnityActionBarPresentation _actionBarPresentation; private AetheriaUnityObservedEntityIndex _observedEntityIndex; private readonly AetheriaEveUnitySurfaceChrome _shipSettingsSurfaceChrome = PanelChrome(360f, 420f); @@ -936,6 +937,8 @@ public class InventoryMenu : MonoBehaviour private void ClearClientCaches() { + _catalog?.Dispose(); + _playerSettings?.Dispose(); _catalog = null; _playerSettings = null; } @@ -995,38 +998,38 @@ public class InventoryMenu : MonoBehaviour private AetheriaRuntimeCatalogSnapshot ResolveCatalog() { if (_catalog != null) - return _catalog; + return _catalog.Current; try { - _catalog = ResolveClient().Aetheria().LatestCatalog(); + _catalog = ResolveClient().Aetheria().ReactiveCatalog(); } catch (Exception ex) { - Debug.LogWarning($"Failed to read Aetheria runtime catalog for inventory menu: {ex.Message}"); + Debug.LogWarning($"Failed to bind Aetheria runtime catalog for inventory menu: {ex.Message}"); } - return _catalog; + return _catalog?.Current; } private AetheriaRuntimePlayerSettingsDocument ResolvePlayerSettings() { if (_playerSettings != null) - return _playerSettings; + return _playerSettings.Current; try { _playerSettings = ResolveClient() .Aetheria() .Settings - .LatestPlayer(); + .ReactivePlayer(); } catch (Exception ex) { - Debug.LogWarning($"Failed to read Aetheria player settings for inventory menu: {ex.Message}"); + Debug.LogWarning($"Failed to bind Aetheria player settings for inventory menu: {ex.Message}"); } - return _playerSettings; + return _playerSettings?.Current; } private float ResolveDefaultShutdownPerformance() @@ -1084,6 +1087,8 @@ public class InventoryMenu : MonoBehaviour private void OnDestroy() { + ClearClientCaches(); + if (_shipSettingsSurfaceDocument != null) { AetheriaEveUnitySurfaceHost.DestroyDocument(_shipSettingsSurfaceDocument);