diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 6edb340b5..89ad4fb3f 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7077,6 +7077,36 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) string.Join(", ", missingActionBarSymbols)); } + var schematicDisplay = File.ReadAllText(Path.Combine( + root, + "Assets", + "Scripts", + "UI", + "HUD", + "SchematicDisplay.cs")); + var requiredSchematicDisplaySymbols = new[] + { + "CultMeshReactiveDocument _catalog", + "CultMeshReactiveDocument _playerSettings", + "ResolveClient().Aetheria().ReactiveCatalog()", + ".Settings", + ".ReactivePlayer()", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()", + "_catalog?.Current", + "_playerSettings?.Current", + "private void OnDestroy()" + }; + var missingSchematicDisplaySymbols = requiredSchematicDisplaySymbols + .Where(symbol => !schematicDisplay.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingSchematicDisplaySymbols.Length > 0) + { + throw new InvalidOperationException( + "SchematicDisplay should bind shared catalog/settings through managed reactive Aetheria documents with HUD lifetime disposal: " + + string.Join(", ", missingSchematicDisplaySymbols)); + } + var volumeCloudRenderer = File.ReadAllText(Path.Combine( root, "Assets", diff --git a/Assets/Scripts/UI/HUD/SchematicDisplay.cs b/Assets/Scripts/UI/HUD/SchematicDisplay.cs index 88dd05bb8..d812550e7 100644 --- a/Assets/Scripts/UI/HUD/SchematicDisplay.cs +++ b/Assets/Scripts/UI/HUD/SchematicDisplay.cs @@ -4,6 +4,7 @@ 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,8 +70,8 @@ public class SchematicDisplay : MonoBehaviour private SchematicDisplayItem[] _schematicItems; private AetherDrive _aetherDrive; private string _clientStatePath = ""; - private AetheriaRuntimeCatalogSnapshot _catalog; - private AetheriaRuntimePlayerSettingsDocument _playerSettings; + private CultMeshReactiveDocument _catalog; + private CultMeshReactiveDocument _playerSettings; private AetheriaRuntimeDaemonRenderSettings? _renderSettings; private AetheriaRuntimeCurrentEntityDocument _currentEntityDocument; private float _currentEntityDocumentReadTime = float.NegativeInfinity; @@ -323,38 +324,38 @@ public class SchematicDisplay : 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 schematic display: {ex.Message}"); + Debug.LogWarning($"Failed to bind Aetheria runtime catalog for schematic display: {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 schematic display: {ex.Message}"); + Debug.LogWarning($"Failed to bind Aetheria player settings for schematic display: {ex.Message}"); } - return _playerSettings; + return _playerSettings?.Current; } private AetheriaRuntimeCurrentEntityHudStatus ResolveCurrentEntityHudStatus() @@ -422,9 +423,16 @@ public class SchematicDisplay : MonoBehaviour private void ClearClientCaches() { + _catalog?.Dispose(); + _playerSettings?.Dispose(); _catalog = null; _playerSettings = null; _currentEntityDocument = null; _currentEntityDocumentReadTime = float.NegativeInfinity; } + + private void OnDestroy() + { + ClearClientCaches(); + } }