Route Unity daemon observation through Verse client
This commit is contained in:
parent
c22d104812
commit
1b25cbd247
3 changed files with 67 additions and 5 deletions
|
|
@ -10321,10 +10321,18 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
|
|||
string.Join(", ", missingActionGameManagerSymbols));
|
||||
}
|
||||
|
||||
if (!daemonObserver.Contains("AetheriaRuntimeStateReader.TryReadObservedDaemonState", StringComparison.Ordinal))
|
||||
if (!daemonObserver.Contains("AetheriaRuntimeVerseClient", StringComparison.Ordinal) ||
|
||||
!daemonObserver.Contains(".OpenAsync(statePath", StringComparison.Ordinal) ||
|
||||
!daemonObserver.Contains("GetObservedDaemonStateAsync()", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaDaemonObserver no longer routes observed daemon state through the shared runtime state reader.");
|
||||
"AetheriaDaemonObserver no longer routes observed daemon state through the shared runtime Verse client.");
|
||||
}
|
||||
|
||||
if (daemonObserver.Contains("AetheriaRuntimeStateReader.TryReadObservedDaemonState", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaDaemonObserver still spelunks observed daemon state through the runtime file reader instead of the Verse client.");
|
||||
}
|
||||
|
||||
if (!mainMenu.Contains("AetheriaRuntimeStateReader", StringComparison.Ordinal) ||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
|
|||
private float _nextPollTime;
|
||||
private AetheriaRuntimeDaemonOperationClient _operationClient;
|
||||
private AetheriaRuntimeDaemonOperationsClient _operations;
|
||||
private AetheriaRuntimeVerseClient _verseClient;
|
||||
private string _verseClientStatePath;
|
||||
private AetheriaDaemonSoaMemoryMap _soaMemoryMap;
|
||||
private AetheriaDaemonRenderNativeView _renderNativeView;
|
||||
|
||||
|
|
@ -75,9 +77,8 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
|
|||
|
||||
public bool Poll()
|
||||
{
|
||||
if (!AetheriaRuntimeStateReader.TryReadObservedDaemonState(
|
||||
ActionGameManager.RuntimeStateFilePath,
|
||||
out var observed))
|
||||
var observed = ReadObservedDaemonState();
|
||||
if (observed == null)
|
||||
{
|
||||
LastObservation = _cursor.Observe(null);
|
||||
return false;
|
||||
|
|
@ -116,9 +117,40 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
|
|||
|
||||
private void OnDisable()
|
||||
{
|
||||
DisposeVerseClient();
|
||||
DisposeSoaMemoryMap();
|
||||
}
|
||||
|
||||
private AetheriaRuntimeObservedDaemonState ReadObservedDaemonState()
|
||||
{
|
||||
var client = ResolveVerseClient();
|
||||
return client.GetObservedDaemonStateAsync().GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private AetheriaRuntimeVerseClient ResolveVerseClient()
|
||||
{
|
||||
var statePath = ActionGameManager.RuntimeStateFilePath;
|
||||
if (_verseClient != null && string.Equals(_verseClientStatePath, statePath, StringComparison.Ordinal))
|
||||
{
|
||||
return _verseClient;
|
||||
}
|
||||
|
||||
DisposeVerseClient();
|
||||
_verseClient = AetheriaRuntimeVerseClient
|
||||
.OpenAsync(statePath, clientId, startServer: false, pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_verseClientStatePath = statePath;
|
||||
return _verseClient;
|
||||
}
|
||||
|
||||
private void DisposeVerseClient()
|
||||
{
|
||||
_verseClient?.Dispose();
|
||||
_verseClient = null;
|
||||
_verseClientStatePath = null;
|
||||
}
|
||||
|
||||
private void RemapSoaView(AetheriaRuntimeObservedDaemonState observed)
|
||||
{
|
||||
DisposeSoaMemoryMap();
|
||||
|
|
|
|||
|
|
@ -243,6 +243,28 @@ namespace GameCult.Aetheria.State.Verse
|
|||
AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest);
|
||||
}
|
||||
|
||||
public async Task<AetheriaRuntimeObservedDaemonState?> GetObservedDaemonStateAsync()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
||||
var frame = await GetLatestFrameAsync().ConfigureAwait(false);
|
||||
if (frame == null)
|
||||
return null;
|
||||
|
||||
var soaView = await GetLatestSoaViewAsync().ConfigureAwait(false);
|
||||
if (soaView == null ||
|
||||
!string.Equals(soaView.Schema, AetheriaRuntimeDaemonSchemas.SoaView, StringComparison.Ordinal))
|
||||
{
|
||||
soaView = null;
|
||||
}
|
||||
|
||||
return new AetheriaRuntimeObservedDaemonState(
|
||||
frame,
|
||||
soaView,
|
||||
AetheriaRuntimeDaemonFrameStore.GetFramePath(StatePath),
|
||||
AetheriaRuntimeDaemonSoaViewStore.GetViewPath(StatePath));
|
||||
}
|
||||
|
||||
public Task<EveSurfaceState?> GetDaemonGameSurfaceAsync()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
|
|
|||
Loading…
Reference in a new issue