From 570365f2963a4f37b9891d5cd52f82a6575b36c6 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 09:04:28 +0100 Subject: [PATCH] Use reactive shared state in inventory panel --- Aetheria.State.Verify/Program.cs | 30 ++++++++++++++++++++++++ Assets/Scripts/UI/Menu/InventoryPanel.cs | 25 ++++++++++++-------- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 4150fd304..5c61ce131 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7167,6 +7167,36 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) string.Join(", ", missingInventoryMenuSharedDocumentSymbols)); } + var inventoryPanel = File.ReadAllText(Path.Combine( + root, + "Assets", + "Scripts", + "UI", + "Menu", + "InventoryPanel.cs")); + var requiredInventoryPanelSharedDocumentSymbols = new[] + { + "CultMeshReactiveDocument _catalog", + "CultMeshReactiveDocument _playerSettings", + "ResolveClient().Aetheria().ReactiveCatalog()", + ".Settings", + ".ReactivePlayer()", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()", + "_catalog?.Current", + "_playerSettings?.Current", + "private void OnDestroy()" + }; + var missingInventoryPanelSharedDocumentSymbols = requiredInventoryPanelSharedDocumentSymbols + .Where(symbol => !inventoryPanel.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingInventoryPanelSharedDocumentSymbols.Length > 0) + { + throw new InvalidOperationException( + "InventoryPanel should bind shared catalog/settings through managed reactive Aetheria documents with panel lifetime disposal: " + + string.Join(", ", missingInventoryPanelSharedDocumentSymbols)); + } + var volumeCloudRenderer = File.ReadAllText(Path.Combine( root, "Assets", diff --git a/Assets/Scripts/UI/Menu/InventoryPanel.cs b/Assets/Scripts/UI/Menu/InventoryPanel.cs index ec8c7e558..83ff8447c 100644 --- a/Assets/Scripts/UI/Menu/InventoryPanel.cs +++ b/Assets/Scripts/UI/Menu/InventoryPanel.cs @@ -7,6 +7,7 @@ using System.Collections; 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; @@ -101,8 +102,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler private InventoryCell _clickCell; private float _clickTime; private string _clientStatePath = ""; - private AetheriaRuntimeCatalogSnapshot _catalog; - private AetheriaRuntimePlayerSettingsDocument _playerSettings; + private CultMeshReactiveDocument _catalog; + private CultMeshReactiveDocument _playerSettings; private AetheriaRuntimeStationRefitEntityOption[] _dropdownStationRefitEntities = Array.Empty(); private AetheriaRuntimeStationLoadoutRestoreOption[] _dropdownStationRefitLoadouts = @@ -1485,6 +1486,8 @@ private void Update() private void ClearClientCaches() { + _catalog?.Dispose(); + _playerSettings?.Dispose(); _catalog = null; _playerSettings = null; } @@ -1492,38 +1495,38 @@ private void Update() 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 panel: {ex.Message}"); + Debug.LogWarning($"Failed to bind Aetheria runtime catalog for inventory panel: {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 panel: {ex.Message}"); + Debug.LogWarning($"Failed to bind Aetheria player settings for inventory panel: {ex.Message}"); } - return _playerSettings; + return _playerSettings?.Current; } private string FormatValue(float value) @@ -1599,6 +1602,8 @@ private void Update() private void OnDestroy() { + ClearClientCaches(); + if (_dropdownSurfaceDocument != null) { AetheriaEveUnitySurfaceHost.DestroyDocument(_dropdownSurfaceDocument);