diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 34249e6f7..b32a0dfe1 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4217,8 +4217,8 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root) "AetheriaUnityRuntimeClientProvider.ResolveClient(", ".State", ".Settings", - ".ReactivePlayer()", - "CultMeshReactiveDocument _playerSettings", + ".ObservePlayer()", + "AetheriaRuntimePlayerSettingsSession _playerSettings", "_playerSettings?.Dispose()", "_playerSettings?.Current", "action.ApplyBindingOverride", @@ -4249,6 +4249,8 @@ static void RequireRuntimeInputScreenUsesEveSurface(string root) "LayoutRebuilder", "UILineRenderer", "Observable.NextFrame()", + ".ReactivePlayer()", + "CultMeshReactiveDocument _playerSettings", "DisplayLayout(_inputLayout)", "EnsureSurfaceDocument(", "new EveUiToolkitSurfaceLowerer()", @@ -7241,8 +7243,8 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) var requiredActionBarSymbols = new[] { "public abstract class ActionBarBinding : IDisposable", - "CultMeshReactiveDocument _catalog", - "Client.State.ReactiveCatalog()", + "AetheriaRuntimeCatalogSession _catalog", + "Client.State.ObserveCatalog()", "_catalog?.Current?.FindItem(item, x => x.ItemKey)", "binding?.Dispose()", "private void OnDestroy()" @@ -7257,6 +7259,13 @@ static void RequireUnitySharedDocumentAccessorErgonomics(string root) string.Join(", ", missingActionBarSymbols)); } + if (actionBarSlot.Contains("CultMeshReactiveDocument _catalog", StringComparison.Ordinal) || + actionBarSlot.Contains("Client.State.ReactiveCatalog()", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "ActionBarSlot still owns the raw catalog CultMesh document instead of AetheriaRuntimeCatalogSession."); + } + var schematicDisplay = File.ReadAllText(Path.Combine( root, "Assets", @@ -7739,6 +7748,7 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root "public CultMeshReactiveDocument ReactiveDaemonSoaView(", "public AetheriaRuntimeObservedDaemonState? LatestObservedDaemon()", "public AetheriaRuntimeObservedDockingState? CurrentDocking(", + "public AetheriaRuntimeCatalogSession ObserveCatalog(", "public AetheriaRuntimePlayerHudSession ObservePlayerHud(", "public AetheriaRuntimeLoadoutTemplatesDocument LatestLoadoutTemplates()", "public AetheriaRuntimeStationRefitDocument LatestStationRefit()", @@ -15023,7 +15033,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) var requiredRuntimeClientProviderSymbols = new[] { "public static class AetheriaUnityRuntimeClientProvider", - "private static CultMeshReactiveDocument _playerSettingsDocument", + "private static AetheriaRuntimePlayerSettingsSession _playerSettingsDocument", "public static RuntimePlayerSettings PlayerSettings", "public static AetheriaClient ResolveClient(string stateFilePath, string runtimeId = \"\")", "public static AetheriaClient ResolveClient(AetheriaRuntimeStateBootReport stateBoot, string runtimeId = \"\")", @@ -15034,7 +15044,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "AetheriaClient", ".State", ".Settings", - ".ReactivePlayer()", + ".ObservePlayer()", "_playerSettingsDocument.Current", "_playerSettingsDocument?.Dispose()", "OpenAsync(", @@ -15051,6 +15061,13 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) string.Join(", ", missingRuntimeClientProviderSymbols)); } + if (runtimeClientProvider.Contains("CultMeshReactiveDocument _playerSettingsDocument", StringComparison.Ordinal) || + runtimeClientProvider.Contains(".ReactivePlayer()", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "AetheriaUnityRuntimeClientProvider still owns the raw player-settings CultMesh document instead of AetheriaRuntimePlayerSettingsSession."); + } + var providerOwnedClientAccessSources = new Dictionary { ["Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveSurfacePresenter.cs"] = eveSurfacePresenter, @@ -15174,7 +15191,9 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public Task> ReactiveAsync(", "public CultMeshReactiveDocument Reactive(", "public AetheriaRuntimeObservedDaemonState? CurrentObservedDaemon(", - "public AetheriaRuntimeObservedDaemonSession ObserveDaemon(" + "public AetheriaRuntimeObservedDaemonSession ObserveDaemon(", + "public AetheriaRuntimeCatalogSession ObserveCatalog(", + "public AetheriaRuntimePlayerSettingsSession ObservePlayer(" }; var missingManagedStateAccessSymbols = requiredManagedStateAccessSymbols .Where(symbol => !aetheriaClientState.Contains(symbol, StringComparison.Ordinal)) diff --git a/Assets/Scripts/Gameplay/ActionBarSlot.cs b/Assets/Scripts/Gameplay/ActionBarSlot.cs index d772477a5..5ab133853 100644 --- a/Assets/Scripts/Gameplay/ActionBarSlot.cs +++ b/Assets/Scripts/Gameplay/ActionBarSlot.cs @@ -1,7 +1,6 @@ using System; using System.Linq; using GameCult.Aetheria.State.Verse; -using GameCult.Mesh; using TMPro; using UniRx.Triggers; using UnityEngine; @@ -58,7 +57,7 @@ public abstract class ActionBarBinding : IDisposable protected AetheriaClient Client { get; } protected ActionBarSlot Slot { get; } protected GameSettings Settings { get; } - private CultMeshReactiveDocument _catalog; + private AetheriaRuntimeCatalogSession _catalog; public abstract void Activate(); public abstract void Deactivate(); public abstract void Update(); @@ -95,7 +94,7 @@ public abstract class ActionBarBinding : IDisposable try { - _catalog ??= Client.State.ReactiveCatalog(); + _catalog ??= Client.State.ObserveCatalog(); return _catalog?.Current?.FindItem(item, x => x.ItemKey); } catch (Exception ex) diff --git a/Assets/Scripts/Gameplay/AetheriaUnityRuntimeClientProvider.cs b/Assets/Scripts/Gameplay/AetheriaUnityRuntimeClientProvider.cs index 6899e743d..6d2f3688f 100644 --- a/Assets/Scripts/Gameplay/AetheriaUnityRuntimeClientProvider.cs +++ b/Assets/Scripts/Gameplay/AetheriaUnityRuntimeClientProvider.cs @@ -6,14 +6,13 @@ using System; using System.Collections.Generic; using System.IO; using GameCult.Aetheria.State.Verse; -using GameCult.Mesh; using UnityEngine; public static class AetheriaUnityRuntimeClientProvider { private static readonly Dictionary RuntimeClients = new Dictionary(StringComparer.Ordinal); - private static CultMeshReactiveDocument _playerSettingsDocument; + private static AetheriaRuntimePlayerSettingsSession _playerSettingsDocument; private static RuntimePlayerSettings _runtimePlayerSettings; private static bool _playerSettingsLoaded; @@ -97,7 +96,7 @@ public static class AetheriaUnityRuntimeClientProvider _playerSettingsDocument ??= ResolveClient(AetheriaUnityRuntimePaths.RuntimeStateFilePath) .State .Settings - .ReactivePlayer(); + .ObservePlayer(); var stored = _playerSettingsDocument.Current; if (stored == null) diff --git a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs index e1869d69a..6837d8e53 100644 --- a/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs +++ b/Assets/Scripts/Tests/DaemonRuntimeDocumentTests.cs @@ -205,6 +205,8 @@ public class DaemonRuntimeDocumentTests .Reactive(); var observed = client.State.LatestObservedDaemon(); var observedAuthoritativeFrame = client.State.LatestDaemonFrame(); + using var catalogSession = client.State.ObserveCatalog(); + using var playerSettingsSession = client.State.Settings.ObservePlayer(); using var playerHud = client.State.ObservePlayerHud(); var gameSurface = client.State.LatestGameSurface(); var gameTuiSurface = client.State.LatestGameTuiSurface(); @@ -280,6 +282,8 @@ public class DaemonRuntimeDocumentTests Assert.AreEqual(AetheriaRuntimeCatalogSnapshot.SchemaId, client.State.Catalog.Sources.Last().SchemaId); Assert.GreaterOrEqual(catalog.Items.Count, 0); Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettings.Schema); + Assert.AreSame(catalog, catalogSession.Current); + Assert.AreEqual(AetheriaRuntimePlayerSettingsDocument.SchemaId, playerSettingsSession.Current.Schema); Assert.AreEqual(AetheriaRuntimeVerseHostSettingsDocument.SchemaId, verseHostSettings.Schema); Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ObjectsViewport, objectsViewport.Schema); Assert.AreEqual("Player", objectsViewport.Objects.FirstOrDefault()?.DisplayName); diff --git a/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs b/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs index b014b1cc0..361639633 100644 --- a/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs +++ b/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs @@ -4,7 +4,6 @@ using System.Linq; using GameCult.Aetheria.EveRuntime; using GameCult.Aetheria.State.Verse; using GameCult.Eve.Surface; -using GameCult.Mesh; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; @@ -15,7 +14,7 @@ public class InputDisplayLayout : MonoBehaviour private UIDocument _surfaceDocument; private AetheriaInput _ownedInput; private string _clientStatePath = ""; - private CultMeshReactiveDocument _playerSettings; + private AetheriaRuntimePlayerSettingsSession _playerSettings; private InputAction _captureAction; private InputActionAsset _input; private string _captureActionName = ""; @@ -395,7 +394,7 @@ public class InputDisplayLayout : MonoBehaviour _playerSettings = ResolveClient() .State .Settings - .ReactivePlayer(); + .ObservePlayer(); } catch (Exception ex) { diff --git a/GameCult.Aetheria.State.Unity.csproj b/GameCult.Aetheria.State.Unity.csproj index 292bba4fb..f6b8a78c6 100644 --- a/GameCult.Aetheria.State.Unity.csproj +++ b/GameCult.Aetheria.State.Unity.csproj @@ -75,6 +75,7 @@ + @@ -114,6 +115,7 @@ + diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs index 8e3fe414d..48917f39b 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClientState.cs @@ -199,6 +199,12 @@ namespace GameCult.Aetheria.State.Verse return Catalog.Reactive(options); } + public AetheriaRuntimeCatalogSession ObserveCatalog( + CultMeshReactiveDocumentOptions? options = null) + { + return new AetheriaRuntimeCatalogSession(ReactiveCatalog(options)); + } + public Task LatestDaemonFrameAsync() { return LatestFrame.LatestAsync(); @@ -945,6 +951,12 @@ namespace GameCult.Aetheria.State.Verse return Player.Reactive(options); } + public AetheriaRuntimePlayerSettingsSession ObservePlayer( + CultMeshReactiveDocumentOptions? options = null) + { + return new AetheriaRuntimePlayerSettingsSession(ReactivePlayer(options)); + } + public Task LatestVerseHostAsync() { return VerseHost.LatestAsync(); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs new file mode 100644 index 000000000..818540515 --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs @@ -0,0 +1,43 @@ +using System; +using GameCult.Mesh; + +#nullable enable + +namespace GameCult.Aetheria.State.Verse +{ + public sealed class AetheriaRuntimeCatalogSession : IDisposable + { + private readonly CultMeshReactiveDocument _catalog; + + public AetheriaRuntimeCatalogSession( + CultMeshReactiveDocument catalog) + { + _catalog = catalog ?? throw new ArgumentNullException(nameof(catalog)); + } + + public AetheriaRuntimeCatalogSnapshot? Current => _catalog.Current; + + public void Dispose() + { + _catalog.Dispose(); + } + } + + public sealed class AetheriaRuntimePlayerSettingsSession : IDisposable + { + private readonly CultMeshReactiveDocument _playerSettings; + + public AetheriaRuntimePlayerSettingsSession( + CultMeshReactiveDocument playerSettings) + { + _playerSettings = playerSettings ?? throw new ArgumentNullException(nameof(playerSettings)); + } + + public AetheriaRuntimePlayerSettingsDocument? Current => _playerSettings.Current; + + public void Dispose() + { + _playerSettings.Dispose(); + } + } +} diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs.meta b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs.meta new file mode 100644 index 000000000..7a217367a --- /dev/null +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateSessions.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 0a8d20b7f1c74745a9456dbf7bcd63c0