Move observed daemon sampling to client owner

This commit is contained in:
Meta Vens 2026-06-29 02:01:28 +01:00
commit a1b6fc0c07
5 changed files with 73 additions and 35 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.IO;
using System.Threading.Tasks;
using GameCult.Eve.Surface;
using GameCult.Mesh;
#nullable enable
@ -16,6 +17,9 @@ namespace GameCult.Aetheria.State.Verse
private readonly AetheriaControl _control;
private readonly AetheriaUi _ui;
private readonly AetheriaClientState _state;
private CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument>? _observedFrame;
private CultMeshReactiveDocument<AetheriaRuntimeDaemonSoaViewDocument>? _observedSoaView;
private CultMeshReactiveDocument<AetheriaRuntimeZoneRenderDocument>? _observedZoneRender;
private bool _disposed;
private AetheriaClient(AetheriaRuntimeVerseClient verse, string clientId, string sessionId)
@ -150,6 +154,9 @@ namespace GameCult.Aetheria.State.Verse
return;
_disposed = true;
_observedFrame?.Dispose();
_observedSoaView?.Dispose();
_observedZoneRender?.Dispose();
_verse.Dispose();
}
@ -159,7 +166,7 @@ namespace GameCult.Aetheria.State.Verse
ThrowIfDisposed();
if (submit == null) throw new ArgumentNullException(nameof(submit));
var observed = State.CurrentObservedDaemon();
var observed = CurrentObservedDaemon();
var operationClient = new AetheriaRuntimeDaemonOperationClient(
StatePath,
_clientId,
@ -172,6 +179,21 @@ namespace GameCult.Aetheria.State.Verse
return submit(operationClient, observed);
}
internal AetheriaRuntimeObservedDaemonState? CurrentObservedDaemon()
{
ThrowIfDisposed();
_observedFrame ??= State.Reactive<AetheriaRuntimeDaemonFrameDocument>();
_observedSoaView ??= State.Reactive<AetheriaRuntimeDaemonSoaViewDocument>();
_observedZoneRender ??= State.Reactive<AetheriaRuntimeZoneRenderDocument>();
return AetheriaRuntimeObservedDaemonState.TryCreateCurrent(
_observedFrame,
_observedSoaView,
_observedZoneRender,
out var current)
? current
: null;
}
private void ThrowIfDisposed()
{
if (_disposed)

View file

@ -215,17 +215,6 @@ namespace GameCult.Aetheria.State.Verse
return Document<TDocument>().LatestAsync().ConfigureAwait(false).GetAwaiter().GetResult();
}
public AetheriaRuntimeObservedDaemonState? CurrentObservedDaemon(
CultMeshReactiveDocumentOptions? options = null)
{
using var frame = Reactive<AetheriaRuntimeDaemonFrameDocument>(options);
using var soaView = TryReactive<AetheriaRuntimeDaemonSoaViewDocument>(options);
using var zoneRender = Reactive<AetheriaRuntimeZoneRenderDocument>(options);
return AetheriaRuntimeObservedDaemonState.TryCreateCurrent(frame, soaView, zoneRender, out var current)
? current
: null;
}
public CultMeshDocumentHandle<TDocument> Document<TDocument>(AetheriaClientEveSurface surface)
where TDocument : class
{

View file

@ -21,7 +21,7 @@ namespace GameCult.Aetheria.State.Verse
return false;
}
var observed = client.State.CurrentObservedDaemon();
var observed = client.CurrentObservedDaemon();
var operationClient = new AetheriaRuntimeDaemonOperationClient(
client.StatePath,
string.IsNullOrWhiteSpace(request.ClientId) ? AetheriaRuntimeDaemonOperationClient.DefaultClientId : request.ClientId,