Expand Aetheria managed state facade
This commit is contained in:
parent
c64ee03a94
commit
e1d25705e5
4 changed files with 78 additions and 3 deletions
|
|
@ -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