Add typed document lookup to Aetheria state facade
This commit is contained in:
parent
69327bbe19
commit
0196b9bca0
5 changed files with 115 additions and 5 deletions
|
|
@ -269,9 +269,14 @@ Gates:
|
|||
## Stage 3A: Collapse State Access To Typed Reactive Handles
|
||||
|
||||
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.
|
||||
C# domain facade for current, station, and zone projected documents,
|
||||
`AetheriaClient` delegates to that shared facade, and the broad Unity
|
||||
menu/HUD/map/render projected-state reads now use typed state handles instead
|
||||
of transitional `Current*Async()`, `StationRefitAsync()`, `SectorMapAsync()`,
|
||||
`ZoneContactsAsync()`, or `ZoneRenderAsync()` helpers. `AetheriaClientState`
|
||||
also indexes projected state documents by shared document type so callers can
|
||||
retrieve or watch a known typed document with one call while CultMesh owns the
|
||||
bound live feed.
|
||||
|
||||
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.
|
||||
|
||||
|
|
@ -303,6 +308,12 @@ var refit = await client.Aetheria()
|
|||
.Station
|
||||
.Refit
|
||||
.LatestAsync();
|
||||
|
||||
var contacts = await client.Aetheria()
|
||||
.LatestAsync<AetheriaRuntimeZoneContactsDocument>();
|
||||
|
||||
using var render = client
|
||||
.Watch<AetheriaRuntimeZoneRenderDocument>(RenderZone);
|
||||
```
|
||||
|
||||
Desired TS shape:
|
||||
|
|
@ -322,10 +333,10 @@ const refit = await client.aetheria()
|
|||
|
||||
Work:
|
||||
|
||||
- Add shared CultMesh typed reactive document and collection handles if the existing state-pointer/query primitives are not enough.
|
||||
- Keep pushing shared CultMesh typed reactive document and collection handles down until type/schema lookup is owned by CultMesh rather than by the Aetheria facade registry.
|
||||
- Generate Aetheria current/station/zone/catalog accessors from schema metadata.
|
||||
- Move derived-state joins, such as current docking bay from current docking plus station refit plus entity records, into generated/internal query executors.
|
||||
- Replace Unity menu/HUD/render calls to `Current*Async()`, `StationRefitAsync()`, `TryResolve*`, and `_observedFacadeIndex` with typed handles.
|
||||
- Replace remaining Unity menu/HUD/render calls to `TryResolve*` and `_observedFacadeIndex` with typed handles or generated/internal render adapters.
|
||||
- Replace blocking `GetAwaiter().GetResult()` reads in client presentation code with watch/latest handles that own lifetimes.
|
||||
- Keep renderer-local facade indexes only inside render adapter internals while native/query views are still being migrated.
|
||||
- Add verifiers that treat multi-hop state reads in client code as failures.
|
||||
|
|
@ -333,6 +344,7 @@ Work:
|
|||
Gates:
|
||||
|
||||
- `InventoryMenu`, `InventoryPanel`, `TradeMenu`, `LocalMenu`, `SchematicDisplay`, `SectorRenderer`, `MapRenderer`, and `ZoneRenderer` do not manually join state projections to obtain domain values.
|
||||
- Shared projected documents are reachable through `client.Aetheria().Document<TDocument>()`, `client.Aetheria().LatestAsync<TDocument>()`, and `client.Watch<TDocument>()` as the C# stepping stone toward CultMesh-native type/schema lookup.
|
||||
- Client-facing code contains no `_observedFacadeIndex.TryResolve*` outside Unity render adapter internals.
|
||||
- Client-facing code contains no `ResolveClient().Current*Async().GetAwaiter().GetResult()` or equivalent blocking state reads.
|
||||
- `TryGetTypedCurrentDockingBayFacade` and similar transitional helpers are deleted rather than renamed.
|
||||
|
|
|
|||
|
|
@ -576,6 +576,9 @@ Assert-Contains $tickRunner "ProjectTradeValuePolicySurfaceDocument(stateFilePat
|
|||
$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 "Document<TDocument>()" "AetheriaClient must allow callers to retrieve a projected state document by shared document type."
|
||||
Assert-Contains $client "LatestAsync<TDocument>()" "AetheriaClient must allow one-call typed state reads by shared document type."
|
||||
Assert-Contains $client "Watch<TDocument>()" "AetheriaClient must allow reactive typed state reads by shared document type."
|
||||
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."
|
||||
|
|
@ -593,6 +596,11 @@ Assert-Contains $verseClient "CreateAetheriaStateFacade" "AetheriaRuntimeVerseCl
|
|||
|
||||
$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 "_documentsByType" "Aetheria state facade must index projected documents by shared document type."
|
||||
Assert-Contains $clientState "TryGetDocument<TDocument>" "Aetheria state facade must support safe typed document lookup."
|
||||
Assert-Contains $clientState "Document<TDocument>()" "Aetheria state facade must support direct typed document lookup."
|
||||
Assert-Contains $clientState "LatestAsync<TDocument>()" "Aetheria state facade must support one-call typed document reads."
|
||||
Assert-Contains $clientState "Watch<TDocument>()" "Aetheria state facade must support reactive typed document lookup."
|
||||
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."
|
||||
|
||||
|
|
|
|||
|
|
@ -167,13 +167,27 @@ public class DaemonRuntimeDocumentTests
|
|||
.GetResult();
|
||||
|
||||
var currentEntity = client.Aetheria().Current.Entity.LatestAsync().GetAwaiter().GetResult();
|
||||
var currentEntityByType = client.Aetheria()
|
||||
.LatestAsync<AetheriaRuntimeCurrentEntityDocument>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
var currentEntityFromClientType = client
|
||||
.LatestAsync<AetheriaRuntimeCurrentEntityDocument>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
var legacyCurrentEntity = client.CurrentEntityAsync().GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual("aetheria.current.entity", client.State.Current.Entity.DocumentId);
|
||||
Assert.AreSame(client.State.Current.Entity, client.State.Document<AetheriaRuntimeCurrentEntityDocument>());
|
||||
Assert.AreSame(client.State.ZoneRender, client.Document<AetheriaRuntimeZoneRenderDocument>());
|
||||
Assert.IsTrue(client.State.TryGetDocument<AetheriaRuntimeSectorMapDocument>(out var sectorMapDocument));
|
||||
Assert.AreSame(client.State.SectorMap, sectorMapDocument);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.CurrentEntity, currentEntity.Schema);
|
||||
Assert.AreEqual("zone.0.entity.0", currentEntity.EntityKey);
|
||||
Assert.AreEqual(0, currentEntity.EntityIndex);
|
||||
Assert.AreEqual("Player", currentEntity.Entity?.Name);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityByType.EntityKey);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityFromClientType.EntityKey);
|
||||
Assert.AreEqual(legacyCurrentEntity.EntityKey, currentEntity.EntityKey);
|
||||
Assert.IsTrue(client.State.Current.Entity.Sources.Any(source =>
|
||||
source.SourceId == AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()));
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Linq;
|
|||
using System.Threading.Tasks;
|
||||
using GameCult.Eve.Surface;
|
||||
using GameCult.Mesh;
|
||||
using R3;
|
||||
|
||||
#nullable enable
|
||||
|
||||
|
|
@ -39,6 +40,30 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
public AetheriaClientState Aetheria() => State;
|
||||
|
||||
public AetheriaRuntimeProjectedDocument<TDocument> Document<TDocument>()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return State.Document<TDocument>();
|
||||
}
|
||||
|
||||
public Task<TDocument> LatestAsync<TDocument>()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return State.LatestAsync<TDocument>();
|
||||
}
|
||||
|
||||
public Observable<TDocument> Watch<TDocument>()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return State.Watch<TDocument>();
|
||||
}
|
||||
|
||||
public IDisposable Watch<TDocument>(Action<TDocument> onNext)
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return State.Watch(onNext);
|
||||
}
|
||||
|
||||
internal AetheriaRuntimeDaemonOperationsClient Operations => _operations;
|
||||
|
||||
public static async Task<AetheriaClient> OpenAsync(
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using GameCult.Mesh;
|
||||
using R3;
|
||||
|
|
@ -81,6 +82,8 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
public sealed class AetheriaClientState
|
||||
{
|
||||
private readonly IReadOnlyDictionary<Type, object> _documentsByType;
|
||||
|
||||
internal AetheriaClientState(
|
||||
AetheriaRuntimeProjectedDocument<AetheriaRuntimeCurrentZoneDocument> currentZone,
|
||||
AetheriaRuntimeProjectedDocument<AetheriaRuntimeCurrentEntityDocument> currentEntity,
|
||||
|
|
@ -95,6 +98,16 @@ namespace GameCult.Aetheria.State.Verse
|
|||
StationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit));
|
||||
SectorMap = sectorMap ?? throw new ArgumentNullException(nameof(sectorMap));
|
||||
ZoneRender = zoneRender ?? throw new ArgumentNullException(nameof(zoneRender));
|
||||
_documentsByType = new Dictionary<Type, object>
|
||||
{
|
||||
[typeof(AetheriaRuntimeCurrentZoneDocument)] = Current.Zone,
|
||||
[typeof(AetheriaRuntimeCurrentEntityDocument)] = Current.Entity,
|
||||
[typeof(AetheriaRuntimeCurrentDockingDocument)] = Current.Docking,
|
||||
[typeof(AetheriaRuntimeZoneContactsDocument)] = ZoneContacts,
|
||||
[typeof(AetheriaRuntimeStationRefitDocument)] = StationRefit,
|
||||
[typeof(AetheriaRuntimeSectorMapDocument)] = SectorMap,
|
||||
[typeof(AetheriaRuntimeZoneRenderDocument)] = ZoneRender
|
||||
};
|
||||
}
|
||||
|
||||
public AetheriaClientCurrentState Current { get; }
|
||||
|
|
@ -106,6 +119,44 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public AetheriaRuntimeProjectedDocument<AetheriaRuntimeSectorMapDocument> SectorMap { get; }
|
||||
|
||||
public AetheriaRuntimeProjectedDocument<AetheriaRuntimeZoneRenderDocument> ZoneRender { get; }
|
||||
|
||||
public bool TryGetDocument<TDocument>(
|
||||
out AetheriaRuntimeProjectedDocument<TDocument> document)
|
||||
{
|
||||
if (_documentsByType.TryGetValue(typeof(TDocument), out var untypedDocument) &&
|
||||
untypedDocument is AetheriaRuntimeProjectedDocument<TDocument> typedDocument)
|
||||
{
|
||||
document = typedDocument;
|
||||
return true;
|
||||
}
|
||||
|
||||
document = null!;
|
||||
return false;
|
||||
}
|
||||
|
||||
public AetheriaRuntimeProjectedDocument<TDocument> Document<TDocument>()
|
||||
{
|
||||
if (TryGetDocument<TDocument>(out var document))
|
||||
return document;
|
||||
|
||||
throw new NotSupportedException(
|
||||
$"Aetheria typed state does not expose a projected document for {typeof(TDocument).FullName}.");
|
||||
}
|
||||
|
||||
public Task<TDocument> LatestAsync<TDocument>()
|
||||
{
|
||||
return Document<TDocument>().LatestAsync();
|
||||
}
|
||||
|
||||
public Observable<TDocument> Watch<TDocument>()
|
||||
{
|
||||
return Document<TDocument>().Watch();
|
||||
}
|
||||
|
||||
public IDisposable Watch<TDocument>(Action<TDocument> onNext)
|
||||
{
|
||||
return Document<TDocument>().Watch(onNext);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientCurrentState
|
||||
|
|
|
|||
Loading…
Reference in a new issue