Expose Aetheria domain state from Verse client
This commit is contained in:
parent
2266ae096e
commit
e08c9e9c3c
6 changed files with 143 additions and 80 deletions
|
|
@ -268,7 +268,10 @@ Gates:
|
|||
|
||||
## Stage 3A: Collapse State Access To Typed Reactive Handles
|
||||
|
||||
Status: not started; current Unity and RTS clients still perform byzantine protocol walks.
|
||||
Status: started; `AetheriaRuntimeVerseClient.Aetheria()` now exposes the first
|
||||
C# domain facade for current, station, and zone projected documents, and
|
||||
`AetheriaClient` delegates to that shared facade. Unity and RTS clients still
|
||||
perform byzantine protocol walks in several menus/renderers.
|
||||
|
||||
Goal: every client-facing state access becomes a single CultMesh document, collection, query, or pointer call. The caller names the domain state it wants and gets a typed reactive value. It does not manually inspect daemon frames, current-state projections, station rows, record keys, local facade indexes, or transport route details.
|
||||
|
||||
|
|
|
|||
|
|
@ -534,6 +534,8 @@ $tickRunner = Read-Text "Packages\org.gamecult.aetheria.state\Runtime\AetheriaRu
|
|||
Assert-Contains $tickRunner "ProjectTradeValuePolicySurfaceDocument(stateFilePath)" "Daemon editor surface must publish the trade-value policy designer surface."
|
||||
|
||||
$client = Read-Text "Packages\org.gamecult.aetheria.state\Runtime\AetheriaClient.cs"
|
||||
Assert-Contains $client "AetheriaClientState State" "AetheriaClient must expose the semantic typed state facade."
|
||||
Assert-Contains $client "Aetheria()" "AetheriaClient must expose the canonical domain facade entrypoint."
|
||||
Assert-Contains $client "ObjectsViewportAsync" "AetheriaClient must expose objects viewport facade."
|
||||
Assert-Contains $client "GravityViewportAsync" "AetheriaClient must expose gravity viewport facade."
|
||||
Assert-Contains $client "CurrentZoneAsync" "AetheriaClient must expose current-zone facade."
|
||||
|
|
@ -545,6 +547,15 @@ Assert-Contains $client "SectorMapAsync" "AetheriaClient must expose sector-map
|
|||
Assert-Contains $client "ZoneDetailsAsync" "AetheriaClient must expose zone-details facade."
|
||||
Assert-Contains $client "ZoneRenderAsync" "AetheriaClient must expose zone-render facade."
|
||||
|
||||
$verseClient = Read-Text "Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeVerseClient.cs"
|
||||
Assert-Contains $verseClient "AetheriaClientState Aetheria()" "AetheriaRuntimeVerseClient must expose the shared domain state facade."
|
||||
Assert-Contains $verseClient "CreateAetheriaStateFacade" "AetheriaRuntimeVerseClient must own projected state facade creation."
|
||||
|
||||
$clientState = Read-Text "Packages\org.gamecult.aetheria.state\Runtime\AetheriaClientState.cs"
|
||||
Assert-Contains $clientState "CultMeshBoundLiveFeed" "Aetheria state documents must bind through CultMesh live feeds."
|
||||
Assert-Contains $clientState "LatestAsync()" "Aetheria state documents must support one-shot typed reads."
|
||||
Assert-Contains $clientState "Watch()" "Aetheria state documents must support reactive typed reads."
|
||||
|
||||
$projection = Read-Text "Packages\org.gamecult.aetheria.state\Runtime\AetheriaRuntimeRtsProjection.cs"
|
||||
Assert-Contains $projection "ProjectZoneDetails" "Shared projection code must own the zone-details feed."
|
||||
Assert-Contains $projection "ProjectZoneContacts" "Shared projection code must own the zone-contacts feed."
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ public class DaemonRuntimeDocumentTests
|
|||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
var currentEntity = client.State.Current.Entity.LatestAsync().GetAwaiter().GetResult();
|
||||
var currentEntity = client.Aetheria().Current.Entity.LatestAsync().GetAwaiter().GetResult();
|
||||
var legacyCurrentEntity = client.CurrentEntityAsync().GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual("aetheria.current.entity", client.State.Current.Entity.DocumentId);
|
||||
|
|
@ -181,6 +181,38 @@ public class DaemonRuntimeDocumentTests
|
|||
source.SourceId == "catalog:aetheria.runtime"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AetheriaRuntimeVerseClientExposesDomainStateFacade()
|
||||
{
|
||||
var statePath = Path.Combine(
|
||||
Path.GetTempPath(),
|
||||
"aetheria-verse-domain-state-facade-tests",
|
||||
Path.GetRandomFileName(),
|
||||
"state.cc");
|
||||
var frame = AetheriaRuntimeDaemonFrameDocument.Create(
|
||||
RunWithTwoEntities(),
|
||||
"daemon",
|
||||
"session-state",
|
||||
8,
|
||||
1.5,
|
||||
0.02);
|
||||
PublishLatestFrameThroughVerseClient(statePath, frame);
|
||||
|
||||
using var verse = AetheriaRuntimeVerseClient
|
||||
.OpenAsync(statePath, "tool-test", pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
|
||||
var aetheria = verse.Aetheria();
|
||||
var currentEntity = aetheria.Current.Entity.LatestAsync().GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual("aetheria.current.entity", aetheria.Current.Entity.DocumentId);
|
||||
Assert.AreEqual("zone.0.entity.0", currentEntity.EntityKey);
|
||||
Assert.AreEqual("Player", currentEntity.Entity?.Name);
|
||||
Assert.IsTrue(aetheria.Current.Entity.Sources.Any(source =>
|
||||
source.SourceId == AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TickRunnerAppliesObservedCommandsAndPublishesFrame()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using R3;
|
||||
|
||||
#nullable enable
|
||||
|
||||
|
|
@ -29,7 +28,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
_operations = new AetheriaRuntimeDaemonOperationsClient(SendOperation);
|
||||
_control = new AetheriaControl(_operations);
|
||||
_ui = new AetheriaUi(this);
|
||||
_state = CreateStateFacade();
|
||||
_state = _verse.Aetheria();
|
||||
}
|
||||
|
||||
public string StatePath => _verse.StatePath;
|
||||
|
|
@ -38,6 +37,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public AetheriaUi Ui => _ui;
|
||||
public AetheriaClientState State => _state;
|
||||
|
||||
public AetheriaClientState Aetheria() => State;
|
||||
|
||||
internal AetheriaRuntimeDaemonOperationsClient Operations => _operations;
|
||||
|
||||
public static async Task<AetheriaClient> OpenAsync(
|
||||
|
|
@ -385,79 +386,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return frame;
|
||||
}
|
||||
|
||||
private AetheriaClientState CreateStateFacade()
|
||||
{
|
||||
var frameChanges = _verse.WatchLatestFrames()
|
||||
.Where(change => change.Document != null)
|
||||
.Select(change => change.Document!);
|
||||
|
||||
return new AetheriaClientState(
|
||||
ProjectedDocument(
|
||||
"aetheria.current.zone",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentZone(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.CurrentZone),
|
||||
ProjectedDocument(
|
||||
"aetheria.current.entity",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentEntity(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.CurrentEntity),
|
||||
ProjectedDocument(
|
||||
"aetheria.current.docking",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentDocking(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.CurrentDocking),
|
||||
ProjectedDocument(
|
||||
"aetheria.zone.contacts",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectZoneContacts(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.ZoneContacts),
|
||||
ProjectedDocument(
|
||||
"aetheria.station.refit",
|
||||
ProjectStationRefitAsync,
|
||||
AetheriaRuntimeDaemonSchemas.StationRefit,
|
||||
CultMesh.ProjectionSource("catalog:aetheria.runtime"),
|
||||
CultMesh.ProjectionSource("loadout-templates:aetheria.runtime")),
|
||||
ProjectedDocument(
|
||||
"aetheria.sector.map",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectSectorMap(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.SectorMap),
|
||||
ProjectedDocument(
|
||||
"aetheria.zone.render",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectZoneRender(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.ZoneRender));
|
||||
|
||||
AetheriaRuntimeProjectedDocument<TDocument> ProjectedDocument<TDocument>(
|
||||
string documentId,
|
||||
Func<AetheriaRuntimeDaemonFrameDocument, Task<TDocument>> project,
|
||||
string schemaId,
|
||||
params CultMeshProjectionSource[] additionalSources)
|
||||
{
|
||||
var sources = new[]
|
||||
{
|
||||
CultMesh.ProjectionSource(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(),
|
||||
AetheriaRuntimeDaemonSchemas.Frame,
|
||||
"latest authoritative daemon frame")
|
||||
}
|
||||
.Concat(additionalSources ?? Array.Empty<CultMeshProjectionSource>())
|
||||
.Append(CultMesh.ProjectionSource(documentId, schemaId, "projected Aetheria client document"))
|
||||
.ToArray();
|
||||
|
||||
return AetheriaRuntimeProjectedDocument<TDocument>.Create(
|
||||
documentId,
|
||||
RuntimeId,
|
||||
async () => await project(await RequireFrameAsync().ConfigureAwait(false)).ConfigureAwait(false),
|
||||
frameChanges,
|
||||
project,
|
||||
sources);
|
||||
}
|
||||
|
||||
async Task<AetheriaRuntimeStationRefitDocument> ProjectStationRefitAsync(
|
||||
AetheriaRuntimeDaemonFrameDocument frame)
|
||||
{
|
||||
var loadoutTemplates = await _verse.GetLoadoutTemplatesAsync().ConfigureAwait(false);
|
||||
var catalog = _verse.OpenRuntimeCatalog();
|
||||
return AetheriaRuntimeRtsProjection.ProjectStationRefit(frame, loadoutTemplates, catalog);
|
||||
}
|
||||
}
|
||||
|
||||
private void ThrowIfDisposed()
|
||||
{
|
||||
if (_disposed)
|
||||
|
|
|
|||
|
|
@ -280,6 +280,12 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return AetheriaRuntimeCatalogStore.OpenReadOnly(StatePath);
|
||||
}
|
||||
|
||||
public AetheriaClientState Aetheria()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return CreateAetheriaStateFacade();
|
||||
}
|
||||
|
||||
public Task<AetheriaRuntimePlayerSettingsSnapshot?> GetPlayerSettingsAsync()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
|
|
@ -700,6 +706,87 @@ namespace GameCult.Aetheria.State.Verse
|
|||
throw new ObjectDisposedException(nameof(AetheriaRuntimeVerseClient));
|
||||
}
|
||||
|
||||
private AetheriaClientState CreateAetheriaStateFacade()
|
||||
{
|
||||
var frameChanges = WatchLatestFrames()
|
||||
.Where(change => change.Document != null)
|
||||
.Select(change => change.Document!);
|
||||
|
||||
return new AetheriaClientState(
|
||||
ProjectedDocument(
|
||||
"aetheria.current.zone",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentZone(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.CurrentZone),
|
||||
ProjectedDocument(
|
||||
"aetheria.current.entity",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentEntity(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.CurrentEntity),
|
||||
ProjectedDocument(
|
||||
"aetheria.current.docking",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentDocking(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.CurrentDocking),
|
||||
ProjectedDocument(
|
||||
"aetheria.zone.contacts",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectZoneContacts(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.ZoneContacts),
|
||||
ProjectedDocument(
|
||||
"aetheria.station.refit",
|
||||
ProjectStationRefitAsync,
|
||||
AetheriaRuntimeDaemonSchemas.StationRefit,
|
||||
CultMesh.ProjectionSource("catalog:aetheria.runtime"),
|
||||
CultMesh.ProjectionSource("loadout-templates:aetheria.runtime")),
|
||||
ProjectedDocument(
|
||||
"aetheria.sector.map",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectSectorMap(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.SectorMap),
|
||||
ProjectedDocument(
|
||||
"aetheria.zone.render",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectZoneRender(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.ZoneRender));
|
||||
|
||||
AetheriaRuntimeProjectedDocument<TDocument> ProjectedDocument<TDocument>(
|
||||
string documentId,
|
||||
Func<AetheriaRuntimeDaemonFrameDocument, Task<TDocument>> project,
|
||||
string schemaId,
|
||||
params CultMeshProjectionSource[] additionalSources)
|
||||
{
|
||||
var sources = new[]
|
||||
{
|
||||
CultMesh.ProjectionSource(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(),
|
||||
AetheriaRuntimeDaemonSchemas.Frame,
|
||||
"latest authoritative daemon frame")
|
||||
}
|
||||
.Concat(additionalSources ?? Array.Empty<CultMeshProjectionSource>())
|
||||
.Append(CultMesh.ProjectionSource(documentId, schemaId, "projected Aetheria client document"))
|
||||
.ToArray();
|
||||
|
||||
return AetheriaRuntimeProjectedDocument<TDocument>.Create(
|
||||
documentId,
|
||||
RuntimeId,
|
||||
async () => await project(await RequireFrameAsync().ConfigureAwait(false)).ConfigureAwait(false),
|
||||
frameChanges,
|
||||
project,
|
||||
sources);
|
||||
}
|
||||
|
||||
async Task<AetheriaRuntimeStationRefitDocument> ProjectStationRefitAsync(
|
||||
AetheriaRuntimeDaemonFrameDocument frame)
|
||||
{
|
||||
var loadoutTemplates = await GetLoadoutTemplatesAsync().ConfigureAwait(false);
|
||||
var catalog = OpenRuntimeCatalog();
|
||||
return AetheriaRuntimeRtsProjection.ProjectStationRefit(frame, loadoutTemplates, catalog);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<AetheriaRuntimeDaemonFrameDocument> RequireFrameAsync()
|
||||
{
|
||||
var frame = await GetLatestFrameAsync().ConfigureAwait(false);
|
||||
if (frame == null)
|
||||
throw new InvalidOperationException("Aetheria Verse client has no daemon frame yet.");
|
||||
return frame;
|
||||
}
|
||||
|
||||
private CultMeshMutableStatePointer<T> Document<T>(CultRecordKey key) where T : class
|
||||
{
|
||||
return CultMesh.MutableStatePointer(
|
||||
|
|
|
|||
|
|
@ -52,7 +52,8 @@ menus, HUDs, renderers, RTS panels, and tools should move toward semantic
|
|||
handles:
|
||||
|
||||
```csharp
|
||||
var aetheria = client.Aetheria();
|
||||
using var verse = await AetheriaRuntimeVerseClient.OpenAsync(statePath, "tool-client");
|
||||
var aetheria = verse.Aetheria();
|
||||
|
||||
using var inventory = aetheria.Current.Inventory.Watch(RenderInventory);
|
||||
using var docking = aetheria.Current.Docking.Watch(RenderDocking);
|
||||
|
|
@ -96,8 +97,9 @@ The alternative idea of "Unity runs CultMesh using the same state assembly, but
|
|||
not the daemon assembly" is exactly what this contract supports. The Unity side
|
||||
references the runtime state package, opens `AetheriaRuntimeVerseClient`, and
|
||||
uses CultMesh reactive wrappers to observe daemon state as if it were native
|
||||
state. The client document handles now delegate to shared CultMesh mutable state
|
||||
pointers instead of a private Aetheria wrapper.
|
||||
state. `AetheriaRuntimeVerseClient.Aetheria()` now exposes the first shared C#
|
||||
domain facade for projected current/station/zone documents, and `AetheriaClient`
|
||||
delegates to that same facade instead of owning a private projection wrapper.
|
||||
|
||||
## Eve Surface Boundary
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue