From 10186bd078558b9bdb0bd2bf0e9246746b4f13c9 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 10:20:35 +0100 Subject: [PATCH] Sample sector renderer through current typed access --- Aetheria.State.Verify/Program.cs | 170 +++++++++-------------- Assets/Scripts/UI/Menu/SectorRenderer.cs | 81 +++-------- 2 files changed, 85 insertions(+), 166 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index b1e8ae849..c1405c6d6 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4591,9 +4591,12 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) "zoneFacts.Bodies", "zoneFacts.Entities", "AetheriaUnityRuntimeClientProvider", - ".ReactiveSectorMap(\"unity-sector-renderer\")", - ".ReactiveZoneDetails(zoneIndex, \"unity-sector-renderer\")", - "_zoneDetails?.Current", + ".RuntimeState(\"unity-sector-renderer\")", + ".CurrentSectorMap()", + ".CurrentZoneDetails(zoneIndex)", + ".CurrentCatalog()", + ".CurrentPlayerSettings()", + ".CurrentZoneState()", "AetheriaRuntimeZoneDetailsSurfaceCommands.TryRead(request, out var command)", "AetheriaRuntimeZoneDetailsCommandKind.Close" }; @@ -4609,46 +4612,34 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) string.Join(", ", missingSymbols)); } - RequireReactiveTypedDocumentAccess( - source, - "SectorRenderer", - "AetheriaRuntimeSectorMapDocument", - "_sectorMap", + var forbiddenAccessSymbols = new[] + { + "CultMeshReactiveDocument<", ".ReactiveSectorMap(\"unity-sector-renderer\")", - "AetheriaRuntimeSectorMapSession", - ".ObserveSectorMap()"); - RequireReactiveTypedDocumentAccess( - source, - "SectorRenderer", - "AetheriaRuntimeCurrentZoneDocument", - "_currentZone", ".ReactiveCurrentZone(\"unity-sector-renderer\")", - "AetheriaRuntimeCurrentZoneSession", - ".ObserveZone()"); - RequireReactiveTypedDocumentAccess( - source, - "SectorRenderer", - "AetheriaRuntimeZoneDetailsDocument", - "_zoneDetails", ".ReactiveZoneDetails(zoneIndex, \"unity-sector-renderer\")", - "AetheriaRuntimeZoneDetailsSession", - ".ObserveZone(zoneIndex)"); - RequireReactiveTypedDocumentAccess( - source, - "SectorRenderer", - "AetheriaRuntimeCatalogSnapshot", - "_catalog", ".ReactiveCatalogSnapshot(\"unity-sector-renderer\")", - "AetheriaRuntimeCatalogSession", - "ResolveClient().State.ObserveCatalog()"); - RequireReactiveTypedDocumentAccess( - source, - "SectorRenderer", - "AetheriaRuntimePlayerSettingsDocument", - "_playerSettings", ".ReactivePlayerSettingsDocument(\"unity-sector-renderer\")", + "AetheriaRuntimeSectorMapSession", + "AetheriaRuntimeCurrentZoneSession", + "AetheriaRuntimeZoneDetailsSession", + "AetheriaRuntimeCatalogSession", "AetheriaRuntimePlayerSettingsSession", - ".ObservePlayer()"); + ".ObserveSectorMap()", + ".ObserveZone()", + ".ObserveZone(zoneIndex)", + "ResolveClient().State.ObserveCatalog()", + ".ObservePlayer()", + "ClearClientCaches()" + } + .Where(symbol => source.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (forbiddenAccessSymbols.Length > 0) + { + throw new InvalidOperationException( + "SectorRenderer should sample sector UI documents through named current typed state instead of owning reactive/session handles: " + + string.Join(", ", forbiddenAccessSymbols)); + } var forbiddenSymbols = new[] { @@ -8038,84 +8029,47 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) "UI", "Menu", "SectorRenderer.cs")); + var compactSectorRenderer = CompactSource(sectorRenderer); var requiredSectorRendererSharedDocumentSymbols = new[] { - "CultMeshReactiveDocument _sectorMap", - "CultMeshReactiveDocument _currentZone", - "CultMeshReactiveDocument _zoneDetails", - ".Current", - "_sectorMap?.Dispose()", - "_currentZone?.Dispose()", - "_zoneDetails?.Dispose()", - "private void OnDestroy()" - }; - var missingSectorRendererSharedDocumentSymbols = requiredSectorRendererSharedDocumentSymbols - .Where(symbol => !sectorRenderer.Contains(symbol, StringComparison.Ordinal)) + ".RuntimeState(\"unity-sector-renderer\").CurrentSectorMap()", + ".RuntimeState(\"unity-sector-renderer\").CurrentZoneState()", + ".RuntimeState(\"unity-sector-renderer\").CurrentZoneDetails(zoneIndex)", + ".RuntimeState(\"unity-sector-renderer\").CurrentCatalog()", + ".RuntimeState(\"unity-sector-renderer\").CurrentPlayerSettings()" + } + .Where(symbol => !compactSectorRenderer.Contains(symbol, StringComparison.Ordinal)) .ToArray(); - var compactSectorRenderer = CompactSource(sectorRenderer); - missingSectorRendererSharedDocumentSymbols = missingSectorRendererSharedDocumentSymbols - .Concat(new[] - { - ".ReactiveSectorMap(\"unity-sector-renderer\")", - ".ReactiveCurrentZone(\"unity-sector-renderer\")", - ".ReactiveZoneDetails(zoneIndex,\"unity-sector-renderer\")" - }.Where(symbol => !compactSectorRenderer.Contains(symbol, StringComparison.Ordinal))) - .ToArray(); - if (missingSectorRendererSharedDocumentSymbols.Length > 0) + if (requiredSectorRendererSharedDocumentSymbols.Length > 0) { throw new InvalidOperationException( - "SectorRenderer should bind shared catalog/settings through managed reactive Aetheria documents with renderer lifetime disposal: " + - string.Join(", ", missingSectorRendererSharedDocumentSymbols)); + "SectorRenderer should sample shared sector UI state through named current typed Aetheria documents: " + + string.Join(", ", requiredSectorRendererSharedDocumentSymbols)); } - RequireReactiveTypedDocumentAccess( - sectorRenderer, - "SectorRenderer", - "AetheriaRuntimeSectorMapDocument", - "_sectorMap", - ".ReactiveSectorMap(\"unity-sector-renderer\")", - "AetheriaRuntimeSectorMapSession", - ".ObserveSectorMap()"); - RequireReactiveTypedDocumentAccess( - sectorRenderer, - "SectorRenderer", - "AetheriaRuntimeCurrentZoneDocument", - "_currentZone", - ".ReactiveCurrentZone(\"unity-sector-renderer\")", - "AetheriaRuntimeCurrentZoneSession", - ".ObserveZone()"); - RequireReactiveTypedDocumentAccess( - sectorRenderer, - "SectorRenderer", - "AetheriaRuntimeZoneDetailsDocument", - "_zoneDetails", - ".ReactiveZoneDetails(zoneIndex,\"unity-sector-renderer\")", - "AetheriaRuntimeZoneDetailsSession", - ".ObserveZone(zoneIndex)"); - RequireReactiveTypedDocumentAccess( - sectorRenderer, - "SectorRenderer", - "AetheriaRuntimeCatalogSnapshot", - "_catalog", - ".ReactiveCatalogSnapshot(\"unity-sector-renderer\")", - "AetheriaRuntimeCatalogSession", - "ResolveClient().State.ObserveCatalog()"); - RequireReactiveTypedDocumentAccess( - sectorRenderer, - "SectorRenderer", - "AetheriaRuntimePlayerSettingsDocument", - "_playerSettings", - ".ReactivePlayerSettingsDocument(\"unity-sector-renderer\")", - "AetheriaRuntimePlayerSettingsSession", - ".ObservePlayer()"); - var forbiddenSectorRendererSharedDocumentSymbols = new[] { + "CultMeshReactiveDocument<", + ".ReactiveSectorMap(\"unity-sector-renderer\")", + ".ReactiveCurrentZone(\"unity-sector-renderer\")", + ".ReactiveZoneDetails(zoneIndex, \"unity-sector-renderer\")", + ".ReactiveCatalogSnapshot(\"unity-sector-renderer\")", + ".ReactivePlayerSettingsDocument(\"unity-sector-renderer\")", "AetheriaRuntimeSectorMapSession _sectorMap", "AetheriaRuntimeCurrentZoneSession _currentZone", "AetheriaRuntimeZoneDetailsSession _zoneDetails", + "AetheriaRuntimeCatalogSession _catalog", + "AetheriaRuntimePlayerSettingsSession _playerSettings", ".ObserveSectorMap()", - ".ObserveZone(zoneIndex)" + ".ObserveZone()", + ".ObserveZone(zoneIndex)", + "ResolveClient().State.ObserveCatalog()", + ".ObservePlayer()", + "_sectorMap?.Dispose()", + "_currentZone?.Dispose()", + "_zoneDetails?.Dispose()", + "_catalog?.Dispose()", + "_playerSettings?.Dispose()" }; var sectorRendererRawDocumentHits = forbiddenSectorRendererSharedDocumentSymbols .Where(symbol => sectorRenderer.Contains(symbol, StringComparison.Ordinal)) @@ -8123,7 +8077,7 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) if (sectorRendererRawDocumentHits.Length > 0) { throw new InvalidOperationException( - "SectorRenderer still routes map/current-zone/details through session wrappers instead of managed reactive typed documents: " + + "SectorRenderer still routes map/current-zone/details through wrapper/session/reactive handles instead of current typed documents: " + string.Join(", ", sectorRendererRawDocumentHits)); } @@ -14944,11 +14898,11 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) !compactMapRenderer.Contains(".ReactiveRenderSplatsViewport(viewport,\"unity-map-renderer\")", StringComparison.Ordinal) || !compactMapRenderer.Contains(".ReactivePlayerSettingsDocument(\"unity-map-renderer\")", StringComparison.Ordinal) || !sectorRenderer.Contains("AetheriaUnityRuntimeClientProvider", StringComparison.Ordinal) || - !compactSectorRenderer.Contains(".ReactiveSectorMap(\"unity-sector-renderer\")", StringComparison.Ordinal) || - !compactSectorRenderer.Contains(".ReactiveZoneDetails(zoneIndex,\"unity-sector-renderer\")", StringComparison.Ordinal) || - !sectorRenderer.Contains(".Current", StringComparison.Ordinal) || - !compactSectorRenderer.Contains(".ReactiveCatalogSnapshot(\"unity-sector-renderer\")", StringComparison.Ordinal) || - !compactSectorRenderer.Contains(".ReactivePlayerSettingsDocument(\"unity-sector-renderer\")", StringComparison.Ordinal) || + !compactSectorRenderer.Contains(".RuntimeState(\"unity-sector-renderer\").CurrentSectorMap()", StringComparison.Ordinal) || + !compactSectorRenderer.Contains(".RuntimeState(\"unity-sector-renderer\").CurrentZoneDetails(zoneIndex)", StringComparison.Ordinal) || + !compactSectorRenderer.Contains(".RuntimeState(\"unity-sector-renderer\").CurrentCatalog()", StringComparison.Ordinal) || + !compactSectorRenderer.Contains(".RuntimeState(\"unity-sector-renderer\").CurrentPlayerSettings()", StringComparison.Ordinal) || + !compactSectorRenderer.Contains(".RuntimeState(\"unity-sector-renderer\").CurrentZoneState()", StringComparison.Ordinal) || !sectorMap.Contains("AetheriaUnityRuntimeClientProvider", StringComparison.Ordinal) || !compactSectorMap.Contains(".RuntimeState(\"unity-sector-map\").CurrentSectorMap()", StringComparison.Ordinal) || !sectorRenderer.Contains("AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(", StringComparison.Ordinal)) diff --git a/Assets/Scripts/UI/Menu/SectorRenderer.cs b/Assets/Scripts/UI/Menu/SectorRenderer.cs index 5141db406..59ea0f23b 100644 --- a/Assets/Scripts/UI/Menu/SectorRenderer.cs +++ b/Assets/Scripts/UI/Menu/SectorRenderer.cs @@ -6,7 +6,6 @@ using System.Linq; using GameCult.Aetheria.EveRuntime; using GameCult.Aetheria.State.Verse; using GameCult.Eve.Surface; -using GameCult.Mesh; using UniRx; using UnityEngine; using UnityEngine.EventSystems; @@ -46,12 +45,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS private float _sectorBackgroundDepth; private float _sectorCameraDepth; private UIDocument _zoneDetailsSurfaceDocument; - private CultMeshReactiveDocument _catalog; - private CultMeshReactiveDocument _playerSettings; - private CultMeshReactiveDocument _sectorMap; - private CultMeshReactiveDocument _currentZone; - private int _zoneDetailsIndex = -1; - private CultMeshReactiveDocument _zoneDetails; private readonly AetheriaEveUnitySurfaceChrome _zoneDetailsSurfaceChrome = new AetheriaEveUnitySurfaceChrome { RootAlignItems = Align.FlexEnd, @@ -168,9 +161,9 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS try { - _sectorMap ??= AetheriaUnityRuntimeClientProvider - .ReactiveSectorMap("unity-sector-renderer"); - var sectorMap = _sectorMap?.Current; + var sectorMap = AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-sector-renderer") + .CurrentSectorMap(); return (sectorMap?.Zones ?? Array.Empty()) .FirstOrDefault(zone => zone.ZoneIndex == zoneIndex); } @@ -191,23 +184,17 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS if (zoneIndex < 0) return null; - if (_zoneDetails != null && _zoneDetailsIndex == zoneIndex) - return _zoneDetails.Current; - try { - var nextZoneDetails = AetheriaUnityRuntimeClientProvider - .ReactiveZoneDetails(zoneIndex, "unity-sector-renderer"); - _zoneDetails?.Dispose(); - _zoneDetailsIndex = zoneIndex; - _zoneDetails = nextZoneDetails; + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-sector-renderer") + .CurrentZoneDetails(zoneIndex); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria sector zone details from local Verse state: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria sector zone details from local Verse state: {ex.Message}"); + return null; } - - return _zoneDetails?.Current; } private string ResolveHullType(string hullItemKey) @@ -218,38 +205,32 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS private AetheriaRuntimeCatalogSnapshot ResolveCatalog() { - if (_catalog != null) - return _catalog.Current; - try { - _catalog = AetheriaUnityRuntimeClientProvider - .ReactiveCatalogSnapshot("unity-sector-renderer"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-sector-renderer") + .CurrentCatalog(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria sector catalog from local Verse state: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria sector catalog from local Verse state: {ex.Message}"); + return null; } - - return _catalog?.Current; } private AetheriaRuntimePlayerSettingsDocument ResolvePlayerSettings() { - if (_playerSettings != null) - return _playerSettings.Current; - try { - _playerSettings = AetheriaUnityRuntimeClientProvider - .ReactivePlayerSettingsDocument("unity-sector-renderer"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-sector-renderer") + .CurrentPlayerSettings(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria sector player settings from local Verse state: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria sector player settings from local Verse state: {ex.Message}"); + return null; } - - return _playerSettings?.Current; } private string FormatValue(float value) @@ -267,20 +248,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS : formatted; } - private void ClearClientCaches() - { - _catalog?.Dispose(); - _playerSettings?.Dispose(); - _sectorMap?.Dispose(); - _currentZone?.Dispose(); - _zoneDetails?.Dispose(); - _catalog = null; - _playerSettings = null; - _sectorMap = null; - _currentZone = null; - _zoneDetails = null; - _zoneDetailsIndex = -1; - } private void OnEnable() { _init = true; @@ -300,15 +267,15 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS { try { - _currentZone ??= AetheriaUnityRuntimeClientProvider - .ReactiveCurrentZone("unity-sector-renderer"); + return AetheriaUnityRuntimeClientProvider + .RuntimeState("unity-sector-renderer") + .CurrentZoneState(); } catch (Exception ex) { - Debug.LogWarning($"Failed to bind Aetheria sector current zone from local Verse state: {ex.Message}"); + Debug.LogWarning($"Failed to read Aetheria sector current zone from local Verse state: {ex.Message}"); + return null; } - - return _currentZone?.Current; } private void OnDisable() @@ -324,8 +291,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS private void OnDestroy() { - ClearClientCaches(); - if (_zoneDetailsSurfaceDocument != null) { AetheriaEveUnitySurfaceHost.DestroyDocument(_zoneDetailsSurfaceDocument);