Build trade cargo selector model directly
This commit is contained in:
parent
80cda5245b
commit
9e89bb0e8b
3 changed files with 34 additions and 22 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<AetheriaRuntimeTradeCargoModelOption>();
|
||||
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"));
|
||||
|
|
|
|||
|
|
@ -98,17 +98,18 @@ namespace GameCult.Aetheria.State.Verse
|
|||
public sealed class AetheriaRuntimeTradeCargoSelectorSurfaceModel
|
||||
{
|
||||
public AetheriaRuntimeTradeCargoSelectorSurfaceModel(
|
||||
AetheriaRuntimeTradeCargoSelectorSurfaceState state,
|
||||
AetheriaRuntimeSurfaceDocument document,
|
||||
IReadOnlyDictionary<string, AetheriaRuntimeTradeCargoSelection> selections)
|
||||
{
|
||||
State = state ?? new AetheriaRuntimeTradeCargoSelectorSurfaceState(
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeTradeCargoTargetOption>(),
|
||||
"");
|
||||
Document = document ?? AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Build(
|
||||
new AetheriaRuntimeTradeCargoSelectorSurfaceState(
|
||||
"",
|
||||
Array.Empty<AetheriaRuntimeTradeCargoTargetOption>(),
|
||||
""));
|
||||
Selections = selections ?? new Dictionary<string, AetheriaRuntimeTradeCargoSelection>(StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
public AetheriaRuntimeTradeCargoSelectorSurfaceState State { get; }
|
||||
public AetheriaRuntimeSurfaceDocument Document { get; }
|
||||
public IReadOnlyDictionary<string, AetheriaRuntimeTradeCargoSelection> 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<AetheriaRuntimeTradeCargoModelOption> 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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue