Compose loadout saves from managed state
This commit is contained in:
parent
6f71c4cd16
commit
9acb9a4d41
4 changed files with 56 additions and 25 deletions
|
|
@ -13475,8 +13475,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
|
|||
"public CultMeshDocumentHandle<TDocument> Document<TDocument>()",
|
||||
"public Task<TDocument> LatestAsync<TDocument>()",
|
||||
"public Observable<TDocument> Watch<TDocument>()",
|
||||
"public CultMeshReactiveDocument<TDocument> Reactive<TDocument>(",
|
||||
"State.Daemon.LatestFrame.LatestAsync()"
|
||||
"public CultMeshReactiveDocument<TDocument> Reactive<TDocument>("
|
||||
};
|
||||
var missingManagedClientAccessSymbols = requiredManagedClientAccessSymbols
|
||||
.Where(symbol => !aetheriaClient.Contains(symbol, StringComparison.Ordinal))
|
||||
|
|
@ -13525,6 +13524,7 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
|
|||
"public async Task<AetheriaRuntimeVerseHostSettingsSnapshot?> VerseHostSettingsAsync()",
|
||||
"public async Task<System.Collections.Generic.IReadOnlyList<AetheriaRuntimeLoadoutTemplateSnapshot>> LoadoutTemplatesAsync()",
|
||||
"public async Task<AetheriaRuntimeObservedDaemonState?> ObserveAsync()",
|
||||
"public async Task<AetheriaRuntimeLoadoutTemplateCommit> 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",
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<AetheriaRuntimeLoadoutTemplateCommit> LoadoutTemplateAsync(string entityKey)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
var frame = await RequireFrameAsync().ConfigureAwait(false);
|
||||
return AetheriaRuntimeLoadoutSnapshotProjector.ProjectLoadoutTemplate(
|
||||
frame.Run ?? new AetheriaRuntimeRunCheckpointCommit(),
|
||||
entityKey ?? "");
|
||||
}
|
||||
|
||||
public Func<string, string> CreateEveSurfaceStateRefResolver()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
|
@ -251,14 +241,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return submit(operationClient, observed);
|
||||
}
|
||||
|
||||
private async Task<AetheriaRuntimeDaemonFrameDocument> 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)
|
||||
|
|
|
|||
|
|
@ -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<AetheriaRuntimeLoadoutTemplateCommit> 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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue