From 6497636bb2eb6c14c00bfbc1eef0c6aa642057d0 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 10:36:52 +0100 Subject: [PATCH] Sample inventory panel through current typed access --- Aetheria.State.Verify/Program.cs | 142 +++++++++-------------- Assets/Scripts/UI/Menu/InventoryPanel.cs | 101 +++++----------- 2 files changed, 81 insertions(+), 162 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 64be06010..91ccff3ae 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7255,15 +7255,12 @@ static void RequireInventoryValidationUsesManagedTypedDocuments(string root) foreach (var (name, source) in sources) { var compact = CompactSource(source); - var currentEntityAccess = name == "InventoryMenu.cs" - ? ".RuntimeState(\"unity-inventory-menu\").CurrentEntityState()" - : ".ReactiveCurrentEntity(\"unity-inventory\")"; - var stationRefitAccess = name == "InventoryMenu.cs" - ? ".RuntimeState(\"unity-inventory-menu\").CurrentStationRefit()" - : ".ReactiveStationRefit(\"unity-inventory\")"; - var inventoryAccess = name == "InventoryMenu.cs" - ? ".RuntimeState(\"unity-inventory-menu\").CurrentInventory(entityIndex)" - : ".ReactiveInventory(entityIndex)"; + var runtimeId = name == "InventoryMenu.cs" + ? "unity-inventory-menu" + : "unity-inventory"; + var currentEntityAccess = $".RuntimeState(\"{runtimeId}\").CurrentEntityState()"; + var stationRefitAccess = $".RuntimeState(\"{runtimeId}\").CurrentStationRefit()"; + var inventoryAccess = $".RuntimeState(\"{runtimeId}\").CurrentInventory(entityIndex)"; var requiredSymbols = new[] { "CurrentEntitySnapshot()", @@ -7279,12 +7276,6 @@ static void RequireInventoryValidationUsesManagedTypedDocuments(string root) stationRefitAccess, inventoryAccess }; - if (name == "InventoryPanel.cs") - { - missingSymbols = missingSymbols - .Concat(new[] { "_inventory?.Current" }.Where(symbol => !source.Contains(symbol, StringComparison.Ordinal))) - .ToArray(); - } missingSymbols = missingSymbols .Concat(requiredCompactedSymbols.Where(symbol => !compact.Contains(symbol, StringComparison.Ordinal))) .ToArray(); @@ -7321,53 +7312,23 @@ static void RequireInventoryValidationUsesManagedTypedDocuments(string root) $"{name} still routes inventory validation through session wrappers instead of direct managed reactive typed documents."); } - if (name == "InventoryMenu.cs") + var forbiddenCurrentDocumentSymbols = new[] { - var forbiddenMenuSymbols = new[] - { - "CultMeshReactiveDocument<", - ".ReactiveCurrentEntity(\"unity-inventory-menu\")", - ".ReactiveStationRefit(\"unity-inventory-menu\")", - ".ReactiveInventory(entityIndex)", - "_currentEntity?.Dispose()", - "_stationRefit?.Dispose()", - "_inventory?.Dispose()" - } - .Where(symbol => source.Contains(symbol, StringComparison.Ordinal)) - .ToArray(); - if (forbiddenMenuSymbols.Length > 0) - { - throw new InvalidOperationException( - "InventoryMenu should sample inventory validation state through current typed documents instead of owning reactive handles: " + - string.Join(", ", forbiddenMenuSymbols)); - } + "CultMeshReactiveDocument<", + $".ReactiveCurrentEntity(\"{runtimeId}\")", + $".ReactiveStationRefit(\"{runtimeId}\")", + ".ReactiveInventory(entityIndex)", + "_currentEntity?.Dispose()", + "_stationRefit?.Dispose()", + "_inventory?.Dispose()" } - else + .Where(symbol => source.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (forbiddenCurrentDocumentSymbols.Length > 0) { - RequireReactiveTypedDocumentAccess( - source, - name, - "AetheriaRuntimeCurrentEntityDocument", - "_currentEntity", - currentEntityAccess, - "AetheriaRuntimeCurrentEntitySession", - ".ObserveEntity()"); - RequireReactiveTypedDocumentAccess( - source, - name, - "AetheriaRuntimeStationRefitDocument", - "_stationRefit", - stationRefitAccess, - "AetheriaRuntimeStationRefitSession", - ".ObserveStationRefit()"); - RequireReactiveTypedDocumentAccess( - source, - name, - "AetheriaRuntimeInventoryDocument", - "_inventory", - ".ReactiveInventory(entityIndex)", - "AetheriaRuntimeInventorySession", - ".ObserveInventory(entityIndex)"); + throw new InvalidOperationException( + $"{name} should sample inventory validation state through current typed documents instead of owning reactive handles: " + + string.Join(", ", forbiddenCurrentDocumentSymbols)); } } @@ -8046,36 +8007,44 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) "UI", "Menu", "InventoryPanel.cs")); + var compactInventoryPanel = CompactSource(inventoryPanel); var requiredInventoryPanelSharedDocumentSymbols = new[] { + ".RuntimeState(\"unity-inventory\").CurrentCatalog()", + ".RuntimeState(\"unity-inventory\").CurrentPlayerSettings()", "private void OnDestroy()" }; var missingInventoryPanelSharedDocumentSymbols = requiredInventoryPanelSharedDocumentSymbols - .Where(symbol => !inventoryPanel.Contains(symbol, StringComparison.Ordinal)) + .Where(symbol => !compactInventoryPanel.Contains(symbol, StringComparison.Ordinal) && + !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: " + + "InventoryPanel should sample shared catalog/settings through named current typed Aetheria documents: " + string.Join(", ", missingInventoryPanelSharedDocumentSymbols)); } - RequireReactiveTypedDocumentAccess( - inventoryPanel, - "InventoryPanel", - "AetheriaRuntimeCatalogSnapshot", - "_catalog", + var forbiddenInventoryPanelSharedDocumentSymbols = new[] + { + "CultMeshReactiveDocument<", ".ReactiveCatalogSnapshot(\"unity-inventory\")", - "AetheriaRuntimeCatalogSession", - "ResolveClient().State.ObserveCatalog()"); - RequireReactiveTypedDocumentAccess( - inventoryPanel, - "InventoryPanel", - "AetheriaRuntimePlayerSettingsDocument", - "_playerSettings", ".ReactivePlayerSettingsDocument(\"unity-inventory\")", + "AetheriaRuntimeCatalogSession", "AetheriaRuntimePlayerSettingsSession", - ".ObservePlayer()"); + "ResolveClient().State.ObserveCatalog()", + ".ObservePlayer()", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()" + } + .Where(symbol => inventoryPanel.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (forbiddenInventoryPanelSharedDocumentSymbols.Length > 0) + { + throw new InvalidOperationException( + "InventoryPanel still routes catalog/settings through wrapper/session/reactive handles instead of current typed documents: " + + string.Join(", ", forbiddenInventoryPanelSharedDocumentSymbols)); + } var sectorRenderer = File.ReadAllText(Path.Combine( root, @@ -17989,7 +17958,7 @@ static void RequireInventoryDoubleClickTransferRequestAuthority(string root) string.Join(", ", missingTypedSlotValidationSymbols)); } var requiredMenuInventoryAccess = ".CurrentInventory(entityIndex)"; - var requiredPanelInventoryAccess = ".ReactiveInventory(entityIndex)"; + var requiredPanelInventoryAccess = ".CurrentInventory(entityIndex)"; if (!inventoryMenu.Contains(requiredMenuInventoryAccess, StringComparison.Ordinal) || !inventoryPanel.Contains(requiredPanelInventoryAccess, StringComparison.Ordinal)) { @@ -18531,49 +18500,42 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root) { "RequestLoadoutTemplateSave(Entity entity)", "TryResolveEntityRecordKey(entity, out var targetEntityKey)", - "CultMeshReactiveDocument _loadoutFrame", "CreateLoadoutTemplate(targetEntityKey)", ".CreateLoadoutTemplate(targetEntityKey ?? \"\")", - ".ReactiveDaemonFrame(\"unity-inventory\")", - "_loadoutFrame?.Dispose()", ".Ui(\"unity-inventory\")", ".SaveLoadoutTemplateAsync(loadout, \"unity-inventory\")" }; var missingInventoryPanelSymbols = requiredInventoryPanelSymbols .Where(symbol => !inventoryPanel.Contains(symbol, StringComparison.Ordinal)) + .Concat(new[] { ".RuntimeState(\"unity-inventory\").CurrentDaemonFrame()" } + .Where(symbol => !CompactSource(inventoryPanel).Contains(symbol, StringComparison.Ordinal))) .ToArray(); if (missingInventoryPanelSymbols.Length > 0) { throw new InvalidOperationException( - "InventoryPanel no longer sends a typed Eve loadout-template command from the managed reactive daemon frame: " + + "InventoryPanel no longer sends a typed Eve loadout-template command from the managed current daemon frame: " + string.Join(", ", missingInventoryPanelSymbols)); } if (inventoryPanel.Contains("AetheriaRuntimeDaemonFrameSession _loadoutFrame", StringComparison.Ordinal) || + inventoryPanel.Contains("CultMeshReactiveDocument _loadoutFrame", StringComparison.Ordinal) || + inventoryPanel.Contains(".ReactiveDaemonFrame(\"unity-inventory\")", StringComparison.Ordinal) || + inventoryPanel.Contains("_loadoutFrame?.Dispose()", StringComparison.Ordinal) || inventoryPanel.Contains(".ObserveDaemonFrame()", StringComparison.Ordinal) || inventoryPanel.Contains("AetheriaUnityRuntimeClientProvider.RuntimeClient(\"unity-inventory\")", StringComparison.Ordinal) || inventoryPanel.Contains(".Ui.SaveLoadoutTemplateAsync(loadout, \"unity-inventory\")", StringComparison.Ordinal)) { throw new InvalidOperationException( - "InventoryPanel must use managed reactive typed daemon-frame state and the provider-native UI command handle."); + "InventoryPanel must use managed current typed daemon-frame state and the provider-native UI command handle."); } - RequireReactiveTypedDocumentAccess( - inventoryPanel, - "InventoryPanel", - "AetheriaRuntimeDaemonFrameDocument", - "_loadoutFrame", - ".ReactiveDaemonFrame(\"unity-inventory\")", - "AetheriaRuntimeDaemonFrameSession", - ".ObserveDaemonFrame()"); - if (inventoryPanel.Contains(".LoadoutTemplateAsync(", StringComparison.Ordinal) || inventoryPanel.Contains(".ProjectLoadoutTemplateAsync(client.State, targetEntityKey)", StringComparison.Ordinal) || inventoryPanel.Contains("AetheriaRuntimeReactiveLoadoutSnapshotProjector", StringComparison.Ordinal) || inventoryPanel.Contains(".ReactiveLoadoutSnapshotProjector()", StringComparison.Ordinal)) { throw new InvalidOperationException( - "InventoryPanel still asks an aggregate compatibility helper for loadout templates instead of caching the managed reactive daemon frame."); + "InventoryPanel still asks an aggregate compatibility helper for loadout templates instead of reading the managed current daemon frame."); } if (File.Exists(loadoutSnapshotProjectorPath)) diff --git a/Assets/Scripts/UI/Menu/InventoryPanel.cs b/Assets/Scripts/UI/Menu/InventoryPanel.cs index 969e1e865..658e9cf7c 100644 --- a/Assets/Scripts/UI/Menu/InventoryPanel.cs +++ b/Assets/Scripts/UI/Menu/InventoryPanel.cs @@ -10,7 +10,6 @@ using System.Linq; using GameCult.Aetheria.EveRuntime; using GameCult.Aetheria.State.Verse; using GameCult.Eve.Surface; -using GameCult.Mesh; using TMPro; using UniRx; using UniRx.Triggers; @@ -107,13 +106,6 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler private int _clickCount; private InventoryCell _clickCell; private float _clickTime; - private CultMeshReactiveDocument _catalog; - private CultMeshReactiveDocument _playerSettings; - private CultMeshReactiveDocument _currentEntity; - private CultMeshReactiveDocument _stationRefit; - private CultMeshReactiveDocument _loadoutFrame; - private int _inventoryEntityIndex = -1; - private CultMeshReactiveDocument _inventory; private AetheriaRuntimeStationRefitEntityOption[] _dropdownStationRefitEntities = Array.Empty(); private AetheriaRuntimeStationLoadoutRestoreOption[] _dropdownStationRefitLoadouts = @@ -1460,56 +1452,37 @@ private void Update() private void ClearClientCaches() { - _catalog?.Dispose(); - _playerSettings?.Dispose(); - _currentEntity?.Dispose(); - _stationRefit?.Dispose(); - _loadoutFrame?.Dispose(); - _inventory?.Dispose(); - _catalog = null; - _playerSettings = null; - _currentEntity = null; - _stationRefit = null; - _loadoutFrame = null; _observedDockingIndex = null; - _inventory = null; - _inventoryEntityIndex = -1; } private AetheriaRuntimeCurrentEntityDocument CurrentEntitySnapshot() { - if (_currentEntity != null) - return _currentEntity.Current; - try { - _currentEntity = AetheriaUnityRuntimeClientProvider - .ReactiveCurrentEntity("unity-inventory"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-inventory") + .CurrentEntityState(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria current entity for inventory panel: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria current entity for inventory panel: {ex.Message}"); + return null; } - - return _currentEntity?.Current; } private AetheriaRuntimeStationRefitDocument StationRefitSnapshot() { - if (_stationRefit != null) - return _stationRefit.Current; - try { - _stationRefit = AetheriaUnityRuntimeClientProvider - .ReactiveStationRefit("unity-inventory"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-inventory") + .CurrentStationRefit(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria station refit for inventory panel: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria station refit for inventory panel: {ex.Message}"); + return null; } - - return _stationRefit?.Current; } private AetheriaRuntimeLoadoutTemplateCommit CreateLoadoutTemplate(string targetEntityKey) @@ -1521,78 +1494,62 @@ private void Update() private AetheriaRuntimeDaemonFrameDocument ResolveLoadoutFrame() { - if (_loadoutFrame != null) - return _loadoutFrame.Current; - try { - _loadoutFrame = AetheriaUnityRuntimeClientProvider - .ReactiveDaemonFrame("unity-inventory"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-inventory") + .CurrentDaemonFrame(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria daemon frame for loadout template save: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria daemon frame for loadout template save: {ex.Message}"); + return null; } - - return _loadoutFrame?.Current; } private AetheriaRuntimeInventoryDocument InventorySnapshot(int entityIndex) { - if (_inventory != null && _inventoryEntityIndex == entityIndex) - return _inventory.Current; - try { - var nextInventory = AetheriaUnityRuntimeClientProvider + return AetheriaUnityRuntimeClientProvider .RuntimeState("unity-inventory") - .ReactiveInventory(entityIndex); - _inventory?.Dispose(); - _inventoryEntityIndex = entityIndex; - _inventory = nextInventory; + .CurrentInventory(entityIndex); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria typed inventory document for entity {entityIndex}: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria typed inventory document for entity {entityIndex}: {ex.Message}"); + return null; } - - return _inventory?.Current; } private AetheriaRuntimeCatalogSnapshot CatalogSnapshot() { - if (_catalog != null) - return _catalog.Current; - try { - _catalog = AetheriaUnityRuntimeClientProvider - .ReactiveCatalogSnapshot("unity-inventory"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-inventory") + .CurrentCatalog(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria runtime catalog for inventory panel: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria runtime catalog for inventory panel: {ex.Message}"); + return null; } - - return _catalog?.Current; } private AetheriaRuntimePlayerSettingsDocument PlayerSettingsSnapshot() { - if (_playerSettings != null) - return _playerSettings.Current; - try { - _playerSettings = AetheriaUnityRuntimeClientProvider - .ReactivePlayerSettingsDocument("unity-inventory"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-inventory") + .CurrentPlayerSettings(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria player settings for inventory panel: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria player settings for inventory panel: {ex.Message}"); + return null; } - - return _playerSettings?.Current; } private string FormatValue(float value)