Remove aggregate docking state wrapper
This commit is contained in:
parent
6cf8538239
commit
a8f35a8f95
3 changed files with 36 additions and 215 deletions
|
|
@ -7022,15 +7022,11 @@ static void RequireMenuDockingUsesManagedTypedSnapshot(string root)
|
|||
var clientState = File.ReadAllText(clientStatePath);
|
||||
var requiredClientSymbols = new[]
|
||||
{
|
||||
"public AetheriaClientDockingSnapshot LatestDockingState()",
|
||||
"public AetheriaClientReactiveDockingState ReactiveDockingState(",
|
||||
"public AetheriaClientReactiveDockingState Reactive(",
|
||||
"public sealed class AetheriaClientReactiveDockingState : IDisposable",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeCurrentEntityDocument>",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeCurrentDockingDocument>",
|
||||
"CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument>",
|
||||
"public AetheriaClientDockingSnapshot Current =>",
|
||||
"public bool TryCurrent(out AetheriaClientDockingSnapshot"
|
||||
"public AetheriaClientCurrentState Current { get; }",
|
||||
"public CultMeshDocumentHandle<AetheriaRuntimeStationRefitDocument> StationRefit { get; }",
|
||||
"public CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> Docking { get; }",
|
||||
"public CultMeshReactiveDocument<AetheriaRuntimeCurrentDockingDocument> ReactiveDocking(",
|
||||
"public CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument> ReactiveStationRefit("
|
||||
};
|
||||
var missingClientSymbols = requiredClientSymbols
|
||||
.Where(symbol => !clientState.Contains(symbol, StringComparison.Ordinal))
|
||||
|
|
@ -7038,10 +7034,28 @@ static void RequireMenuDockingUsesManagedTypedSnapshot(string root)
|
|||
if (missingClientSymbols.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaClientDockingState must expose a managed reactive typed docking snapshot for Unity menu surfaces: " +
|
||||
"AetheriaClientState must expose managed typed docking documents directly for Unity menu surfaces: " +
|
||||
string.Join(", ", missingClientSymbols));
|
||||
}
|
||||
|
||||
var forbiddenClientSymbols = new[]
|
||||
{
|
||||
"AetheriaClientDockingState",
|
||||
"AetheriaClientDockingSnapshot",
|
||||
"AetheriaClientReactiveDockingState",
|
||||
"LatestDockingState",
|
||||
"ReactiveDockingState"
|
||||
};
|
||||
var forbiddenClientHits = forbiddenClientSymbols
|
||||
.Where(symbol => clientState.Contains(symbol, StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
if (forbiddenClientHits.Length > 0)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"AetheriaClientState still exposes aggregate docking snapshot wrappers instead of direct managed typed documents: " +
|
||||
string.Join(", ", forbiddenClientHits));
|
||||
}
|
||||
|
||||
var menuPaths = new[]
|
||||
{
|
||||
Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryMenu.cs"),
|
||||
|
|
@ -7703,8 +7717,6 @@ static void RequireAetheriaManagedStateAccessorsCoverDomainDocuments(string root
|
|||
"public CultMeshReactiveDocument<AetheriaRuntimeDaemonFrameDocument> ReactiveDaemonFrame(",
|
||||
"public AetheriaRuntimeDaemonSoaViewDocument LatestDaemonSoaView()",
|
||||
"public CultMeshReactiveDocument<AetheriaRuntimeDaemonSoaViewDocument> ReactiveDaemonSoaView(",
|
||||
"public AetheriaClientDockingSnapshot LatestDockingState()",
|
||||
"public AetheriaClientReactiveDockingState ReactiveDockingState(",
|
||||
"public AetheriaRuntimeObservedDaemonState? LatestObservedDaemon()",
|
||||
"public AetheriaRuntimeLoadoutTemplatesDocument LatestLoadoutTemplates()",
|
||||
"public AetheriaRuntimeStationRefitDocument LatestStationRefit()",
|
||||
|
|
|
|||
|
|
@ -210,8 +210,13 @@ public class DaemonRuntimeDocumentTests
|
|||
var editorSurface = client.State.LatestEditorSurface();
|
||||
var editorTuiSurface = client.State.LatestEditorTuiSurface();
|
||||
var authorityStatus = client.State.LatestAuthorityPolicy();
|
||||
var dockingState = client.State.LatestDockingState();
|
||||
using var reactiveDockingState = client.State.ReactiveDockingState();
|
||||
var currentDocking = client.State.Current.Docking
|
||||
.LatestAsync()
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
var stationRefit = client.State.LatestStationRefit();
|
||||
using var reactiveCurrentDocking = client.State.Current.ReactiveDocking();
|
||||
using var reactiveStationRefit = client.State.ReactiveStationRefit();
|
||||
using var reactiveGameSurface = client.State.ReactiveGameSurface();
|
||||
using var reactiveGameTuiSurface = client.State.ReactiveGameTuiSurface();
|
||||
using var reactiveEditorSurface = client.State.ReactiveEditorSurface();
|
||||
|
|
@ -287,10 +292,11 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.AreEqual(AetheriaRuntimeDaemonSchemas.ZoneRender, zoneRenderReactive.Current.Schema);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityByType.EntityKey);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentEntityFromClientType.EntityKey);
|
||||
Assert.AreEqual(currentEntity.EntityKey, dockingState.CurrentEntityKey);
|
||||
Assert.AreEqual(currentEntity.EntityKey, reactiveDockingState.Current.CurrentEntityKey);
|
||||
Assert.AreEqual("", dockingState.DockParentEntityKey);
|
||||
Assert.AreEqual(-1, dockingState.DockingBayIndex);
|
||||
Assert.AreEqual(currentEntity.EntityKey, currentDocking.CurrentEntityKey);
|
||||
Assert.AreEqual(currentEntity.EntityKey, reactiveCurrentDocking.Current.CurrentEntityKey);
|
||||
Assert.AreEqual("", stationRefit.DockParentEntityKey);
|
||||
Assert.AreEqual("", reactiveStationRefit.Current.DockParentEntityKey);
|
||||
Assert.AreEqual(-1, stationRefit.DockingBayIndex);
|
||||
Assert.IsTrue(client.State.Current.Entity.Sources.Any(source =>
|
||||
source.SourceId == AetheriaRuntimeVerseRecordKeys.DaemonFrameLatest.ToString()));
|
||||
Assert.IsTrue(client.State.StationRefit.Sources.Any(source =>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
zoneDetails,
|
||||
selectedObject,
|
||||
inventory);
|
||||
DockingState = new AetheriaClientDockingState(Current.Entity, Current.Docking, StationRefit);
|
||||
Starbridge = new AetheriaClientStarbridgeState(
|
||||
starbridgeScenario,
|
||||
starbridgeSession,
|
||||
|
|
@ -124,8 +123,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
|
||||
public AetheriaClientCurrentState Current { get; }
|
||||
|
||||
public AetheriaClientDockingState DockingState { get; }
|
||||
|
||||
public AetheriaClientViewportState Viewports { get; }
|
||||
|
||||
public AetheriaClientDetailState Details { get; }
|
||||
|
|
@ -246,28 +243,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
return LatestSoaView.Reactive(options);
|
||||
}
|
||||
|
||||
public Task<AetheriaClientDockingSnapshot> LatestDockingStateAsync()
|
||||
{
|
||||
return DockingState.LatestAsync();
|
||||
}
|
||||
|
||||
public AetheriaClientDockingSnapshot LatestDockingState()
|
||||
{
|
||||
return LatestDockingStateAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public Task<AetheriaClientReactiveDockingState> ReactiveDockingStateAsync(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
{
|
||||
return DockingState.ReactiveAsync(options);
|
||||
}
|
||||
|
||||
public AetheriaClientReactiveDockingState ReactiveDockingState(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
{
|
||||
return ReactiveDockingStateAsync(options).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public async Task<AetheriaRuntimeObservedDaemonState?> LatestObservedDaemonAsync()
|
||||
{
|
||||
var frame = await LatestDaemonFrameAsync().ConfigureAwait(false);
|
||||
|
|
@ -916,178 +891,6 @@ namespace GameCult.Aetheria.State.Verse
|
|||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientDockingState
|
||||
{
|
||||
private readonly CultMeshDocumentHandle<AetheriaRuntimeCurrentEntityDocument> _currentEntity;
|
||||
private readonly CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> _currentDocking;
|
||||
private readonly CultMeshDocumentHandle<AetheriaRuntimeStationRefitDocument> _stationRefit;
|
||||
|
||||
internal AetheriaClientDockingState(
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentEntityDocument> currentEntity,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> currentDocking,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStationRefitDocument> stationRefit)
|
||||
{
|
||||
_currentEntity = currentEntity ?? throw new ArgumentNullException(nameof(currentEntity));
|
||||
_currentDocking = currentDocking ?? throw new ArgumentNullException(nameof(currentDocking));
|
||||
_stationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit));
|
||||
}
|
||||
|
||||
public Task<AetheriaClientDockingSnapshot> LatestAsync()
|
||||
{
|
||||
return CultMesh.LatestAsync(
|
||||
_currentEntity,
|
||||
_currentDocking,
|
||||
_stationRefit,
|
||||
CreateSnapshot);
|
||||
}
|
||||
|
||||
public AetheriaClientDockingSnapshot Latest()
|
||||
{
|
||||
return LatestAsync().ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
public bool TryLatest(out AetheriaClientDockingSnapshot? snapshot)
|
||||
{
|
||||
snapshot = null;
|
||||
try
|
||||
{
|
||||
snapshot = Latest();
|
||||
return snapshot != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<AetheriaClientReactiveDockingState> ReactiveAsync(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
{
|
||||
return AetheriaClientReactiveDockingState.CreateAsync(
|
||||
_currentEntity,
|
||||
_currentDocking,
|
||||
_stationRefit,
|
||||
options);
|
||||
}
|
||||
|
||||
public AetheriaClientReactiveDockingState Reactive(
|
||||
CultMeshReactiveDocumentOptions? options = null)
|
||||
{
|
||||
return ReactiveAsync(options).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private static AetheriaClientDockingSnapshot CreateSnapshot(
|
||||
AetheriaRuntimeCurrentEntityDocument? entity,
|
||||
AetheriaRuntimeCurrentDockingDocument? docking,
|
||||
AetheriaRuntimeStationRefitDocument? refit)
|
||||
{
|
||||
var dockingBay = refit?.IsDocked == true && refit.DockingBayIndex >= 0
|
||||
? (refit.DockingBays ?? Array.Empty<AetheriaRuntimeStationDockingBayRow>())
|
||||
.FirstOrDefault(row => row != null && row.DockingBayIndex == refit.DockingBayIndex)
|
||||
: null;
|
||||
return new AetheriaClientDockingSnapshot(entity, docking, refit, dockingBay);
|
||||
}
|
||||
|
||||
internal static AetheriaClientDockingSnapshot SnapshotFromCurrent(
|
||||
AetheriaRuntimeCurrentEntityDocument? entity,
|
||||
AetheriaRuntimeCurrentDockingDocument? docking,
|
||||
AetheriaRuntimeStationRefitDocument? refit)
|
||||
{
|
||||
return CreateSnapshot(entity, docking, refit);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientReactiveDockingState : IDisposable
|
||||
{
|
||||
private readonly CultMeshReactiveDocument<AetheriaRuntimeCurrentEntityDocument> _currentEntity;
|
||||
private readonly CultMeshReactiveDocument<AetheriaRuntimeCurrentDockingDocument> _currentDocking;
|
||||
private readonly CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument> _stationRefit;
|
||||
|
||||
private AetheriaClientReactiveDockingState(
|
||||
CultMeshReactiveDocument<AetheriaRuntimeCurrentEntityDocument> currentEntity,
|
||||
CultMeshReactiveDocument<AetheriaRuntimeCurrentDockingDocument> currentDocking,
|
||||
CultMeshReactiveDocument<AetheriaRuntimeStationRefitDocument> stationRefit)
|
||||
{
|
||||
_currentEntity = currentEntity ?? throw new ArgumentNullException(nameof(currentEntity));
|
||||
_currentDocking = currentDocking ?? throw new ArgumentNullException(nameof(currentDocking));
|
||||
_stationRefit = stationRefit ?? throw new ArgumentNullException(nameof(stationRefit));
|
||||
}
|
||||
|
||||
internal static async Task<AetheriaClientReactiveDockingState> CreateAsync(
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentEntityDocument> currentEntity,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeCurrentDockingDocument> currentDocking,
|
||||
CultMeshDocumentHandle<AetheriaRuntimeStationRefitDocument> stationRefit,
|
||||
CultMeshReactiveDocumentOptions? options)
|
||||
{
|
||||
var currentEntityTask = currentEntity.ReactiveAsync(options);
|
||||
var currentDockingTask = currentDocking.ReactiveAsync(options);
|
||||
var stationRefitTask = stationRefit.ReactiveAsync(options);
|
||||
await Task.WhenAll(currentEntityTask, currentDockingTask, stationRefitTask).ConfigureAwait(false);
|
||||
return new AetheriaClientReactiveDockingState(
|
||||
currentEntityTask.Result,
|
||||
currentDockingTask.Result,
|
||||
stationRefitTask.Result);
|
||||
}
|
||||
|
||||
public AetheriaClientDockingSnapshot Current =>
|
||||
AetheriaClientDockingState.SnapshotFromCurrent(
|
||||
_currentEntity.Current,
|
||||
_currentDocking.Current,
|
||||
_stationRefit.Current);
|
||||
|
||||
public bool TryCurrent(out AetheriaClientDockingSnapshot? snapshot)
|
||||
{
|
||||
snapshot = null;
|
||||
try
|
||||
{
|
||||
snapshot = Current;
|
||||
return snapshot != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_currentEntity.Dispose();
|
||||
_currentDocking.Dispose();
|
||||
_stationRefit.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientDockingSnapshot
|
||||
{
|
||||
internal AetheriaClientDockingSnapshot(
|
||||
AetheriaRuntimeCurrentEntityDocument? currentEntity,
|
||||
AetheriaRuntimeCurrentDockingDocument? currentDocking,
|
||||
AetheriaRuntimeStationRefitDocument? stationRefit,
|
||||
AetheriaRuntimeStationDockingBayRow? currentDockingBay)
|
||||
{
|
||||
CurrentEntity = currentEntity;
|
||||
CurrentDocking = currentDocking;
|
||||
StationRefit = stationRefit;
|
||||
CurrentDockingBay = currentDockingBay;
|
||||
}
|
||||
|
||||
public AetheriaRuntimeCurrentEntityDocument? CurrentEntity { get; }
|
||||
|
||||
public AetheriaRuntimeCurrentDockingDocument? CurrentDocking { get; }
|
||||
|
||||
public AetheriaRuntimeStationRefitDocument? StationRefit { get; }
|
||||
|
||||
public AetheriaRuntimeStationDockingBayRow? CurrentDockingBay { get; }
|
||||
|
||||
public string CurrentEntityKey => CurrentEntity?.EntityKey ?? CurrentDocking?.CurrentEntityKey ?? "";
|
||||
|
||||
public string DockParentEntityKey => StationRefit?.DockParentEntityKey ?? CurrentDocking?.DockParentEntityKey ?? "";
|
||||
|
||||
public int DockingBayIndex => CurrentDockingBay?.DockingBayIndex ?? StationRefit?.DockingBayIndex ?? CurrentDocking?.DockingBayIndex ?? -1;
|
||||
|
||||
public bool IsDocked => StationRefit?.IsDocked == true && CurrentDockingBay != null;
|
||||
}
|
||||
|
||||
public sealed class AetheriaClientViewportState
|
||||
{
|
||||
private readonly Func<AetheriaRuntimeRtsViewportBounds, CultMeshDocumentHandle<AetheriaRuntimeRtsViewportDocument>> _map;
|
||||
|
|
|
|||
Loading…
Reference in a new issue