Move daemon operation facade into runtime client
This commit is contained in:
parent
54aea11b5b
commit
c22d104812
6 changed files with 154 additions and 20 deletions
|
|
@ -2879,8 +2879,15 @@ static void RequireEveRuntimeBootstrap(string root)
|
|||
var requiredPresenterSymbols = new[]
|
||||
{
|
||||
"private string surfaceId = AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId",
|
||||
"AetheriaRuntimeStateReader.ReadEveSurface(statePath, surfaceId)",
|
||||
"AetheriaRuntimeStateReader.ReadEveSurface(stateBoot.StateFilePath, surfaceId)",
|
||||
"private AetheriaRuntimeVerseClient? _verseClient",
|
||||
"ReadDaemonSurface(statePath)",
|
||||
"ReadDaemonSurface(stateBoot.StateFilePath)",
|
||||
"AetheriaRuntimeVerseClient.OpenAsync(",
|
||||
"GetDaemonGameSurfaceAsync()",
|
||||
"GetDaemonGameTuiSurfaceAsync()",
|
||||
"GetDaemonEditorSurfaceAsync()",
|
||||
"GetDaemonEditorTuiSurfaceAsync()",
|
||||
"AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(",
|
||||
"private bool ShouldMountSurface(",
|
||||
"_mountedSurfaceVersion != surface.Version",
|
||||
"private static readonly AetheriaEveUnitySurfaceChrome RootOnlyChrome",
|
||||
|
|
@ -2900,6 +2907,12 @@ static void RequireEveRuntimeBootstrap(string root)
|
|||
string.Join(", ", missingPresenterSymbols));
|
||||
}
|
||||
|
||||
if (presenter.Contains("AetheriaRuntimeStateReader.ReadEveSurface", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Aetheria Eve presenter still mounts daemon surfaces through file-reader lookup instead of AetheriaRuntimeVerseClient.");
|
||||
}
|
||||
|
||||
if (presenter.Contains("new EveUiToolkitSurfaceLowerer", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
|
|
@ -7194,8 +7207,18 @@ static void RequireTypedDaemonCommandPayloads(string root)
|
|||
"command.EquipmentTransfer.SourceKind",
|
||||
"command.StoreItem.SourceEquipmentIndex"
|
||||
};
|
||||
var daemonOperationsUnity = File.ReadAllText(Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaDaemonOperations.cs"));
|
||||
var clientAndObserver = daemonClient + "\n" + observer + "\n" + stateNode + "\n" + daemonOperationsUnity;
|
||||
var daemonOperationsClientPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonOperationsClient.cs");
|
||||
var daemonOperationsClient = File.Exists(daemonOperationsClientPath)
|
||||
? File.ReadAllText(daemonOperationsClientPath)
|
||||
: throw new InvalidOperationException("Shared daemon operations client is missing from the runtime package.");
|
||||
var legacyUnityOperationsPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaDaemonOperations.cs");
|
||||
if (File.Exists(legacyUnityOperationsPath))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Aetheria daemon operation facade still lives under Unity gameplay; move shared client operations into the runtime package.");
|
||||
}
|
||||
|
||||
var clientAndObserver = daemonClient + "\n" + observer + "\n" + stateNode + "\n" + daemonOperationsClient;
|
||||
var missingClientSymbols = requiredClientSymbols
|
||||
.Where(symbol => !clientAndObserver.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
|
|
@ -7260,8 +7283,7 @@ static void RequireTypedDaemonCommandPayloads(string root)
|
|||
};
|
||||
var unityDocumentSubmitHits = new Dictionary<string, string>
|
||||
{
|
||||
["Unity daemon observer"] = observer,
|
||||
["Unity daemon operations"] = daemonOperationsUnity
|
||||
["Unity daemon observer"] = observer
|
||||
}
|
||||
.SelectMany(source => forbiddenUnityDocumentSubmitSymbols
|
||||
.Where(symbol => source.Value.Contains(symbol, StringComparison.Ordinal))
|
||||
|
|
@ -8957,7 +8979,8 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
|
|||
var daemonRuntimeOperationsPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonOperations.cs");
|
||||
var daemonIntentPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonIntentState.cs");
|
||||
var daemonObserverPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaDaemonObserver.cs");
|
||||
var daemonGameplayOperationsPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaDaemonOperations.cs");
|
||||
var daemonGameplayOperationsPath = Path.Combine(root, "Packages", "org.gamecult.aetheria.state", "Runtime", "AetheriaRuntimeDaemonOperationsClient.cs");
|
||||
var legacyDaemonGameplayOperationsPath = Path.Combine(root, "Assets", "Scripts", "Gameplay", "AetheriaDaemonOperations.cs");
|
||||
var actionGameManager = File.Exists(actionGameManagerPath)
|
||||
? File.ReadAllText(actionGameManagerPath)
|
||||
: throw new InvalidOperationException("Cannot verify Unity observer authority; ActionGameManager.cs is missing.");
|
||||
|
|
@ -8984,7 +9007,13 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
|
|||
: throw new InvalidOperationException("Cannot verify Unity observer authority; AetheriaDaemonObserver.cs is missing.");
|
||||
var daemonOperations = File.Exists(daemonGameplayOperationsPath)
|
||||
? File.ReadAllText(daemonGameplayOperationsPath)
|
||||
: throw new InvalidOperationException("Cannot verify Unity observer authority; AetheriaDaemonOperations.cs is missing.");
|
||||
: throw new InvalidOperationException("Cannot verify Unity observer authority; shared daemon operations client is missing.");
|
||||
|
||||
if (File.Exists(legacyDaemonGameplayOperationsPath))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Unity gameplay still owns AetheriaDaemonOperations; shared daemon operation access belongs in the runtime package.");
|
||||
}
|
||||
|
||||
var forbiddenGameplaySymbols = new[]
|
||||
{
|
||||
|
|
@ -10305,10 +10334,11 @@ static void RequireRuntimeStateReaderOwnsUnityStateAcquisition(string root)
|
|||
"MainMenu no longer routes daemon-frame lookup through the shared runtime state reader.");
|
||||
}
|
||||
|
||||
if (!eveSurfacePresenter.Contains("AetheriaRuntimeStateReader.ReadEveSurface", StringComparison.Ordinal))
|
||||
if (!eveSurfacePresenter.Contains("AetheriaRuntimeVerseClient.OpenAsync(", StringComparison.Ordinal) ||
|
||||
!eveSurfacePresenter.Contains("ReadDaemonSurface(statePath)", StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Aetheria Eve surface presenter no longer routes provider surface lookup through the shared runtime state reader.");
|
||||
"Aetheria Eve surface presenter no longer routes daemon surface lookup through the shared runtime Verse client.");
|
||||
}
|
||||
|
||||
if (!eveSurfacePresenter.Contains("AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver(statePath)", StringComparison.Ordinal))
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
|
|||
private readonly AetheriaRuntimeDaemonObservationCursor _cursor = new AetheriaRuntimeDaemonObservationCursor();
|
||||
private float _nextPollTime;
|
||||
private AetheriaRuntimeDaemonOperationClient _operationClient;
|
||||
private AetheriaDaemonOperations _operations;
|
||||
private AetheriaRuntimeDaemonOperationsClient _operations;
|
||||
private AetheriaDaemonSoaMemoryMap _soaMemoryMap;
|
||||
private AetheriaDaemonRenderNativeView _renderNativeView;
|
||||
|
||||
|
|
@ -34,7 +34,8 @@ public sealed class AetheriaDaemonObserver : MonoBehaviour
|
|||
public AetheriaDaemonSoaMemoryMap LastSoaMemoryMap => _soaMemoryMap;
|
||||
public AetheriaDaemonRenderNativeView LastRenderNativeView => _renderNativeView;
|
||||
public bool HasRenderNativeView => _renderNativeView.IsCreated;
|
||||
public AetheriaDaemonOperations Operations => _operations ??= new AetheriaDaemonOperations(this);
|
||||
public AetheriaRuntimeDaemonOperationsClient Operations =>
|
||||
_operations ??= new AetheriaRuntimeDaemonOperationsClient(SendOperation);
|
||||
|
||||
public event Action<AetheriaRuntimeObservedDaemonState, AetheriaRuntimeDaemonObservationResult> ObservedDaemonStateChanged;
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,7 @@
|
|||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSurfaceCommandCatalog.cs" />
|
||||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSurfaceCommands.cs" />
|
||||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonOperations.cs" />
|
||||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonOperationsClient.cs" />
|
||||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonIntentState.cs" />
|
||||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSoaDocuments.cs" />
|
||||
<Compile Include="Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeDaemonSoaFramePublisher.cs" />
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ namespace GameCult.Aetheria.EveRuntime
|
|||
private float refreshIntervalSeconds = 0.1f;
|
||||
|
||||
private UIDocument? _document;
|
||||
private AetheriaRuntimeVerseClient? _verseClient;
|
||||
private string _verseClientStatePath = "";
|
||||
private float _nextRefreshTime;
|
||||
private string _mountedStatePath = "";
|
||||
private string _mountedSurfaceId = "";
|
||||
|
|
@ -81,7 +83,7 @@ namespace GameCult.Aetheria.EveRuntime
|
|||
return;
|
||||
}
|
||||
|
||||
var surface = AetheriaRuntimeStateReader.ReadEveSurface(statePath, surfaceId);
|
||||
var surface = ReadDaemonSurface(statePath);
|
||||
if (surface == null)
|
||||
{
|
||||
root.Add(BuildError($"Eve surface not found: {surfaceId}"));
|
||||
|
|
@ -112,13 +114,58 @@ namespace GameCult.Aetheria.EveRuntime
|
|||
if (!stateBoot.SupportsLocalStateFileRead || !stateBoot.StateFileExists)
|
||||
return;
|
||||
|
||||
var surface = AetheriaRuntimeStateReader.ReadEveSurface(stateBoot.StateFilePath, surfaceId);
|
||||
var surface = ReadDaemonSurface(stateBoot.StateFilePath);
|
||||
if (surface == null || !ShouldMountSurface(stateBoot.StateFilePath, surface))
|
||||
return;
|
||||
|
||||
MountSurface(stateBoot.StateFilePath, surface);
|
||||
}
|
||||
|
||||
private EveSurfaceDocument? ReadDaemonSurface(string statePath)
|
||||
{
|
||||
var client = ResolveVerseClient(statePath);
|
||||
var surface = ReadDaemonSurfaceState(client);
|
||||
return surface == null
|
||||
? null
|
||||
: AetheriaRuntimeEveSurfaceAdapter.ToEveSurfaceDocument(
|
||||
surface,
|
||||
AetheriaRuntimeStateReader.CreateEveSurfaceStateRefResolver(statePath));
|
||||
}
|
||||
|
||||
private global::Aetheria.State.Documents.EveSurfaceState? ReadDaemonSurfaceState(AetheriaRuntimeVerseClient client)
|
||||
{
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonGameSurfaceBuilder.SurfaceId, StringComparison.Ordinal))
|
||||
return client.GetDaemonGameSurfaceAsync().GetAwaiter().GetResult();
|
||||
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonGameSurfaceBuilder.TuiSurfaceId, StringComparison.Ordinal))
|
||||
return client.GetDaemonGameTuiSurfaceAsync().GetAwaiter().GetResult();
|
||||
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonEditorSurfaceBuilder.SurfaceId, StringComparison.Ordinal))
|
||||
return client.GetDaemonEditorSurfaceAsync().GetAwaiter().GetResult();
|
||||
|
||||
if (string.Equals(surfaceId, AetheriaRuntimeDaemonEditorSurfaceBuilder.TuiSurfaceId, StringComparison.Ordinal))
|
||||
return client.GetDaemonEditorTuiSurfaceAsync().GetAwaiter().GetResult();
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeVerseClient ResolveVerseClient(string statePath)
|
||||
{
|
||||
if (_verseClient != null && string.Equals(_verseClientStatePath, statePath, StringComparison.Ordinal))
|
||||
return _verseClient;
|
||||
|
||||
_verseClient?.Dispose();
|
||||
_verseClientStatePath = statePath ?? "";
|
||||
_verseClient = AetheriaRuntimeVerseClient.OpenAsync(
|
||||
_verseClientStatePath,
|
||||
"unity-eve-surface-presenter",
|
||||
startServer: false,
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
return _verseClient;
|
||||
}
|
||||
|
||||
private UIDocument ResolveDocument()
|
||||
{
|
||||
if (_document == null)
|
||||
|
|
@ -190,5 +237,12 @@ namespace GameCult.Aetheria.EveRuntime
|
|||
Debug.Log(
|
||||
$"Submitted Eve command for CultMesh bridge: {envelope!.ProviderId}/{envelope.SurfaceId}/{envelope.Command} {envelope.CommandId}");
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
_verseClient?.Dispose();
|
||||
_verseClient = null;
|
||||
_verseClientStatePath = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
using System;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
|
||||
public sealed class AetheriaDaemonOperations
|
||||
namespace GameCult.Aetheria.State.Verse
|
||||
{
|
||||
private readonly AetheriaDaemonObserver _observer;
|
||||
public sealed class AetheriaRuntimeDaemonOperationsClient
|
||||
{
|
||||
private readonly Func<Func<AetheriaRuntimeDaemonOperationClient, AetheriaRuntimeObservedDaemonState, AetheriaRuntimeDaemonCommandEnvelope>, AetheriaRuntimeDaemonCommandEnvelope> _submit;
|
||||
|
||||
internal AetheriaDaemonOperations(AetheriaDaemonObserver observer)
|
||||
public AetheriaRuntimeDaemonOperationsClient(
|
||||
Func<Func<AetheriaRuntimeDaemonOperationClient, AetheriaRuntimeObservedDaemonState, AetheriaRuntimeDaemonCommandEnvelope>, AetheriaRuntimeDaemonCommandEnvelope> submit)
|
||||
{
|
||||
_observer = observer ?? throw new ArgumentNullException(nameof(observer));
|
||||
_submit = submit ?? throw new ArgumentNullException(nameof(submit));
|
||||
}
|
||||
|
||||
public AetheriaRuntimeDaemonCommandEnvelope SetTarget(string targetEntityKey)
|
||||
|
|
@ -377,6 +379,7 @@ public sealed class AetheriaDaemonOperations
|
|||
private AetheriaRuntimeDaemonCommandEnvelope Send(
|
||||
Func<AetheriaRuntimeDaemonOperationClient, AetheriaRuntimeObservedDaemonState, AetheriaRuntimeDaemonCommandEnvelope> submit)
|
||||
{
|
||||
return _observer.SendOperation(submit);
|
||||
return _submit(submit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Eve.Surface;
|
||||
using EveSurfaceState = global::Aetheria.State.Documents.EveSurfaceState;
|
||||
|
||||
#nullable enable
|
||||
|
||||
|
|
@ -14,6 +15,41 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return ToEveSurfaceDocument(document, null);
|
||||
}
|
||||
|
||||
public static EveSurfaceDocument ToEveSurfaceDocument(EveSurfaceState state)
|
||||
{
|
||||
return ToEveSurfaceDocument(state, null);
|
||||
}
|
||||
|
||||
public static EveSurfaceDocument ToEveSurfaceDocument(
|
||||
EveSurfaceState state,
|
||||
Func<string, string>? stateRefResolver)
|
||||
{
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
|
||||
var surface = new EveSurfaceDocument(
|
||||
state.Type,
|
||||
state.Schema,
|
||||
state.ProviderId,
|
||||
state.ProviderKind,
|
||||
state.Title,
|
||||
state.Version,
|
||||
state.UpdatedAtUtc,
|
||||
new EveSurfaceTree(
|
||||
state.Surface.Id,
|
||||
ToEveSurfaceComponent(state.Surface.Root),
|
||||
state.Surface.Styles
|
||||
.Select(style => new GameCult.Eve.Surface.EveStyleToken(style.Name, style.Value))
|
||||
.ToArray()),
|
||||
state.Commands
|
||||
.Select(command => new GameCult.Eve.Surface.EveCommandTemplate(
|
||||
command.Command,
|
||||
command.Label,
|
||||
command.Transport))
|
||||
.ToArray());
|
||||
|
||||
return ResolveStateRefs(surface, stateRefResolver);
|
||||
}
|
||||
|
||||
public static EveSurfaceDocument ToEveSurfaceDocument(
|
||||
AetheriaRuntimeSurfaceDocument document,
|
||||
Func<string, string>? stateRefResolver)
|
||||
|
|
@ -95,6 +131,15 @@ namespace GameCult.Aetheria.State.Verse
|
|||
component.Children.Select(ToEveSurfaceComponent).ToArray());
|
||||
}
|
||||
|
||||
private static EveSurfaceComponent ToEveSurfaceComponent(global::Aetheria.State.Documents.EveSurfaceComponent component)
|
||||
{
|
||||
return new EveSurfaceComponent(
|
||||
component.Id,
|
||||
component.Kind,
|
||||
new Dictionary<string, string>(component.Props, StringComparer.Ordinal),
|
||||
component.Children.Select(ToEveSurfaceComponent).ToArray());
|
||||
}
|
||||
|
||||
private static EveSurfaceComponent ResolveStateRefs(
|
||||
EveSurfaceComponent component,
|
||||
Func<string, string> stateRefResolver)
|
||||
|
|
|
|||
Loading…
Reference in a new issue