Add CultMesh reactive document access to Aetheria
This commit is contained in:
parent
ba6af78ab5
commit
e7f379168d
5 changed files with 91 additions and 14 deletions
|
|
@ -175,6 +175,12 @@ public class DaemonRuntimeDocumentTests
|
|||
.LatestAsync<AetheriaRuntimeCurrentEntityDocument>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
using var currentEntityReactive = client
|
||||
.ReactiveAsync<AetheriaRuntimeCurrentEntityDocument>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
using var zoneRenderReactive = client.State
|
||||
.Reactive<AetheriaRuntimeZoneRenderDocument>();
|
||||
var legacyCurrentEntity = client.CurrentEntityAsync().GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual("aetheria.current.entity", client.State.Current.Entity.DocumentId);
|
||||
|
|
@ -198,7 +204,9 @@ public class DaemonRuntimeDocumentTests
|
|||
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("Player", currentEntity.Entity?.DisplayName);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityReactive.Current.EntityKey);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ZoneRender, zoneRenderReactive.Current.Schema);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityByType.EntityKey);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityFromClientType.EntityKey);
|
||||
Assert.AreEqual(legacyCurrentEntity.EntityKey, currentEntity.EntityKey);
|
||||
|
|
@ -232,10 +240,17 @@ public class DaemonRuntimeDocumentTests
|
|||
|
||||
var aetheria = verse.Aetheria();
|
||||
var currentEntity = aetheria.Current.Entity.LatestAsync().GetAwaiter().GetResult();
|
||||
var latestFrameDocument = verse.Document<AetheriaRuntimeDaemonFrameDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest);
|
||||
using var latestFrameReactive = latestFrameDocument.Reactive();
|
||||
|
||||
Assert.AreEqual("aetheria.current.entity", aetheria.Current.Entity.DocumentId);
|
||||
Assert.AreEqual("zone.0.entity.0", currentEntity.EntityKey);
|
||||
Assert.AreEqual("Player", currentEntity.Entity?.Name);
|
||||
Assert.AreEqual("Player", currentEntity.Entity?.DisplayName);
|
||||
Assert.AreEqual(AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString(), latestFrameDocument.DocumentId);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, latestFrameReactive.Current.Schema);
|
||||
Assert.AreEqual(8, latestFrameReactive.Current.FrameId);
|
||||
Assert.IsTrue(latestFrameDocument.CanSet);
|
||||
Assert.IsTrue(aetheria.Current.Entity.Sources.Any(source =>
|
||||
source.SourceId == AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
"CultMath",
|
||||
"Aetheria.Shared.Unity",
|
||||
"GameCult.Aetheria.State.Unity",
|
||||
"GameCult.Caching",
|
||||
"GameCult.Mesh",
|
||||
"GameCult.Eve.Surface"
|
||||
],
|
||||
"includePlatforms": [
|
||||
|
|
|
|||
|
|
@ -74,6 +74,22 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return State.Watch(onNext);
|
||||
}
|
||||
|
||||
public Task<CultMeshReactiveDocument<TDocument>> ReactiveAsync<TDocument>(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
where TDocument : class
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return State.ReactiveAsync<TDocument>(options);
|
||||
}
|
||||
|
||||
public CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
where TDocument : class
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return State.Reactive<TDocument>(options);
|
||||
}
|
||||
|
||||
internal AetheriaRuntimeDaemonOperationsClient Operations => _operations;
|
||||
|
||||
public static async Task<AetheriaClient> OpenAsync(
|
||||
|
|
|
|||
|
|
@ -106,6 +106,20 @@ namespace GameCult.Aetheria.State.Verse
|
|||
if (onNext == null) throw new ArgumentNullException(nameof(onNext));
|
||||
return Document<TDocument>().Watch(onNext);
|
||||
}
|
||||
|
||||
public Task<CultMeshReactiveDocument<TDocument>> ReactiveAsync<TDocument>(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
where TDocument : class
|
||||
{
|
||||
return Document<TDocument>().ReactiveAsync(options);
|
||||
}
|
||||
|
||||
public CultMeshReactiveDocument<TDocument> Reactive<TDocument>(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
where TDocument : class
|
||||
{
|
||||
return Document<TDocument>().Reactive(options);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientCurrentState
|
||||
|
|
|
|||
|
|
@ -365,74 +365,104 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public CultMeshMutableStatePointer<AetheriaRuntimeDaemonProviderAdvertisementDocument> ProviderAdvertisement()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeDaemonProviderAdvertisementDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeDaemonProviderAdvertisementDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonProviderAdvertisement);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<AetheriaRuntimeDaemonHealthDocument> Health()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeDaemonHealthDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeDaemonHealthDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonHealth);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<AetheriaRuntimeDaemonCommandBoundaryDocument> CommandBoundary()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeDaemonCommandBoundaryDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeDaemonCommandBoundaryDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonCommandBoundary);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<AetheriaRuntimeDaemonFrameDocument> LatestFrame()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeDaemonFrameDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeDaemonFrameDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<AetheriaRuntimeDaemonSoaViewDocument> LatestSoaView()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeDaemonSoaViewDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeDaemonSoaViewDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<AetheriaRuntimeStarbridgeScenarioDocument> StarbridgeScenario()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeStarbridgeScenarioDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeStarbridgeScenarioDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgeScenarioLatest);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<AetheriaRuntimeStarbridgeSessionDocument> StarbridgeSession()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<AetheriaRuntimeStarbridgeSessionDocument>(
|
||||
return MutableDocumentPointer<AetheriaRuntimeStarbridgeSessionDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgeSessionLatest);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<EveSurfaceState> DaemonGameSurface()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonGameSurface);
|
||||
return MutableDocumentPointer<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonGameSurface);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<EveSurfaceState> DaemonGameTuiSurface()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonGameTuiSurface);
|
||||
return MutableDocumentPointer<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonGameTuiSurface);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<EveSurfaceState> DaemonEditorSurface()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonEditorSurface);
|
||||
return MutableDocumentPointer<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonEditorSurface);
|
||||
}
|
||||
|
||||
public CultMeshMutableStatePointer<EveSurfaceState> DaemonEditorTuiSurface()
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
return Document<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonEditorTuiSurface);
|
||||
return MutableDocumentPointer<EveSurfaceState>(AetheriaRuntimeVerseRecordKeys.DaemonEditorTuiSurface);
|
||||
}
|
||||
|
||||
public CultMeshDocumentHandle<TDocument> Document<TDocument>(
|
||||
CultRecordKey key,
|
||||
string? documentId = null)
|
||||
where TDocument : class
|
||||
{
|
||||
ThrowIfDisposed();
|
||||
if (string.IsNullOrWhiteSpace(key.Value))
|
||||
throw new ArgumentException("Value must be non-empty.", nameof(key));
|
||||
var descriptor = CultDocumentRegistry.Shared.GetRequired<TDocument>();
|
||||
return CultMesh.Document<TDocument>(
|
||||
Database,
|
||||
key,
|
||||
CultMesh.Verse("aetheria.local", RuntimeId),
|
||||
documentId,
|
||||
new[]
|
||||
{
|
||||
CultMesh.ProjectionSource(key.ToString(), descriptor.SchemaId, "Aetheria Verse database document")
|
||||
},
|
||||
new CultMeshRouteHint(CultMeshLocalityKind.SharedMemory, "Aetheria Verse database"));
|
||||
}
|
||||
|
||||
public Task<CultMeshReactiveDocument<TDocument>> ReactiveDocumentAsync<TDocument>(
|
||||
CultRecordKey key,
|
||||
CultMeshReactiveDocumentOptions? options = null,
|
||||
string? documentId = null)
|
||||
where TDocument : class
|
||||
{
|
||||
return Document<TDocument>(key, documentId).ReactiveAsync(options);
|
||||
}
|
||||
|
||||
public Observable<CultNetDatabaseChange<AetheriaRuntimeDaemonProviderAdvertisementDocument>>
|
||||
|
|
@ -732,7 +762,7 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return frame;
|
||||
}
|
||||
|
||||
private CultMeshMutableStatePointer<T> Document<T>(CultRecordKey key) where T : class
|
||||
private CultMeshMutableStatePointer<T> MutableDocumentPointer<T>(CultRecordKey key) where T : class
|
||||
{
|
||||
return CultMesh.MutableStatePointer(
|
||||
key.ToString(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue