diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 8454487d4..57f54f0da 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -5787,13 +5787,13 @@ static void RequireTradeCargoSelectorUseEveSurface(string root) var requiredSymbols = new[] { "RenderCargoSelectorSurface(", - "_cargoSelectorSurfaceModel = ComposeTradeCargoSelectorSurface();", + "_cargoSelectorSurfaceModel = BuildTradeCargoSelectorSurfaceModel();", "HandleCargoSelectorSurfaceCommand(", "AetheriaEveUnitySurfaceHost.RenderRuntime(", "AetheriaEveUnitySurfaceHost.Hide(_cargoSelectorSurfaceDocument)", - "AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Build(_cargoSelectorSurfaceModel.State)", - "ComposeTradeCargoSelectorSurface(", - "AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Compose(", + "_cargoSelectorSurfaceModel.Document", + "BuildTradeCargoSelectorSurfaceModel(", + "AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Build(", "_cargoSelectorSurfaceModel?.TryResolve(command.Command, out var selection) == true", "ApplyCargoSelection(", "new AetheriaRuntimeTradeCargoModelOption(", @@ -5847,6 +5847,9 @@ static void RequireTradeCargoSelectorUseEveSurface(string root) "BuildCargoSelectionCommands(", "ProjectTradeCargoSelectorSurfaceState(", "ProjectTradeCargoSelectorSurface(", + "ComposeTradeCargoSelectorSurface(", + "_cargoSelectorSurfaceModel.State", + "AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Compose(", "_cargoSelectorSurfaceProjection", "AetheriaRuntimeObservedDockingState", "ResolveClient().State.CurrentDocking()", @@ -5906,8 +5909,9 @@ static void RequireTradeCargoSelectorUseEveSurface(string root) "AetheriaRuntimeTradeCargoTargetKind", "AetheriaRuntimeTradeCargoSelection", "AetheriaRuntimeTradeCargoSelectorSurfaceModel", + "public AetheriaRuntimeSurfaceDocument Document { get; }", "public static string ShipBayCommand(", - "public static AetheriaRuntimeTradeCargoSelectorSurfaceModel Compose(", + "public static AetheriaRuntimeTradeCargoSelectorSurfaceModel Build(", "public bool TryResolve(string command, out AetheriaRuntimeTradeCargoSelection selection)", "public static AetheriaRuntimeSurfaceDocument Build(", "providerKind: \"trade.menu\"", @@ -5922,6 +5926,13 @@ static void RequireTradeCargoSelectorUseEveSurface(string root) "Shared runtime trade cargo selector surface builder no longer owns the trade cargo-selector shell contract: " + string.Join(", ", missingBuilderSymbols)); } + + if (tradeCargoSelectorSurfaceBuilder.Contains("public AetheriaRuntimeTradeCargoSelectorSurfaceState State { get; }", StringComparison.Ordinal) || + tradeCargoSelectorSurfaceBuilder.Contains("public static AetheriaRuntimeTradeCargoSelectorSurfaceModel Compose(", StringComparison.Ordinal)) + { + throw new InvalidOperationException( + "Shared runtime trade cargo selector builder must return a model with a finished surface document; do not re-expose Compose or a public State handoff."); + } } static void RequireTradeFilterAndRowActionsUseEveSurface(string root) diff --git a/Assets/Scripts/UI/Menu/TradeMenu.cs b/Assets/Scripts/UI/Menu/TradeMenu.cs index 667b5e69c..6f72fd20f 100644 --- a/Assets/Scripts/UI/Menu/TradeMenu.cs +++ b/Assets/Scripts/UI/Menu/TradeMenu.cs @@ -1136,13 +1136,13 @@ public class TradeMenu : MonoBehaviour private void RenderCargoSelectorSurface() { - _cargoSelectorSurfaceModel = ComposeTradeCargoSelectorSurface(); + _cargoSelectorSurfaceModel = BuildTradeCargoSelectorSurfaceModel(); _cargoSelectorSurfaceDocument = AetheriaEveUnitySurfaceHost.RenderRuntime( transform, _cargoSelectorSurfaceDocument, "Aetheria Trade Cargo Selector Surface", - AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Build(_cargoSelectorSurfaceModel.State), + _cargoSelectorSurfaceModel.Document, HandleCargoSelectorSurfaceCommand, _cargoSelectorSurfaceChrome); } @@ -1200,7 +1200,7 @@ public class TradeMenu : MonoBehaviour }; } - private AetheriaRuntimeTradeCargoSelectorSurfaceModel ComposeTradeCargoSelectorSurface() + private AetheriaRuntimeTradeCargoSelectorSurfaceModel BuildTradeCargoSelectorSurfaceModel() { var targets = new List(); var stationRefit = ResolveStationRefit(); @@ -1228,7 +1228,7 @@ public class TradeMenu : MonoBehaviour target.BayIndex, IsTargetCargoBayKey(target.EntityKey, target.BayIndex)))); - return AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Compose( + return AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Build( _targetCargoLabel ?? "", targets, DateTime.UtcNow.ToString("O")); diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.cs index 2a8442ea0..324f34162 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.cs @@ -98,17 +98,18 @@ namespace GameCult.Aetheria.State.Verse public sealed class AetheriaRuntimeTradeCargoSelectorSurfaceModel { public AetheriaRuntimeTradeCargoSelectorSurfaceModel( - AetheriaRuntimeTradeCargoSelectorSurfaceState state, + AetheriaRuntimeSurfaceDocument document, IReadOnlyDictionary selections) { - State = state ?? new AetheriaRuntimeTradeCargoSelectorSurfaceState( - "", - Array.Empty(), - ""); + Document = document ?? AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Build( + new AetheriaRuntimeTradeCargoSelectorSurfaceState( + "", + Array.Empty(), + "")); Selections = selections ?? new Dictionary(StringComparer.Ordinal); } - public AetheriaRuntimeTradeCargoSelectorSurfaceState State { get; } + public AetheriaRuntimeSurfaceDocument Document { get; } public IReadOnlyDictionary Selections { get; } public bool TryResolve(string command, out AetheriaRuntimeTradeCargoSelection selection) @@ -128,7 +129,7 @@ namespace GameCult.Aetheria.State.Verse return $"{SurfaceId}.ship_{shipIndex}_bay_{bayIndex}"; } - public static AetheriaRuntimeTradeCargoSelectorSurfaceModel Compose( + public static AetheriaRuntimeTradeCargoSelectorSurfaceModel Build( string currentTarget, IEnumerable targets, string updatedAtUtc) @@ -165,12 +166,12 @@ namespace GameCult.Aetheria.State.Verse target.BayIndex); } - return new AetheriaRuntimeTradeCargoSelectorSurfaceModel( - new AetheriaRuntimeTradeCargoSelectorSurfaceState( - currentTarget, - options, - updatedAtUtc), - selections); + var state = new AetheriaRuntimeTradeCargoSelectorSurfaceState( + currentTarget, + options, + updatedAtUtc); + + return new AetheriaRuntimeTradeCargoSelectorSurfaceModel(Build(state), selections); } public static AetheriaRuntimeSurfaceDocument Build(