diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 40a339a35..5aeaa6d12 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7022,15 +7022,11 @@ static void RequireMenuDockingUsesManagedTypedSnapshot(string root) var clientState = File.ReadAllText(clientStatePath); var requiredClientSymbols = new[] { - "public AetheriaClientDockingSnapshot LatestDockingState()", - "public AetheriaClientReactiveDockingState ReactiveDockingState(", - "public AetheriaClientReactiveDockingState Reactive(", - "public sealed class AetheriaClientReactiveDockingState : IDisposable", - "CultMeshReactiveDocument", - "CultMeshReactiveDocument", - "CultMeshReactiveDocument", - "public AetheriaClientDockingSnapshot Current =>", - "public bool TryCurrent(out AetheriaClientDockingSnapshot" + "public AetheriaClientCurrentState Current { get; }", + "public CultMeshDocumentHandle StationRefit { get; }", + "public CultMeshDocumentHandle Docking { get; }", + "public CultMeshReactiveDocument ReactiveDocking(", + "public CultMeshReactiveDocument ReactiveStationRefit(" }; var missingClientSymbols = requiredClientSymbols .Where(symbol => !clientState.Contains(symbol, StringComparison.Ordinal)) @@ -7038,10 +7034,28 @@ static void RequireMenuDockingUsesManagedTypedSnapshot(string root) if (missingClientSymbols.Length > 0) { throw new InvalidOperationException( - "AetheriaClientDockingState must expose a managed reactive typed docking snapshot for Unity menu surfaces: " + + "AetheriaClientState must expose managed typed docking documents directly for Unity menu surfaces: " + string.Join(", ", missingClientSymbols)); } + var forbiddenClientSymbols = new[] + { + "AetheriaClientDockingState", + "AetheriaClientDockingSnapshot", + "AetheriaClientReactiveDockingState", + "LatestDockingState", + "ReactiveDockingState" + }; + var forbiddenClientHits = forbiddenClientSymbols + .Where(symbol => clientState.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (forbiddenClientHits.Length > 0) + { + throw new InvalidOperationException( + "AetheriaClientState still exposes aggregate docking snapshot wrappers instead of direct managed typed documents: " + + string.Join(", ", forbiddenClientHits)); + } + var menuPaths = new[] { Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryMenu.cs"), @@ -7703,8 +7717,6 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root "public CultMeshReactiveDocument ReactiveDaemonFrame(", "public AetheriaRuntimeDaemonSoaViewDocument LatestDaemonSoaView()", "public CultMeshReactiveDocument ReactiveDaemonSoaView(", - "public AetheriaClientDockingSnapshot LatestDockingState()", - "public AetheriaClientReactiveDockingState ReactiveDockingState(", "public AetheriaRuntimeObservedDaemonState? LatestObservedDaemon()", "public AetheriaRuntimeLoadoutTemplatesDocument LatestLoadoutTemplates()", "public AetheriaRuntimeStationRefitDocument LatestStationRefit()", diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index e6c3eaf53..dc20da86e 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -210,8 +210,13 @@ public class DaemonRuntimeDocumentTests var editorSurface = client.State.LatestEditorSurface(); var editorTuiSurface = client.State.LatestEditorTuiSurface(); var authorityStatus = client.State.LatestAuthorityPolicy(); - var dockingState = client.State.LatestDockingState(); - using var reactiveDockingState = client.State.ReactiveDockingState(); + var currentDocking = client.State.Current.Docking + .LatestAsync() + .GetAwaiter() + .GetResult(); + var stationRefit = client.State.LatestStationRefit(); + using var reactiveCurrentDocking = client.State.Current.ReactiveDocking(); + using var reactiveStationRefit = client.State.ReactiveStationRefit(); using var reactiveGameSurface = client.State.ReactiveGameSurface(); using var reactiveGameTuiSurface = client.State.ReactiveGameTuiSurface(); using var reactiveEditorSurface = client.State.ReactiveEditorSurface(); @@ -287,10 +292,11 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ZoneRender, zoneRenderReactive.Current.Schema); Assert.AreEqual(currentEntity.EntityKey, currentEntityByType.EntityKey); Assert.AreEqual(currentEntity.EntityKey, currentEntityFromClientType.EntityKey); - Assert.AreEqual(currentEntity.EntityKey, dockingState.CurrentEntityKey); - Assert.AreEqual(currentEntity.EntityKey, reactiveDockingState.Current.CurrentEntityKey); - Assert.AreEqual("", dockingState.DockParentEntityKey); - Assert.AreEqual(-1, dockingState.DockingBayIndex); + Assert.AreEqual(currentEntity.EntityKey, currentDocking.CurrentEntityKey); + Assert.AreEqual(currentEntity.EntityKey, reactiveCurrentDocking.Current.CurrentEntityKey); + Assert.AreEqual("", stationRefit.DockParentEntityKey); + Assert.AreEqual("", reactiveStationRefit.Current.DockParentEntityKey); + Assert.AreEqual(-1, stationRefit.DockingBayIndex); Assert.IsTrue(client.State.Current.Entity.Sources.Any(source => source.SourceId == AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString())); Assert.IsTrue(client.State.StationRefit.Sources.Any(source => diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs index 7de366e77..6ebed698a 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs @@ -77,7 +77,6 @@ namespace GameCult.Aetheria.State.Verse zoneDetails, selectedObject, inventory); - DockingState = new AetheriaClientDockingState(Current.Entity, Current.Docking, StationRefit); Starbridge = new AetheriaClientStarbridgeState( starbridgeScenario, starbridgeSession, @@ -124,8 +123,6 @@ namespace GameCult.Aetheria.State.Verse public AetheriaClientCurrentState Current { get; } - public AetheriaClientDockingState DockingState { get; } - public AetheriaClientViewportState Viewports { get; } public AetheriaClientDetailState Details { get; } @@ -246,28 +243,6 @@ namespace GameCult.Aetheria.State.Verse return LatestSoaView.Reactive(options); } - public Task LatestDockingStateAsync() - { - return DockingState.LatestAsync(); - } - - public AetheriaClientDockingSnapshot LatestDockingState() - { - return LatestDockingStateAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - } - - public Task ReactiveDockingStateAsync( - CultMeshReactiveDocumentOptions? options = null) - { - return DockingState.ReactiveAsync(options); - } - - public AetheriaClientReactiveDockingState ReactiveDockingState( - CultMeshReactiveDocumentOptions? options = null) - { - return ReactiveDockingStateAsync(options).ConfigureAwait(false).GetAwaiter().GetResult(); - } - public async Task LatestObservedDaemonAsync() { var frame = await LatestDaemonFrameAsync().ConfigureAwait(false); @@ -916,178 +891,6 @@ namespace GameCult.Aetheria.State.Verse } } - public sealed class AetheriaClientDockingState - { - private readonly CultMeshDocumentHandle _currentEntity; - private readonly CultMeshDocumentHandle _currentDocking; - private readonly CultMeshDocumentHandle _stationRefit; - - internal AetheriaClientDockingState( - CultMeshDocumentHandle currentEntity, - CultMeshDocumentHandle currentDocking, - CultMeshDocumentHandle stationRefit) - { - _currentEntity = currentEntity ?? throw new ArgumentNullException(nameof(currentEntity)); - _currentDocking = currentDocking ?? throw new ArgumentNullException(nameof(currentDocking)); - _stationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit)); - } - - public Task LatestAsync() - { - return CultMesh.LatestAsync( - _currentEntity, - _currentDocking, - _stationRefit, - CreateSnapshot); - } - - public AetheriaClientDockingSnapshot Latest() - { - return LatestAsync().ConfigureAwait(false).GetAwaiter().GetResult(); - } - - public bool TryLatest(out AetheriaClientDockingSnapshot? snapshot) - { - snapshot = null; - try - { - snapshot = Latest(); - return snapshot != null; - } - catch - { - return false; - } - } - - public Task ReactiveAsync( - CultMeshReactiveDocumentOptions? options = null) - { - return AetheriaClientReactiveDockingState.CreateAsync( - _currentEntity, - _currentDocking, - _stationRefit, - options); - } - - public AetheriaClientReactiveDockingState Reactive( - CultMeshReactiveDocumentOptions? options = null) - { - return ReactiveAsync(options).ConfigureAwait(false).GetAwaiter().GetResult(); - } - - private static AetheriaClientDockingSnapshot CreateSnapshot( - AetheriaRuntimeCurrentEntityDocument? entity, - AetheriaRuntimeCurrentDockingDocument? docking, - AetheriaRuntimeStationRefitDocument? refit) - { - var dockingBay = refit?.IsDocked == true && refit.DockingBayIndex >= 0 - ? (refit.DockingBays ?? Array.Empty()) - .FirstOrDefault(row => row != null && row.DockingBayIndex == refit.DockingBayIndex) - : null; - return new AetheriaClientDockingSnapshot(entity, docking, refit, dockingBay); - } - - internal static AetheriaClientDockingSnapshot SnapshotFromCurrent( - AetheriaRuntimeCurrentEntityDocument? entity, - AetheriaRuntimeCurrentDockingDocument? docking, - AetheriaRuntimeStationRefitDocument? refit) - { - return CreateSnapshot(entity, docking, refit); - } - } - - public sealed class AetheriaClientReactiveDockingState : IDisposable - { - private readonly CultMeshReactiveDocument _currentEntity; - private readonly CultMeshReactiveDocument _currentDocking; - private readonly CultMeshReactiveDocument _stationRefit; - - private AetheriaClientReactiveDockingState( - CultMeshReactiveDocument currentEntity, - CultMeshReactiveDocument currentDocking, - CultMeshReactiveDocument stationRefit) - { - _currentEntity = currentEntity ?? throw new ArgumentNullException(nameof(currentEntity)); - _currentDocking = currentDocking ?? throw new ArgumentNullException(nameof(currentDocking)); - _stationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit)); - } - - internal static async Task CreateAsync( - CultMeshDocumentHandle currentEntity, - CultMeshDocumentHandle currentDocking, - CultMeshDocumentHandle stationRefit, - CultMeshReactiveDocumentOptions? options) - { - var currentEntityTask = currentEntity.ReactiveAsync(options); - var currentDockingTask = currentDocking.ReactiveAsync(options); - var stationRefitTask = stationRefit.ReactiveAsync(options); - await Task.WhenAll(currentEntityTask, currentDockingTask, stationRefitTask).ConfigureAwait(false); - return new AetheriaClientReactiveDockingState( - currentEntityTask.Result, - currentDockingTask.Result, - stationRefitTask.Result); - } - - public AetheriaClientDockingSnapshot Current => - AetheriaClientDockingState.SnapshotFromCurrent( - _currentEntity.Current, - _currentDocking.Current, - _stationRefit.Current); - - public bool TryCurrent(out AetheriaClientDockingSnapshot? snapshot) - { - snapshot = null; - try - { - snapshot = Current; - return snapshot != null; - } - catch - { - return false; - } - } - - public void Dispose() - { - _currentEntity.Dispose(); - _currentDocking.Dispose(); - _stationRefit.Dispose(); - } - } - - public sealed class AetheriaClientDockingSnapshot - { - internal AetheriaClientDockingSnapshot( - AetheriaRuntimeCurrentEntityDocument? currentEntity, - AetheriaRuntimeCurrentDockingDocument? currentDocking, - AetheriaRuntimeStationRefitDocument? stationRefit, - AetheriaRuntimeStationDockingBayRow? currentDockingBay) - { - CurrentEntity = currentEntity; - CurrentDocking = currentDocking; - StationRefit = stationRefit; - CurrentDockingBay = currentDockingBay; - } - - public AetheriaRuntimeCurrentEntityDocument? CurrentEntity { get; } - - public AetheriaRuntimeCurrentDockingDocument? CurrentDocking { get; } - - public AetheriaRuntimeStationRefitDocument? StationRefit { get; } - - public AetheriaRuntimeStationDockingBayRow? CurrentDockingBay { get; } - - public string CurrentEntityKey => CurrentEntity?.EntityKey ?? CurrentDocking?.CurrentEntityKey ?? ""; - - public string DockParentEntityKey => StationRefit?.DockParentEntityKey ?? CurrentDocking?.DockParentEntityKey ?? ""; - - public int DockingBayIndex => CurrentDockingBay?.DockingBayIndex ?? StationRefit?.DockingBayIndex ?? CurrentDocking?.DockingBayIndex ?? -1; - - public bool IsDocked => StationRefit?.IsDocked == true && CurrentDockingBay != null; - } - public sealed class AetheriaClientViewportState { private readonly Func> _map;