Use reactive shared state in inventory menu

This commit is contained in:
Meta Vens 2026-06-28 09:02:22 +01:00
commit e5799e4950
2 changed files with 45 additions and 10 deletions

View file

@ -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<AetheriaRuntimeCatalogSnapshot> _catalog",
"CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _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",

View file

@ -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<AetheriaRuntimeCatalogSnapshot> _catalog;
private CultMeshReactiveDocument<AetheriaRuntimePlayerSettingsDocument> _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);