Expose native daemon render document handle

This commit is contained in:
Meta Vens 2026-06-29 12:45:03 +01:00
commit 09d92e3d90
5 changed files with 115 additions and 52 deletions

View file

@ -1,6 +1,5 @@
using System;
using GameCult.Aetheria.State.Verse;
using GameCult.Mesh;
using UnityEngine;
public sealed class AetheriaDaemonObserver : MonoBehaviour
@ -21,9 +20,7 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
private float _nextPollTime;
private AetheriaDaemonSoaMemoryMap _soaMemoryMap;
private AetheriaDaemonRenderNativeView _renderNativeView;
private CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument> _daemonFrame;
private CultMeshReactiveDocument<AetheriaRuntimeDaemonSoaViewDocument> _daemonSoaView;
private CultMeshReactiveDocument<AetheriaRuntimeZoneRenderDocument> _zoneRender;
private AetheriaUnityDaemonRenderDocuments _renderDocuments;
public AetheriaRuntimeDaemonRenderView LastRenderView { get; private set; }
public AetheriaRuntimeDaemonObservationResult LastObservation { get; private set; }
@ -102,13 +99,7 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
try
{
EnsureRenderViewDocuments();
return AetheriaRuntimeDaemonRenderView.TryCreateCurrent(
_daemonFrame,
_daemonSoaView,
_zoneRender,
out var observed)
? observed
: null;
return _renderDocuments?.Current;
}
catch
{
@ -118,24 +109,11 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
private void EnsureRenderViewDocuments()
{
if (_daemonFrame != null && _daemonSoaView != null && _zoneRender != null)
if (_renderDocuments != null)
{
return;
}
var state = ResolveState();
if (state == null)
{
return;
}
_daemonFrame ??= state.ReactiveDaemonFrame();
_daemonSoaView ??= state.ReactiveDaemonSoaView();
_zoneRender ??= state.ReactiveZoneRender();
}
private AetheriaClientState ResolveState()
{
var stateBoot = AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory);
if (!stateBoot.SupportsLocalStateFileRead || !stateBoot.StateFileExists)
{
@ -143,7 +121,7 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
$"Aetheria daemon observer requires a readable local Verse state file: {stateBoot.FailureMessage}");
}
return AetheriaUnityRuntimeClientProvider.RuntimeState(stateBoot, clientId);
_renderDocuments = AetheriaUnityRuntimeClientProvider.DaemonRenderDocuments(stateBoot, clientId);
}
private void RemapSoaView(AetheriaRuntimeDaemonRenderView observed)
@ -184,11 +162,7 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
private void DisposeRenderViewDocuments()
{
_daemonFrame?.Dispose();
_daemonFrame = null;
_daemonSoaView?.Dispose();
_daemonSoaView = null;
_zoneRender?.Dispose();
_zoneRender = null;
_renderDocuments?.Dispose();
_renderDocuments = null;
}
}

View file

@ -0,0 +1,44 @@
using System;
using GameCult.Aetheria.State.Verse;
using GameCult.Mesh;
public sealed class AetheriaUnityDaemonRenderDocuments : IDisposable
{
private AetheriaUnityDaemonRenderDocuments(AetheriaClientState state)
{
if (state == null)
throw new ArgumentNullException(nameof(state));
Frame = state.ReactiveDaemonFrame();
SoaView = state.ReactiveDaemonSoaView();
ZoneRender = state.ReactiveZoneRender();
}
public CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument> Frame { get; }
public CultMeshReactiveDocument<AetheriaRuntimeDaemonSoaViewDocument> SoaView { get; }
public CultMeshReactiveDocument<AetheriaRuntimeZoneRenderDocument> ZoneRender { get; }
public AetheriaRuntimeDaemonRenderView Current =>
TryRead(out var observed) ? observed : null;
public static AetheriaUnityDaemonRenderDocuments Open(AetheriaClientState state)
{
return new AetheriaUnityDaemonRenderDocuments(state);
}
public bool TryRead(out AetheriaRuntimeDaemonRenderView observed)
{
return AetheriaRuntimeDaemonRenderView.TryCreateCurrent(
Frame,
SoaView,
ZoneRender,
out observed);
}
public void Dispose()
{
Frame?.Dispose();
SoaView?.Dispose();
ZoneRender?.Dispose();
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: a5bd499492bebfb439338bc5283f6a23

View file

@ -48,9 +48,6 @@ public static class AetheriaUnityRuntimeClientProvider
private static AetheriaClient ResolveClient(AetheriaRuntimeStateBootReport stateBoot, string runtimeId = "")
{
if (stateBoot == null)
throw new ArgumentNullException(nameof(stateBoot));
return ResolveClient(
stateBoot.StateFilePath,
string.IsNullOrWhiteSpace(runtimeId) ? stateBoot.RuntimeId : runtimeId);
@ -131,6 +128,12 @@ public static class AetheriaUnityRuntimeClientProvider
return RuntimeState(runtimeId).CurrentZoneContacts();
}
public static CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> ReactiveZoneContacts(
string runtimeId = "")
{
return RuntimeState(runtimeId).ReactiveZoneContacts();
}
public static AetheriaRuntimeStationRefitDocument CurrentStationRefit(string runtimeId = "")
{
return RuntimeState(runtimeId).CurrentStationRefit();
@ -158,6 +161,20 @@ public static class AetheriaUnityRuntimeClientProvider
return RuntimeState(runtimeId).CurrentInventory(entityIndex);
}
public static CultMeshReactiveDocument<AetheriaRuntimeObjectsViewportDocument> ReactiveObjectsViewport(
AetheriaRuntimeRtsViewportBounds viewport,
string runtimeId = "")
{
return RuntimeState(runtimeId).ReactiveObjectsViewport(viewport);
}
public static CultMeshReactiveDocument<AetheriaRuntimeRenderSplatsViewportDocument> ReactiveRenderSplatsViewport(
AetheriaRuntimeRtsViewportBounds viewport,
string runtimeId = "")
{
return RuntimeState(runtimeId).ReactiveRenderSplatsViewport(viewport);
}
public static AetheriaRuntimeDaemonFrameDocument CurrentDaemonFrame(string runtimeId = "")
{
return RuntimeState(runtimeId).CurrentDaemonFrame();
@ -170,6 +187,13 @@ public static class AetheriaUnityRuntimeClientProvider
return RuntimeState(stateBoot, runtimeId).CurrentDaemonFrame();
}
public static AetheriaUnityDaemonRenderDocuments DaemonRenderDocuments(
AetheriaRuntimeStateBootReport stateBoot,
string runtimeId = "")
{
return AetheriaUnityDaemonRenderDocuments.Open(RuntimeState(stateBoot, runtimeId));
}
public static AetheriaRuntimeVerseHostSettingsDocument CurrentVerseHostSettings(
AetheriaRuntimeStateBootReport stateBoot,
string runtimeId = "")