Expand Aetheria managed state facade
This commit is contained in:
parent
c64ee03a94
commit
e1d25705e5
4 changed files with 78 additions and 3 deletions
|
|
@ -167,10 +167,15 @@ public class DaemonRuntimeDocumentTests
|
|||
.GetResult();
|
||||
|
||||
var currentEntity = client.Aetheria().Current.Entity.LatestAsync().GetAwaiter().GetResult();
|
||||
var latestFrame = client.Aetheria().LatestFrame.LatestAsync().GetAwaiter().GetResult();
|
||||
var currentEntityByType = client.Aetheria()
|
||||
.LatestAsync<AetheriaRuntimeCurrentEntityDocument>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
var latestFrameByType = client.Aetheria()
|
||||
.LatestAsync<AetheriaRuntimeDaemonFrameDocument>()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
var currentEntityFromClientType = client
|
||||
.LatestAsync<AetheriaRuntimeCurrentEntityDocument>()
|
||||
.GetAwaiter()
|
||||
|
|
@ -186,6 +191,7 @@ public class DaemonRuntimeDocumentTests
|
|||
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.AreSame(client.State.LatestFrame, client.Document<AetheriaRuntimeDaemonFrameDocument>());
|
||||
Assert.AreSame(
|
||||
client.State.Current.Entity,
|
||||
client.State.DocumentBySchema(AetheriaRuntimeDaemonSchemas.CurrentEntity));
|
||||
|
|
@ -202,6 +208,9 @@ public class DaemonRuntimeDocumentTests
|
|||
out var sectorMapBySchema));
|
||||
Assert.AreSame(client.State.SectorMap, sectorMapBySchema);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.CurrentEntity, currentEntity.Schema);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.Frame, latestFrame.Schema);
|
||||
Assert.AreEqual(frame.FrameId, latestFrame.FrameId);
|
||||
Assert.AreEqual(frame.FrameId, latestFrameByType.FrameId);
|
||||
Assert.AreEqual("zone.0.entity.0", currentEntity.EntityKey);
|
||||
Assert.AreEqual(0, currentEntity.EntityIndex);
|
||||
Assert.AreEqual("Player", currentEntity.Entity?.DisplayName);
|
||||
|
|
|
|||
|
|
@ -77,11 +77,20 @@ public class StarbridgePlayerSeatDocumentTests
|
|||
.GetResult();
|
||||
var handle = client.Document<AetheriaRuntimeStarbridgePlayerSeatDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgePlayerSeat(seat.SeatId));
|
||||
var aetheriaSeat = client
|
||||
.Aetheria()
|
||||
.Starbridge
|
||||
.PlayerSeat(seat.SeatId);
|
||||
using var reactive = handle.Reactive();
|
||||
using var aetheriaReactive = aetheriaSeat.Reactive();
|
||||
|
||||
Assert.AreEqual("seat-support", handle.Latest().SeatId);
|
||||
Assert.AreEqual("seat-support", aetheriaSeat.Latest().SeatId);
|
||||
Assert.AreEqual("item:cockpit:support", reactive.Current.CockpitItemKey);
|
||||
Assert.AreEqual("item:cockpit:support", aetheriaReactive.Current.CockpitItemKey);
|
||||
Assert.AreEqual("entity:pod:support", reactive.Current.EscapePodEntityKey);
|
||||
Assert.AreEqual("entity:pod:support", aetheriaReactive.Current.EscapePodEntityKey);
|
||||
Assert.AreEqual("unity-support", reactive.Document.Context.RuntimeId);
|
||||
Assert.AreEqual("unity-support", aetheriaReactive.Document.Context.RuntimeId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,34 +13,55 @@ namespace GameCult.Aetheria.State.Verse
|
|||
private readonly CultMeshDocumentCatalog _documents;
|
||||
|
||||
internal AetheriaClientState(
|
||||
CultMeshDocumentHandle<AetheriaRuntimeDaemonFrameDocument> latestFrame,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeDaemonSoaViewDocument> latestSoaView,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentZoneDocument> currentZone,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentEntityDocument> currentEntity,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> currentDocking,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeZoneContactsDocument> zoneContacts,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStationRefitDocument> stationRefit,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeSectorMapDocument> sectorMap,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeZoneRenderDocument> zoneRender)
|
||||
CultMeshDocumentHandle<AetheriaRuntimeZoneRenderDocument> zoneRender,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStarbridgeScenarioDocument> starbridgeScenario,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStarbridgeSessionDocument> starbridgeSession,
|
||||
Func<string, CultMeshDocumentHandle<AetheriaRuntimeStarbridgePlayerSeatDocument>> starbridgePlayerSeat)
|
||||
{
|
||||
LatestFrame = latestFrame ?? throw new ArgumentNullException(nameof(latestFrame));
|
||||
LatestSoaView = latestSoaView ?? throw new ArgumentNullException(nameof(latestSoaView));
|
||||
Current = new AetheriaClientCurrentState(currentZone, currentEntity, currentDocking);
|
||||
ZoneContacts = zoneContacts ?? throw new ArgumentNullException(nameof(zoneContacts));
|
||||
StationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit));
|
||||
SectorMap = sectorMap ?? throw new ArgumentNullException(nameof(sectorMap));
|
||||
ZoneRender = zoneRender ?? throw new ArgumentNullException(nameof(zoneRender));
|
||||
DockingState = new AetheriaClientDockingState(Current.Entity, Current.Docking, StationRefit);
|
||||
Starbridge = new AetheriaClientStarbridgeState(
|
||||
starbridgeScenario,
|
||||
starbridgeSession,
|
||||
starbridgePlayerSeat);
|
||||
_documents = CultMesh.Documents(
|
||||
LatestFrame,
|
||||
LatestSoaView,
|
||||
Current.Zone,
|
||||
Current.Entity,
|
||||
Current.Docking,
|
||||
ZoneContacts,
|
||||
StationRefit,
|
||||
SectorMap,
|
||||
ZoneRender);
|
||||
ZoneRender,
|
||||
Starbridge.Scenario,
|
||||
Starbridge.Session);
|
||||
}
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeDaemonFrameDocument> LatestFrame { get; }
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeDaemonSoaViewDocument> LatestSoaView { get; }
|
||||
|
||||
public AetheriaClientCurrentState Current { get; }
|
||||
|
||||
public AetheriaClientDockingState DockingState { get; }
|
||||
|
||||
public AetheriaClientStarbridgeState Starbridge { get; }
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeZoneContactsDocument> ZoneContacts { get; }
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeStationRefitDocument> StationRefit { get; }
|
||||
|
|
@ -210,4 +231,30 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
public bool IsDocked => StationRefit?.IsDocked == true && CurrentDockingBay != null;
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientStarbridgeState
|
||||
{
|
||||
private readonly Func<string, CultMeshDocumentHandle<AetheriaRuntimeStarbridgePlayerSeatDocument>> _playerSeat;
|
||||
|
||||
internal AetheriaClientStarbridgeState(
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStarbridgeScenarioDocument> scenario,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStarbridgeSessionDocument> session,
|
||||
Func<string, CultMeshDocumentHandle<AetheriaRuntimeStarbridgePlayerSeatDocument>> playerSeat)
|
||||
{
|
||||
Scenario = scenario ?? throw new ArgumentNullException(nameof(scenario));
|
||||
Session = session ?? throw new ArgumentNullException(nameof(session));
|
||||
_playerSeat = playerSeat ?? throw new ArgumentNullException(nameof(playerSeat));
|
||||
}
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeStarbridgeScenarioDocument> Scenario { get; }
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeStarbridgeSessionDocument> Session { get; }
|
||||
|
||||
public CultMeshDocumentHandle<AetheriaRuntimeStarbridgePlayerSeatDocument> PlayerSeat(string seatId)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(seatId))
|
||||
throw new ArgumentException("Seat id must be non-empty.", nameof(seatId));
|
||||
return _playerSeat(seatId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -727,6 +727,10 @@ namespace GameCult.Aetheria.State.Verse
|
|||
.Select(change => change.Document!);
|
||||
|
||||
return new AetheriaClientState(
|
||||
Document<AetheriaRuntimeDaemonFrameDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest),
|
||||
Document<AetheriaRuntimeDaemonSoaViewDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.DaemonSoaViewLatest),
|
||||
ProjectedDocument(
|
||||
"aetheria.current.zone",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectCurrentZone(frame)),
|
||||
|
|
@ -756,7 +760,13 @@ namespace GameCult.Aetheria.State.Verse
|
|||
ProjectedDocument(
|
||||
"aetheria.zone.render",
|
||||
frame => Task.FromResult(AetheriaRuntimeRtsProjection.ProjectZoneRender(frame)),
|
||||
AetheriaRuntimeDaemonSchemas.ZoneRender));
|
||||
AetheriaRuntimeDaemonSchemas.ZoneRender),
|
||||
Document<AetheriaRuntimeStarbridgeScenarioDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgeScenarioLatest),
|
||||
Document<AetheriaRuntimeStarbridgeSessionDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgeSessionLatest),
|
||||
seatId => Document<AetheriaRuntimeStarbridgePlayerSeatDocument>(
|
||||
AetheriaRuntimeVerseRecordKeys.StarbridgePlayerSeat(seatId)));
|
||||
|
||||
CultMeshDocumentHandle<TDocument> ProjectedDocument<TDocument>(
|
||||
string documentId,
|
||||
|
|
|
|||
Loading…
Reference in a new issue