From d20d8d684a8cf97a34d9c0106d009059c57b11aa Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 27 Jun 2026 16:13:52 +0100 Subject: [PATCH] Centralize Eve state ref resolver construction --- .../Runtime/AetheriaRuntimeStateReader.cs | 76 ++++++++++++------- .../Runtime/AetheriaRuntimeVerseClient.cs | 57 ++++---------- 2 files changed, 65 insertions(+), 68 deletions(-) diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs index 358944c79..ef232f458 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeStateReader.cs @@ -340,6 +340,50 @@ namespace GameCult.Aetheria.State.Verse return CreateStateRefResolver(stateFilePath, runtimeId); } + public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver( + AetheriaRuntimeDaemonFrameDocument? frame, + AetheriaRuntimeDaemonHealthDocument? health, + AetheriaRuntimeDaemonCommandBoundaryDocument? commandBoundary, + Func? catalogProvider = null, + CultMeshRouteHint? routeHint = null) + { + AetheriaRuntimeCatalogSnapshot? catalog = null; + + var daemonRefs = CultMesh.StateRefResolver( + "aetheria.daemon.refs", + (stateRef, _context) => TryResolveDaemonStateRef(frame, health, commandBoundary, stateRef, out var value) + ? value + : "", + new[] + { + CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), + CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonHealth.ToString()), + CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonCommandBoundary.ToString()) + }, + routeHint); + + var itemStatRefs = CultMesh.StateRefResolver( + "aetheria.daemon.item_stats.refs", + (stateRef, _context) => + { + if (!stateRef.StartsWith(AetheriaRuntimeDaemonItemStatQueries.StateRefPrefix + "/", StringComparison.Ordinal)) + return ""; + + catalog ??= catalogProvider?.Invoke(); + return TryResolveDaemonItemStatRef(frame, catalog, stateRef, out var value) + ? value + : ""; + }, + new[] + { + CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), + CultMesh.ProjectionSource("catalog:aetheria.runtime") + }, + routeHint); + + return daemonRefs.Or(itemStatRefs); + } + private static EveSurfaceDocument ToResolvedEveSurfaceDocument( string stateFilePath, AetheriaRuntimeSurfaceDocument surface) @@ -364,34 +408,12 @@ namespace GameCult.Aetheria.State.Verse AetheriaRuntimeDaemonPublicationStore.TryReadHealth(stateFilePath, out var health); AetheriaRuntimeDaemonPublicationStore.TryReadCommandBoundary(stateFilePath, out var commandBoundary); - var daemonRefs = CultMesh.StateRefResolver( - "aetheria.daemon.refs", - (stateRef, _context) => TryResolveDaemonStateRef(frame, health, commandBoundary, stateRef, out var value) - ? value - : "", - new[] - { - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonHealth.ToString()), - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonCommandBoundary.ToString()) - }, + return CreateEveSurfaceCultMeshStateRefResolver( + frame, + health, + commandBoundary, + () => OpenRuntimeCatalog(stateFilePath), new CultMeshRouteHint(CultMeshLocalityKind.InProcess, runtimeId)); - - var itemStatRefs = CultMesh.StateRefResolver( - "aetheria.daemon.item_stats.refs", - (stateRef, _context) => - stateRef.StartsWith(AetheriaRuntimeDaemonItemStatQueries.StateRefPrefix + "/", StringComparison.Ordinal) && - TryResolveDaemonItemStatRef(frame, OpenRuntimeCatalog(stateFilePath), stateRef, out var value) - ? value - : "", - new[] - { - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), - CultMesh.ProjectionSource("catalog:aetheria.runtime") - }, - new CultMeshRouteHint(CultMeshLocalityKind.InProcess, runtimeId)); - - return daemonRefs.Or(itemStatRefs); } private static AetheriaRuntimeLoadoutItemCommit? FindDaemonItem( diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs index 9fb7bad4d..3a17b3a79 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeVerseClient.cs @@ -84,6 +84,7 @@ namespace GameCult.Aetheria.State.Verse typeof(AetheriaRuntimeDaemonCommandBoundaryDocument), typeof(AetheriaRuntimeDaemonFrameDocument), typeof(AetheriaRuntimeDaemonSoaViewDocument), + typeof(AetheriaRuntimeAssetManifestDocument), typeof(AetheriaRuntimeObjectsViewportDocument), typeof(AetheriaRuntimeGravityViewportDocument), typeof(AetheriaRuntimeCurrentZoneDocument), @@ -127,6 +128,7 @@ namespace GameCult.Aetheria.State.Verse CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), + CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), CultNetDocumentBinding.ForDocument(registry), @@ -332,52 +334,25 @@ namespace GameCult.Aetheria.State.Verse } public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver() + { + return CreateEveSurfaceCultMeshStateRefResolverAsync().ConfigureAwait(false).GetAwaiter().GetResult(); + } + + public async Task CreateEveSurfaceCultMeshStateRefResolverAsync() { ThrowIfDisposed(); - var frame = GetLatestFrameAsync().GetAwaiter().GetResult(); - var health = GetHealthAsync().GetAwaiter().GetResult(); - var commandBoundary = GetCommandBoundaryAsync().GetAwaiter().GetResult(); - AetheriaRuntimeCatalogSnapshot? catalog = null; + var frameTask = GetLatestFrameAsync(); + var healthTask = GetHealthAsync(); + var commandBoundaryTask = GetCommandBoundaryAsync(); - var daemonRefs = CultMesh.StateRefResolver( - "aetheria.daemon.refs", - stateRef => - stateRef.StartsWith(AetheriaRuntimeDaemonStateRefs.Prefix + "/", StringComparison.Ordinal) && - AetheriaRuntimeStateReader.TryResolveDaemonStateRef( - frame, - health, - commandBoundary, - stateRef, - out var daemonValue) - ? daemonValue - : "", - new[] - { - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonHealth.ToString()), - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonCommandBoundary.ToString()) - }); + await Task.WhenAll(frameTask, healthTask, commandBoundaryTask).ConfigureAwait(false); - var itemStatRefs = CultMesh.StateRefResolver( - "aetheria.daemon.item_stats.refs", - stateRef => - { - if (!stateRef.StartsWith(AetheriaRuntimeDaemonItemStatQueries.StateRefPrefix + "/", StringComparison.Ordinal)) - return ""; - - catalog ??= OpenRuntimeCatalog(); - return AetheriaRuntimeStateReader.TryResolveDaemonItemStatRef(frame, catalog, stateRef, out var itemValue) - ? itemValue - : ""; - }, - new[] - { - CultMesh.ProjectionSource(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()), - CultMesh.ProjectionSource("catalog:aetheria.runtime") - }); - - return daemonRefs.Or(itemStatRefs); + return AetheriaRuntimeStateReader.CreateEveSurfaceCultMeshStateRefResolver( + frameTask.Result, + healthTask.Result, + commandBoundaryTask.Result, + OpenRuntimeCatalog); } public async Task GetLatestAuthoritativeRunFrameAsync()