From 7c9e0f1aae6a39a09ba7502823a1d96564c33690 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 10:06:48 +0100 Subject: [PATCH] Sample schematic HUD through current typed access --- Aetheria.State.Verify/Program.cs | 51 +++++++++------- Assets/Scripts/UI/HUD/SchematicDisplay.cs | 71 ++++++++--------------- 2 files changed, 54 insertions(+), 68 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index c55eef02d..c41161672 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -2560,16 +2560,13 @@ static void RequireDaemonRenderQueryAuthority(string root) var requiredSchematicHudSymbols = new[] { - "CultMeshReactiveDocument _catalog", - "CultMeshReactiveDocument _playerSettings", - "CultMeshReactiveDocument _currentEntity", "CatalogSnapshot()", "CurrentEntityHudStatus()", - ".ReactiveCatalogSnapshot(\"unity-schematic-display\")", - ".ReactivePlayerSettingsDocument(\"unity-schematic-display\")", - ".ReactiveCurrentEntity(\"unity-schematic-display\")", - "return _currentEntity?.Current?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();", - "_currentEntity?.Dispose()", + ".RuntimeState(\"unity-schematic-display\")", + ".CurrentCatalog()", + ".CurrentPlayerSettings()", + ".CurrentEntityState()", + "?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();", "hud.OverrideShutdown", "hud.HeatsinksEnabled", "hud.Heatstroke", @@ -2589,6 +2586,15 @@ static void RequireDaemonRenderQueryAuthority(string root) var forbiddenSchematicHudSymbols = new[] { + "CultMeshReactiveDocument", + "CultMeshReactiveDocument", + "CultMeshReactiveDocument", + ".ReactiveCatalogSnapshot(\"unity-schematic-display\")", + ".ReactivePlayerSettingsDocument(\"unity-schematic-display\")", + ".ReactiveCurrentEntity(\"unity-schematic-display\")", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()", + "_currentEntity?.Dispose()", "_entity.OverrideShutdown", "_entity.HeatsinksEnabled", "_entity.Heatstroke", @@ -7664,21 +7670,15 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) "AetheriaRuntimePlayerHudState.cs"); var requiredSchematicDisplaySymbols = new[] { - "CultMeshReactiveDocument _catalog", - "CultMeshReactiveDocument _playerSettings", - "CultMeshReactiveDocument _currentEntity", - ".ReactiveCatalogSnapshot(\"unity-schematic-display\")", - ".ReactivePlayerSettingsDocument(\"unity-schematic-display\")", - ".ReactiveCurrentEntity(\"unity-schematic-display\")", - "_catalog?.Dispose()", - "_playerSettings?.Dispose()", - "_currentEntity?.Dispose()", + ".RuntimeState(\"unity-schematic-display\")", + ".CurrentCatalog()", + ".CurrentPlayerSettings()", + ".CurrentEntityState()", "CatalogSnapshot()?.FindItem(item, x => x.ItemKey)", "private AetheriaRuntimeCatalogSnapshot CatalogSnapshot()", "private AetheriaRuntimePlayerSettingsDocument PlayerSettingsSnapshot()", "private AetheriaRuntimeCurrentEntityHudStatus CurrentEntityHudStatus()", - "return _playerSettings?.Current;", - "private void OnDestroy()" + "?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus();" }; var missingSchematicDisplaySymbols = requiredSchematicDisplaySymbols .Where(symbol => !schematicDisplay.Contains(symbol, StringComparison.Ordinal)) @@ -7686,7 +7686,7 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) if (missingSchematicDisplaySymbols.Length > 0) { throw new InvalidOperationException( - "SchematicDisplay should bind shared catalog/settings/current-entity HUD through managed reactive typed documents: " + + "SchematicDisplay should sample shared catalog/settings/current-entity HUD through named current typed documents: " + string.Join(", ", missingSchematicDisplaySymbols)); } if (schematicDisplay.Contains("ResolveCatalog()?.Current?.FindItem", StringComparison.Ordinal) || @@ -7698,6 +7698,15 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) var forbiddenSchematicDisplaySymbols = new[] { + "CultMeshReactiveDocument", + "CultMeshReactiveDocument", + "CultMeshReactiveDocument", + ".ReactiveCatalogSnapshot(\"unity-schematic-display\")", + ".ReactivePlayerSettingsDocument(\"unity-schematic-display\")", + ".ReactiveCurrentEntity(\"unity-schematic-display\")", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()", + "_currentEntity?.Dispose()", "AetheriaRuntimePlayerHudSession _playerHud", "ResolvePlayerHud()", "ResolveClient().State.ObservePlayerHud()", @@ -7711,7 +7720,7 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) if (schematicDisplayHits.Length > 0) { throw new InvalidOperationException( - "SchematicDisplay still routes through AetheriaRuntimePlayerHudSession instead of direct managed reactive typed documents: " + + "SchematicDisplay still routes through legacy HUD/reactive wrappers instead of named current typed documents: " + string.Join(", ", schematicDisplayHits)); } diff --git a/Assets/Scripts/UI/HUD/SchematicDisplay.cs b/Assets/Scripts/UI/HUD/SchematicDisplay.cs index 8c3f0b8d7..3be0c7103 100644 --- a/Assets/Scripts/UI/HUD/SchematicDisplay.cs +++ b/Assets/Scripts/UI/HUD/SchematicDisplay.cs @@ -4,7 +4,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; using GameCult.Aetheria.State.Verse; -using GameCult.Mesh; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -69,9 +68,6 @@ public class SchematicDisplay : MonoBehaviour private EquippedCargoBay[] _cargoBays; private SchematicDisplayItem[] _schematicItems; private AetherDrive _aetherDrive; - private CultMeshReactiveDocument _catalog; - private CultMeshReactiveDocument _playerSettings; - private CultMeshReactiveDocument _currentEntity; private AetheriaRuntimeDaemonRenderSettings? _renderSettings; private bool _enemy; @@ -320,56 +316,51 @@ public class SchematicDisplay : MonoBehaviour private AetheriaRuntimeCatalogSnapshot CatalogSnapshot() { - if (_catalog != null) - return _catalog.Current; - try { - _catalog = AetheriaUnityRuntimeClientProvider - .ReactiveCatalogSnapshot("unity-schematic-display"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-schematic-display") + .CurrentCatalog(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria runtime catalog for schematic display: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria runtime catalog for schematic display: {ex.Message}"); } - return _catalog?.Current; + return null; } private AetheriaRuntimePlayerSettingsDocument PlayerSettingsSnapshot() { - if (_playerSettings == null) + try { - try - { - _playerSettings = AetheriaUnityRuntimeClientProvider - .ReactivePlayerSettingsDocument("unity-schematic-display"); - } - catch (Exception ex) - { - Debug.LogWarning($"Failed to bind Aetheria player settings for schematic display: {ex.Message}"); - } + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-schematic-display") + .CurrentPlayerSettings(); + } + catch (Exception ex) + { + Debug.LogWarning($"Failed to read Aetheria player settings for schematic display: {ex.Message}"); } - return _playerSettings?.Current; + return null; } private AetheriaRuntimeCurrentEntityHudStatus CurrentEntityHudStatus() { - if (_currentEntity == null) + try { - try - { - _currentEntity = AetheriaUnityRuntimeClientProvider - .ReactiveCurrentEntity("unity-schematic-display"); - } - catch (Exception ex) - { - Debug.LogWarning($"Failed to bind Aetheria current entity for schematic display: {ex.Message}"); - } + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-schematic-display") + .CurrentEntityState() + ?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus(); + } + catch (Exception ex) + { + Debug.LogWarning($"Failed to read Aetheria current entity for schematic display: {ex.Message}"); } - return _currentEntity?.Current?.Hud ?? new AetheriaRuntimeCurrentEntityHudStatus(); + return new AetheriaRuntimeCurrentEntityHudStatus(); } private string FormatValue(float value) @@ -400,18 +391,4 @@ public class SchematicDisplay : MonoBehaviour return $"{FormatValue(value - 273.15f)} C"; } - private void ClearClientCaches() - { - _catalog?.Dispose(); - _catalog = null; - _playerSettings?.Dispose(); - _playerSettings = null; - _currentEntity?.Dispose(); - _currentEntity = null; - } - - private void OnDestroy() - { - ClearClientCaches(); - } }