From 9acb9a4d414a74497eb5a0892526ec122cd41e3a Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 28 Jun 2026 05:32:06 +0100 Subject: [PATCH] Compose loadout saves from managed state --- Aetheria.State.Verify/Program.cs | 40 +++++++++++++++++-- Assets/Scripts/UI/Menu/InventoryPanel.cs | 7 ++-- .../Runtime/AetheriaClient.cs | 18 --------- ...AetheriaRuntimeLoadoutSnapshotProjector.cs | 16 ++++++++ 4 files changed, 56 insertions(+), 25 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 96deb7745..932d0d3db 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -13475,8 +13475,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public CultMeshDocumentHandle Document()", "public Task LatestAsync()", "public Observable Watch()", - "public CultMeshReactiveDocument Reactive(", - "State.Daemon.LatestFrame.LatestAsync()" + "public CultMeshReactiveDocument Reactive(" }; var missingManagedClientAccessSymbols = requiredManagedClientAccessSymbols .Where(symbol => !aetheriaClient.Contains(symbol, StringComparison.Ordinal)) @@ -13525,6 +13524,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root) "public async Task VerseHostSettingsAsync()", "public async Task> LoadoutTemplatesAsync()", "public async Task ObserveAsync()", + "public async Task LoadoutTemplateAsync(", "scenario ??= await _verse.GetStarbridgeScenarioAsync()", "session ??= await _verse.GetStarbridgeSessionAsync()", "var frame = await _verse.GetLatestFrameAsync()", @@ -14902,11 +14902,17 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root) var runtimeStateMapperPath = Path.Combine(root, "Aetheria.State", "AetheriaRuntimeStateMapper.cs"); var inventoryPanelPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryPanel.cs"); var loadoutProjectorPath = Path.Combine(root, "Assets", "Scripts", "ServerShared", "AetheriaRuntimeLoadoutProjector.cs"); + var loadoutSnapshotProjectorPath = Path.Combine( + root, + "Packages", + "org.gamecult.aetheria.state", + "Runtime", + "AetheriaRuntimeLoadoutSnapshotProjector.cs"); var dragSessionPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaUnityDragSession.cs"); var dragObjectsPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaUnityDragObjects.cs"); var gameplaySceneWiringPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaUnityGameplaySceneWiring.cs"); - var requiredFiles = new[] { eveCommandDocumentPath, loadoutCommandsPath, eveBridgePath, runtimeStateMapperPath, inventoryPanelPath, loadoutProjectorPath, dragSessionPath, gameplaySceneWiringPath }; + var requiredFiles = new[] { eveCommandDocumentPath, loadoutCommandsPath, eveBridgePath, runtimeStateMapperPath, inventoryPanelPath, loadoutProjectorPath, loadoutSnapshotProjectorPath, dragSessionPath, gameplaySceneWiringPath }; var missingFiles = requiredFiles.Where(path => !File.Exists(path)).ToArray(); if (missingFiles.Length > 0) { @@ -14921,6 +14927,7 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root) var runtimeStateMapper = File.ReadAllText(runtimeStateMapperPath); var inventoryPanel = File.ReadAllText(inventoryPanelPath); var loadoutProjector = File.ReadAllText(loadoutProjectorPath); + var loadoutSnapshotProjector = File.ReadAllText(loadoutSnapshotProjectorPath); var dragSession = File.ReadAllText(dragSessionPath); var gameplaySceneWiring = File.ReadAllText(gameplaySceneWiringPath); var dragObjects = File.Exists(dragObjectsPath) @@ -14995,7 +15002,8 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root) { "RequestLoadoutTemplateSave(Entity entity)", "TryResolveEntityRecordKey(entity, out var targetEntityKey)", - ".LoadoutTemplateAsync(targetEntityKey)", + "AetheriaRuntimeLoadoutSnapshotProjector", + ".ProjectLoadoutTemplateAsync(client.State, targetEntityKey)", ".Ui.SaveLoadoutTemplateAsync(loadout, \"unity-inventory\")" }; var missingInventoryPanelSymbols = requiredInventoryPanelSymbols @@ -15008,6 +15016,30 @@ static void RequireInventoryLoadoutSaveRequestAuthority(string root) string.Join(", ", missingInventoryPanelSymbols)); } + if (inventoryPanel.Contains(".LoadoutTemplateAsync(", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "InventoryPanel still asks AetheriaClient for a document-specific loadout template helper instead of composing from managed typed state."); + } + + var requiredLoadoutSnapshotProjectorSymbols = new[] + { + "ProjectLoadoutTemplateAsync(", + "AetheriaClientState state", + "state.Daemon.LatestFrame.LatestAsync()", + "ProjectLoadoutTemplate(", + "frame.Run ?? new AetheriaRuntimeRunCheckpointCommit()" + }; + var missingLoadoutSnapshotProjectorSymbols = requiredLoadoutSnapshotProjectorSymbols + .Where(symbol => !loadoutSnapshotProjector.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingLoadoutSnapshotProjectorSymbols.Length > 0) + { + throw new InvalidOperationException( + "Loadout template save payloads must be composed from managed typed daemon frame documents: " + + string.Join(", ", missingLoadoutSnapshotProjectorSymbols)); + } + var forbiddenActionSymbols = new[] { "AetheriaRuntimeStateCommitLog.QueueLoadoutTemplate", diff --git a/Assets/Scripts/UI/Menu/InventoryPanel.cs b/Assets/Scripts/UI/Menu/InventoryPanel.cs index c30c11512..c94b354e4 100644 --- a/Assets/Scripts/UI/Menu/InventoryPanel.cs +++ b/Assets/Scripts/UI/Menu/InventoryPanel.cs @@ -1076,14 +1076,15 @@ private void Update() try { - var loadout = ResolveClient() - .LoadoutTemplateAsync(targetEntityKey) + var client = ResolveClient(); + var loadout = AetheriaRuntimeLoadoutSnapshotProjector + .ProjectLoadoutTemplateAsync(client.State, targetEntityKey) .GetAwaiter() .GetResult(); if (loadout?.RootEntity == null || string.IsNullOrWhiteSpace(loadout.RootEntity.Hull?.ItemKey ?? "")) return; - var submitted = ResolveClient() + var submitted = client .Ui.SaveLoadoutTemplateAsync(loadout, "unity-inventory") .GetAwaiter() .GetResult(); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs index 6c4c34542..cd4993d6a 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaClient.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.Linq; using System.Threading.Tasks; using GameCult.Eve.Surface; using GameCult.Mesh; @@ -128,15 +127,6 @@ namespace GameCult.Aetheria.State.Verse pullOnOpen: pullOnOpen); } - public async Task LoadoutTemplateAsync(string entityKey) - { - ThrowIfDisposed(); - var frame = await RequireFrameAsync().ConfigureAwait(false); - return AetheriaRuntimeLoadoutSnapshotProjector.ProjectLoadoutTemplate( - frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(), - entityKey ?? ""); - } - public Func CreateEveSurfaceStateRefResolver() { ThrowIfDisposed(); @@ -251,14 +241,6 @@ namespace GameCult.Aetheria.State.Verse return submit(operationClient, observed); } - private async Task RequireFrameAsync() - { - var frame = await State.Daemon.LatestFrame.LatestAsync().ConfigureAwait(false); - if (frame == null) - throw new InvalidOperationException("Aetheria local client has no daemon frame yet."); - return frame; - } - private void ThrowIfDisposed() { if (_disposed) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLoadoutSnapshotProjector.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLoadoutSnapshotProjector.cs index 853de07f9..f5bc84a0d 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLoadoutSnapshotProjector.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeLoadoutSnapshotProjector.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; #nullable enable @@ -8,6 +9,21 @@ namespace GameCult.Aetheria.State.Verse { public static class AetheriaRuntimeLoadoutSnapshotProjector { + public static async Task ProjectLoadoutTemplateAsync( + AetheriaClientState state, + string entityKey) + { + if (state == null) throw new ArgumentNullException(nameof(state)); + + var frame = await state.Daemon.LatestFrame.LatestAsync().ConfigureAwait(false); + if (frame == null) + return new AetheriaRuntimeLoadoutTemplateCommit(); + + return ProjectLoadoutTemplate( + frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(), + entityKey ?? ""); + } + public static AetheriaRuntimeLoadoutTemplateCommit ProjectLoadoutTemplate( AetheriaRuntimeRunCheckpointCommit run, string entityKey)