From 1a535c416da2e25ab1777464c85bb82d3d9b9ad7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 14:03:52 +0100 Subject: [PATCH] Centralize main menu state sessions --- Aetheria.State.Verify/Program.cs | 48 ++++++++++++++----- .../Tests/DaemonRuntimeDocumentTests.cs | 4 ++ Assets/Scripts/UI/MainMenu.cs | 13 +++-- .../Runtime/AetheriaClientState.cs | 12 +++++ .../Runtime/AetheriaRuntimeStateSessions.cs | 36 ++++++++++++++ 5 files changed, 93 insertions(+), 20 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index e2a8884fa..2bac1f430 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7415,13 +7415,13 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) "MainMenu.cs")); var requiredMainMenuSharedDocumentSymbols = new[] { - "CultMeshReactiveDocument _sectorMap", - "CultMeshReactiveDocument _playerSettings", - "CultMeshReactiveDocument _verseHostSettings", - ".ReactiveSectorMap()", + "AetheriaRuntimeSectorMapSession _sectorMap", + "AetheriaRuntimePlayerSettingsSession _playerSettings", + "AetheriaRuntimeVerseHostSettingsSession _verseHostSettings", + ".ObserveSectorMap()", ".Settings", - ".ReactivePlayer()", - ".ReactiveVerseHost()", + ".ObservePlayer()", + ".ObserveVerseHost()", "_sectorMap?.Dispose()", "_playerSettings?.Dispose()", "_verseHostSettings?.Dispose()", @@ -7440,6 +7440,25 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) string.Join(", ", missingMainMenuSharedDocumentSymbols)); } + var forbiddenMainMenuSharedDocumentSymbols = new[] + { + "CultMeshReactiveDocument _sectorMap", + "CultMeshReactiveDocument _playerSettings", + "CultMeshReactiveDocument _verseHostSettings", + ".ReactiveSectorMap()", + ".ReactivePlayer()", + ".ReactiveVerseHost()" + }; + var mainMenuRawDocumentHits = forbiddenMainMenuSharedDocumentSymbols + .Where(symbol => mainMenu.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (mainMenuRawDocumentHits.Length > 0) + { + throw new InvalidOperationException( + "MainMenu still owns raw sector/settings CultMesh documents instead of managed sessions: " + + string.Join(", ", mainMenuRawDocumentHits)); + } + var tradeMenu = File.ReadAllText(Path.Combine( root, "Assets", @@ -7803,6 +7822,7 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root "public AetheriaRuntimeObservedDaemonState? LatestObservedDaemon()", "public AetheriaRuntimeObservedDockingState? CurrentDocking(", "public AetheriaRuntimeCatalogSession ObserveCatalog(", + "public AetheriaRuntimeSectorMapSession ObserveSectorMap(", "public AetheriaRuntimeZoneContactsSession ObserveZoneContacts(", "public AetheriaRuntimePlayerHudSession ObservePlayerHud(", "public AetheriaRuntimeLoadoutTemplatesDocument LatestLoadoutTemplates()", @@ -8540,7 +8560,7 @@ static void RequireClientTargetBootAuthority(string root) "ResolveSectorMap(AetheriaRuntimeStateBootReport stateBoot)", "AetheriaClient", ".State", - ".ReactiveSectorMap()", + ".ObserveSectorMap()", "ResolveVerseHostSettings(AetheriaRuntimeStateBootReport stateBoot)", "AetheriaState.At(AetheriaUnityRuntimePaths.GameDataDirectory)", ".ClientTarget", @@ -11921,7 +11941,7 @@ static void RequireMainMenuVerseHostProjection(string root) { "ResolveVerseHostSettings(AetheriaRuntimeStateBootReport stateBoot)", ".Settings", - ".ReactiveVerseHost()", + ".ObserveVerseHost()", "AetheriaRuntimeMainMenuSurfaceBuilder.ProjectRoot(", "AetheriaRuntimeMainMenuSurfaceBuilder.BuildRoot(" }; @@ -12054,7 +12074,7 @@ static void RequireMainMenuContinueRunState(string root) "ResolveSectorMap", "AetheriaClient", ".State", - ".ReactiveSectorMap()", + ".ObserveSectorMap()", "ContinueGame()", "SceneManager.LoadScene(\"ARPG\")" }; @@ -14189,7 +14209,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) "TryStartDaemonObservedGame", "ResolveSectorMap(stateBoot)", ".State", - ".ReactiveSectorMap()", + ".ObserveSectorMap()", "sectorMap.FrameId", "SceneManager.LoadScene(\"ARPG\")" }; @@ -15263,7 +15283,9 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public AetheriaRuntimeObservedDaemonSession ObserveDaemon(", "public AetheriaRuntimeCatalogSession ObserveCatalog(", "public AetheriaRuntimeZoneContactsSession ObserveZoneContacts(", - "public AetheriaRuntimePlayerSettingsSession ObservePlayer(" + "public AetheriaRuntimePlayerSettingsSession ObservePlayer(", + "public AetheriaRuntimeVerseHostSettingsSession ObserveVerseHost(", + "public AetheriaRuntimeSectorMapSession ObserveSectorMap(" }; var missingManagedStateAccessSymbols = requiredManagedStateAccessSymbols .Where(symbol => !aetheriaClientState.Contains(symbol, StringComparison.Ordinal)) @@ -15492,8 +15514,8 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) if (!mainMenu.Contains("AetheriaClient", StringComparison.Ordinal) || !mainMenu.Contains("ResolveSectorMap(AetheriaRuntimeStateBootReport stateBoot)", StringComparison.Ordinal) || !mainMenu.Contains(".State", StringComparison.Ordinal) || - !mainMenu.Contains(".ReactiveSectorMap()", StringComparison.Ordinal) || - !mainMenu.Contains(".ReactivePlayer()", StringComparison.Ordinal)) + !mainMenu.Contains(".ObserveSectorMap()", StringComparison.Ordinal) || + !mainMenu.Contains(".ObservePlayer()", StringComparison.Ordinal)) { throw new InvalidOperationException( "MainMenu no longer routes sector-map lookup through the shared Aetheria client facade."); diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index ed1ec01e2..ad2132f51 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -206,7 +206,9 @@ public class DaemonRuntimeDocumentTests var observed = client.State.LatestObservedDaemon(); var observedAuthoritativeFrame = client.State.LatestDaemonFrame(); using var catalogSession = client.State.ObserveCatalog(); + using var sectorMapSession = client.State.ObserveSectorMap(); using var playerSettingsSession = client.State.Settings.ObservePlayer(); + using var verseHostSettingsSession = client.State.Settings.ObserveVerseHost(); using var zoneContactsSession = client.State.ObserveZoneContacts(); using var playerHud = client.State.ObservePlayerHud(); var gameSurface = client.State.LatestGameSurface(); @@ -284,8 +286,10 @@ public class DaemonRuntimeDocumentTests Assert.GreaterOrEqual(catalog.Items.Count, 0); Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettings.Schema); Assert.AreSame(catalog, catalogSession.Current); + Assert.AreEqual(AetheriaRuntimeDaemonSchemas.SectorMap, sectorMapSession.Current.Schema); Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettingsSession.Current.Schema); Assert.AreEqual(AetheriaRuntimeVerseHostSettingsDocument.SchemaId, verseHostSettings.Schema); + Assert.AreEqual(AetheriaRuntimeVerseHostSettingsDocument.SchemaId, verseHostSettingsSession.Current.Schema); Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ObjectsViewport, objectsViewport.Schema); Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ZoneContacts, zoneContactsSession.Current.Schema); Assert.AreEqual("Player", objectsViewport.Objects.FirstOrDefault()?.DisplayName); diff --git a/Assets/Scripts/UI/MainMenu.cs b/Assets/Scripts/UI/MainMenu.cs index 808c10936..bd26123de 100644 --- a/Assets/Scripts/UI/MainMenu.cs +++ b/Assets/Scripts/UI/MainMenu.cs @@ -1,5 +1,4 @@ using System; -using GameCult.Mesh; using GameCult.Aetheria.EveRuntime; using GameCult.Aetheria.State.Verse; using GameCult.Eve.Surface; @@ -19,9 +18,9 @@ public class MainMenu : MonoBehaviour private UIDocument _menuSurfaceDocument; private string _clientStatePath; - private CultMeshReactiveDocument _sectorMap; - private CultMeshReactiveDocument _playerSettings; - private CultMeshReactiveDocument _verseHostSettings; + private AetheriaRuntimeSectorMapSession _sectorMap; + private AetheriaRuntimePlayerSettingsSession _playerSettings; + private AetheriaRuntimeVerseHostSettingsSession _verseHostSettings; private Func _canOpenRuntimeInputScreen; private Action _openRuntimeInputScreen; private readonly AetheriaEveUnitySurfaceChrome _menuSurfaceChrome = new AetheriaEveUnitySurfaceChrome @@ -152,7 +151,7 @@ public class MainMenu : MonoBehaviour { _sectorMap ??= ResolveClient(stateBoot) .State - .ReactiveSectorMap(); + .ObserveSectorMap(); return _sectorMap?.Current; } catch (Exception ex) @@ -172,7 +171,7 @@ public class MainMenu : MonoBehaviour _playerSettings ??= ResolveClient(stateBoot) .State .Settings - .ReactivePlayer(); + .ObservePlayer(); return _playerSettings?.Current; } catch (Exception ex) @@ -192,7 +191,7 @@ public class MainMenu : MonoBehaviour _verseHostSettings ??= ResolveClient(stateBoot) .State .Settings - .ReactiveVerseHost(); + .ObserveVerseHost(); return _verseHostSettings?.Current; } catch (Exception ex) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs index b11744ba5..6cac43e51 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs @@ -526,6 +526,12 @@ namespace GameCult.Aetheria.State.Verse return SectorMap.Reactive(options); } + public AetheriaRuntimeSectorMapSession ObserveSectorMap( + CultMeshReactiveDocumentOptions? options = null) + { + return new AetheriaRuntimeSectorMapSession(ReactiveSectorMap(options)); + } + public Task LatestZoneContactsAsync() { return ZoneContacts.LatestAsync(); @@ -984,6 +990,12 @@ namespace GameCult.Aetheria.State.Verse { return VerseHost.Reactive(options); } + + public AetheriaRuntimeVerseHostSettingsSession ObserveVerseHost( + CultMeshReactiveDocumentOptions? options = null) + { + return new AetheriaRuntimeVerseHostSettingsSession(ReactiveVerseHost(options)); + } } public sealed class AetheriaClientViewportState diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs index 297c23cb1..1e270a4bb 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs @@ -41,6 +41,42 @@ namespace GameCult.Aetheria.State.Verse } } + public sealed class AetheriaRuntimeVerseHostSettingsSession : IDisposable + { + private readonly CultMeshReactiveDocument _verseHostSettings; + + public AetheriaRuntimeVerseHostSettingsSession( + CultMeshReactiveDocument verseHostSettings) + { + _verseHostSettings = verseHostSettings ?? throw new ArgumentNullException(nameof(verseHostSettings)); + } + + public AetheriaRuntimeVerseHostSettingsDocument? Current => _verseHostSettings.Current; + + public void Dispose() + { + _verseHostSettings.Dispose(); + } + } + + public sealed class AetheriaRuntimeSectorMapSession : IDisposable + { + private readonly CultMeshReactiveDocument _sectorMap; + + public AetheriaRuntimeSectorMapSession( + CultMeshReactiveDocument sectorMap) + { + _sectorMap = sectorMap ?? throw new ArgumentNullException(nameof(sectorMap)); + } + + public AetheriaRuntimeSectorMapDocument? Current => _sectorMap.Current; + + public void Dispose() + { + _sectorMap.Dispose(); + } + } + public sealed class AetheriaRuntimeZoneContactsSession : IDisposable { private readonly CultMeshReactiveDocument _zoneContacts;