Make Eve state refs resolve reactive documents
This commit is contained in:
parent
9570bfc11d
commit
636756d583
4 changed files with 76 additions and 29 deletions
|
|
@ -11968,11 +11968,24 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
|||
{
|
||||
"public Func<string, string> CreateEveSurfaceStateRefResolver()",
|
||||
"public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver()",
|
||||
"public async Task<CultMeshStateRefResolver> CreateEveSurfaceCultMeshStateRefResolverAsync()",
|
||||
"LatestAsync<AetheriaRuntimeDaemonFrameDocument>()",
|
||||
"LatestAsync<AetheriaRuntimeDaemonHealthDocument>()",
|
||||
"LatestAsync<AetheriaRuntimeDaemonCommandBoundaryDocument>()",
|
||||
"() => Latest<AetheriaRuntimeCatalogSnapshot>()",
|
||||
"public sealed class AetheriaClientState : IDisposable",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument>? _eveStateRefFrame",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeDaemonHealthDocument>? _eveStateRefHealth",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeDaemonCommandBoundaryDocument>? _eveStateRefCommandBoundary",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot>? _eveStateRefCatalog",
|
||||
"_eveStateRefFrame ??= Reactive<AetheriaRuntimeDaemonFrameDocument>()",
|
||||
"_eveStateRefHealth ??= Reactive<AetheriaRuntimeDaemonHealthDocument>()",
|
||||
"_eveStateRefCommandBoundary ??= Reactive<AetheriaRuntimeDaemonCommandBoundaryDocument>()",
|
||||
"_eveStateRefCatalog ??= Reactive<AetheriaRuntimeCatalogSnapshot>()",
|
||||
"() => _eveStateRefFrame.Current",
|
||||
"() => _eveStateRefHealth.Current",
|
||||
"() => _eveStateRefCommandBoundary.Current",
|
||||
"() => _eveStateRefCatalog.Current",
|
||||
"public void Dispose()",
|
||||
"_eveStateRefFrame?.Dispose()",
|
||||
"_eveStateRefHealth?.Dispose()",
|
||||
"_eveStateRefCommandBoundary?.Dispose()",
|
||||
"_eveStateRefCatalog?.Dispose()",
|
||||
"AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver("
|
||||
};
|
||||
var missingClientStateSymbols = requiredClientStateSymbols
|
||||
|
|
@ -11988,10 +12001,21 @@ static void RequireAetheriaRuntimeVerseClientContract(string root)
|
|||
if (clientState.Contains("var frameTask = Daemon.LatestFrameDocumentAsync()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("var healthTask = Daemon.LatestHealthAsync()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("var commandBoundaryTask = Daemon.LatestCommandBoundaryAsync()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("LatestAsync<AetheriaRuntimeDaemonFrameDocument>()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("LatestAsync<AetheriaRuntimeDaemonHealthDocument>()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("LatestAsync<AetheriaRuntimeDaemonCommandBoundaryDocument>()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("Latest<AetheriaRuntimeCatalogSnapshot>()", StringComparison.Ordinal) ||
|
||||
clientState.Contains("LatestCatalog)", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaClientState Eve state-ref resolver must use top-level managed accessors instead of walking through the nested daemon state.");
|
||||
"AetheriaClientState Eve state-ref resolver must own reactive typed documents instead of bootstrapping one-shot latest snapshots.");
|
||||
}
|
||||
|
||||
if (!client.Contains("_aetheriaState?.Dispose()", StringComparison.Ordinal) ||
|
||||
!client.Contains("_aetheriaState = null", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaRuntimeVerseClient must dispose AetheriaClientState so cached reactive state-ref resolver documents do not leak.");
|
||||
}
|
||||
|
||||
var requiredStateRefResolverSymbols = new[]
|
||||
|
|
@ -15669,6 +15693,11 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
|
|||
"AetheriaRuntimeDaemonItemStatQueries.StateRefPrefix",
|
||||
"AetheriaRuntimeDaemonStateRefs.CurrentEntityName",
|
||||
"public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(",
|
||||
"Func<AetheriaRuntimeDaemonFrameDocument?> frameProvider",
|
||||
"Func<AetheriaRuntimeDaemonHealthDocument?> healthProvider",
|
||||
"Func<AetheriaRuntimeDaemonCommandBoundaryDocument?> commandBoundaryProvider",
|
||||
"frameProvider?.Invoke()",
|
||||
"catalogProvider?.Invoke()",
|
||||
"CultMesh.StateRefResolver(",
|
||||
"FindDaemonItem("
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
EditorTui
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientState
|
||||
public sealed class AetheriaClientState : IDisposable
|
||||
{
|
||||
private readonly CultMeshDocumentCatalog _documents;
|
||||
private readonly Func<AetheriaRuntimeRtsViewportBounds, CultMeshDocumentHandle<AetheriaRuntimeRtsViewportDocument>> _mapViewport;
|
||||
|
|
@ -28,6 +28,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
private readonly Func<int, CultMeshDocumentHandle<AetheriaRuntimeSelectedObjectDocument>> _selectedObject;
|
||||
private readonly Func<int, CultMeshDocumentHandle<AetheriaRuntimeInventoryDocument>> _inventory;
|
||||
private readonly Func<string, CultMeshDocumentHandle<AetheriaRuntimeStarbridgePlayerSeatDocument>> _starbridgePlayerSeat;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument>? _eveStateRefFrame;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeDaemonHealthDocument>? _eveStateRefHealth;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeDaemonCommandBoundaryDocument>? _eveStateRefCommandBoundary;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot>? _eveStateRefCatalog;
|
||||
|
||||
internal AetheriaClientState(
|
||||
CultMeshDocumentHandle<AetheriaRuntimeDaemonProviderAdvertisementDocument> providerAdvertisement,
|
||||
|
|
@ -437,22 +441,28 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
public CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver()
|
||||
{
|
||||
return CreateEveSurfaceCultMeshStateRefResolverAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task<CultMeshStateRefResolver> CreateEveSurfaceCultMeshStateRefResolverAsync()
|
||||
{
|
||||
var frameTask = LatestAsync<AetheriaRuntimeDaemonFrameDocument>();
|
||||
var healthTask = LatestAsync<AetheriaRuntimeDaemonHealthDocument>();
|
||||
var commandBoundaryTask = LatestAsync<AetheriaRuntimeDaemonCommandBoundaryDocument>();
|
||||
|
||||
await Task.WhenAll(frameTask, healthTask, commandBoundaryTask).ConfigureAwait(false);
|
||||
_eveStateRefFrame ??= Reactive<AetheriaRuntimeDaemonFrameDocument>();
|
||||
_eveStateRefHealth ??= Reactive<AetheriaRuntimeDaemonHealthDocument>();
|
||||
_eveStateRefCommandBoundary ??= Reactive<AetheriaRuntimeDaemonCommandBoundaryDocument>();
|
||||
_eveStateRefCatalog ??= Reactive<AetheriaRuntimeCatalogSnapshot>();
|
||||
|
||||
return AetheriaRuntimeStateRefResolver.CreateEveSurfaceCultMeshStateRefResolver(
|
||||
frameTask.Result,
|
||||
healthTask.Result,
|
||||
commandBoundaryTask.Result,
|
||||
() => Latest<AetheriaRuntimeCatalogSnapshot>());
|
||||
() => _eveStateRefFrame.Current,
|
||||
() => _eveStateRefHealth.Current,
|
||||
() => _eveStateRefCommandBoundary.Current,
|
||||
() => _eveStateRefCatalog.Current);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_eveStateRefFrame?.Dispose();
|
||||
_eveStateRefHealth?.Dispose();
|
||||
_eveStateRefCommandBoundary?.Dispose();
|
||||
_eveStateRefCatalog?.Dispose();
|
||||
_eveStateRefFrame = null;
|
||||
_eveStateRefHealth = null;
|
||||
_eveStateRefCommandBoundary = null;
|
||||
_eveStateRefCatalog = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,17 +128,20 @@ namespace GameCult.Aetheria.State.Verse
|
|||
}
|
||||
|
||||
public static CultMeshStateRefResolver CreateEveSurfaceCultMeshStateRefResolver(
|
||||
AetheriaRuntimeDaemonFrameDocument? frame,
|
||||
AetheriaRuntimeDaemonHealthDocument? health,
|
||||
AetheriaRuntimeDaemonCommandBoundaryDocument? commandBoundary,
|
||||
Func<AetheriaRuntimeDaemonFrameDocument?> frameProvider,
|
||||
Func<AetheriaRuntimeDaemonHealthDocument?> healthProvider,
|
||||
Func<AetheriaRuntimeDaemonCommandBoundaryDocument?> commandBoundaryProvider,
|
||||
Func<AetheriaRuntimeCatalogSnapshot?>? 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)
|
||||
(stateRef, _context) => TryResolveDaemonStateRef(
|
||||
frameProvider?.Invoke(),
|
||||
healthProvider?.Invoke(),
|
||||
commandBoundaryProvider?.Invoke(),
|
||||
stateRef,
|
||||
out var value)
|
||||
? value
|
||||
: "",
|
||||
new[]
|
||||
|
|
@ -156,8 +159,11 @@ namespace GameCult.Aetheria.State.Verse
|
|||
if (!stateRef.StartsWith(AetheriaRuntimeDaemonItemStatQueries.StateRefPrefix + "/", StringComparison.Ordinal))
|
||||
return "";
|
||||
|
||||
catalog ??= catalogProvider?.Invoke();
|
||||
return TryResolveDaemonItemStatRef(frame, catalog, stateRef, out var value)
|
||||
return TryResolveDaemonItemStatRef(
|
||||
frameProvider?.Invoke(),
|
||||
catalogProvider?.Invoke(),
|
||||
stateRef,
|
||||
out var value)
|
||||
? value
|
||||
: "";
|
||||
},
|
||||
|
|
|
|||
|
|
@ -351,6 +351,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return;
|
||||
|
||||
_disposed = true;
|
||||
_aetheriaState?.Dispose();
|
||||
_aetheriaState = null;
|
||||
_managedDaemonFrame?.Dispose();
|
||||
_managedCatalog?.Dispose();
|
||||
_managedLoadoutTemplates?.Dispose();
|
||||
|
|
|
|||
Loading…
Reference in a new issue