From 97aeba7304cb6329089a463c2366a72305d4b375 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 08:26:07 +0100 Subject: [PATCH] Collapse trade item details surface state --- Aetheria.State.Verify/Program.cs | 12 +- ...iaRuntimeTradeItemDetailsSurfaceBuilder.cs | 129 +++--------------- 2 files changed, 28 insertions(+), 113 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 4ac7623c3..e9b27d6b3 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -6176,7 +6176,6 @@ static void RequireTradeItemDetailsUseEveSurface(string root) "private static EveSurfaceComponent", "new EveSurfaceComponent(", "string.Equals(request.Command, AetheriaRuntimeTradeItemDetailsSurfaceBuilder.Close", - "new AetheriaRuntimeTradeItemDetailsSurfaceState(", "ProjectTradeItemDetailsSurface(", "ProjectTradeItemDetailsSurfaceState(", "AetheriaRuntimeTradeItemDetailsSurfaceBuilder.Project(", @@ -6204,10 +6203,11 @@ static void RequireTradeItemDetailsUseEveSurface(string root) "public readonly struct AetheriaRuntimeTradeItemDetailsCommand", "public static class AetheriaRuntimeTradeItemDetailsSurfaceCommands", "public static bool TryRead(", - "AetheriaRuntimeTradeItemDetailsSurfaceState", "AetheriaRuntimeTradeItemSection", "AetheriaRuntimeTradeItemMetric", - "private static AetheriaRuntimeTradeItemDetailsSurfaceState ComposeState(", + "var itemName = item?.Name ?? \"\"", + "var behaviorSections = Array.Empty()", + "var hasEquipmentStatus = !string.IsNullOrWhiteSpace(durability)", "ProjectBehaviorSections(", "ProjectBehaviorMetric(", "public static AetheriaRuntimeSurfaceDocument Build(", @@ -6224,13 +6224,15 @@ static void RequireTradeItemDetailsUseEveSurface(string root) string.Join(", ", missingBuilderSymbols)); } - if (tradeItemDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeTradeItemDetailsSurfaceState Project(", StringComparison.Ordinal) || + if (tradeItemDetailsSurfaceBuilder.Contains("AetheriaRuntimeTradeItemDetailsSurfaceState", StringComparison.Ordinal) || + tradeItemDetailsSurfaceBuilder.Contains("ComposeState(", StringComparison.Ordinal) || + tradeItemDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeTradeItemDetailsSurfaceState Project(", StringComparison.Ordinal) || tradeItemDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeTradeItemDetailsSurfaceState Compose(", StringComparison.Ordinal) || tradeItemDetailsSurfaceBuilder.Contains("private static AetheriaRuntimeTradeItemDetailsSurfaceState ProjectState(", StringComparison.Ordinal) || tradeItemDetailsSurfaceBuilder.Contains("Build(ProjectState(", StringComparison.Ordinal)) { throw new InvalidOperationException( - "Runtime trade item detail composition must stay behind Build(...); do not re-expose Project/Compose or restore ProjectState handoffs."); + "Runtime trade item details must emit the typed surface document directly; do not rebuild a shadow SurfaceState projection layer."); } } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeItemDetailsSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeItemDetailsSurfaceBuilder.cs index 5293f58b9..b9d952d4d 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeItemDetailsSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeTradeItemDetailsSurfaceBuilder.cs @@ -37,44 +37,6 @@ namespace GameCult.Aetheria.State.Verse public IReadOnlyList Metrics { get; } } - public sealed class AetheriaRuntimeTradeItemDetailsSurfaceState - { - public AetheriaRuntimeTradeItemDetailsSurfaceState( - string itemName, - string description, - string manufacturer, - string mass, - int price, - string durability, - string thermalRange, - IReadOnlyList behaviorSections, - string updatedAtUtc) - { - ItemName = itemName ?? ""; - Description = description ?? ""; - Manufacturer = manufacturer ?? ""; - Mass = mass ?? ""; - Price = price; - Durability = durability ?? ""; - ThermalRange = thermalRange ?? ""; - BehaviorSections = behaviorSections ?? Array.Empty(); - UpdatedAtUtc = updatedAtUtc ?? ""; - } - - public string ItemName { get; } - public string Description { get; } - public string Manufacturer { get; } - public string Mass { get; } - public int Price { get; } - public string Durability { get; } - public string ThermalRange { get; } - public IReadOnlyList BehaviorSections { get; } - public string UpdatedAtUtc { get; } - public bool HasEquipmentStatus => !string.IsNullOrWhiteSpace(Durability) || - !string.IsNullOrWhiteSpace(ThermalRange) || - BehaviorSections.Count > 0; - } - public static class AetheriaRuntimeTradeItemDetailsSurfaceBuilder { public const string SurfaceId = "aetheria.trade.item_details"; @@ -87,106 +49,57 @@ namespace GameCult.Aetheria.State.Verse Func formatTemperature, DateTime updatedAtUtc = default(DateTime), long version = 1) - { - return Build( - ComposeState( - item, - manufacturer, - formatValue, - formatTemperature, - updatedAtUtc), - version); - } - - private static AetheriaRuntimeTradeItemDetailsSurfaceState ComposeState( - AetheriaRuntimeCatalogItem item, - string manufacturer, - Func formatValue, - Func formatTemperature, - DateTime updatedAtUtc = default(DateTime)) { if (updatedAtUtc == default(DateTime)) updatedAtUtc = DateTime.UtcNow; - if (item == null) - { - return new AetheriaRuntimeTradeItemDetailsSurfaceState( - "", - "", - manufacturer ?? "", - "", - 0, - "", - "", - Array.Empty(), - updatedAtUtc.ToString("O", CultureInfo.InvariantCulture)); - } - + var itemName = item?.Name ?? ""; + var description = item?.Description ?? ""; + manufacturer ??= ""; + var mass = item == null ? "" : FormatValue(item.Mass, formatValue); + var price = item?.Price ?? 0; var durability = ""; var thermalRange = ""; var behaviorSections = Array.Empty(); - if (!string.IsNullOrWhiteSpace(item.HardpointType)) + if (!string.IsNullOrWhiteSpace(item?.HardpointType)) { durability = FormatValue(item.Durability, formatValue); thermalRange = FormatTemperatureRange(item, formatTemperature); behaviorSections = ProjectBehaviorSections(item, formatValue, formatTemperature).ToArray(); } - - return new AetheriaRuntimeTradeItemDetailsSurfaceState( - item.Name, - item.Description ?? "", - manufacturer ?? "", - FormatValue(item.Mass, formatValue), - item.Price, - durability, - thermalRange, - behaviorSections, - updatedAtUtc.ToString("O", CultureInfo.InvariantCulture)); - } - - public static AetheriaRuntimeSurfaceDocument Build( - AetheriaRuntimeTradeItemDetailsSurfaceState state, - long version = 1) - { - state ??= new AetheriaRuntimeTradeItemDetailsSurfaceState( - "", - "", - "", - "", - 0, - "", - "", - Array.Empty(), - ""); + var hasEquipmentStatus = !string.IsNullOrWhiteSpace(durability) || + !string.IsNullOrWhiteSpace(thermalRange) || + behaviorSections.Length > 0; + var updated = updatedAtUtc.ToString("O", CultureInfo.InvariantCulture); var children = new List { Card( $"{SurfaceId}.summary", - state.ItemName, + itemName, Text( $"{SurfaceId}.description", - string.IsNullOrWhiteSpace(state.Description) + string.IsNullOrWhiteSpace(description) ? "No typed item description is available." - : state.Description), + : description), Text( $"{SurfaceId}.note", "The observing client supplies the selected market row; the shared runtime surface owns trade item inspection layout."), - Metric($"{SurfaceId}.manufacturer", "Manufacturer", state.Manufacturer), - Metric($"{SurfaceId}.mass", "Mass", state.Mass), - Metric($"{SurfaceId}.price", "Price", state.Price.ToString("N0"))) + Metric($"{SurfaceId}.manufacturer", "Manufacturer", manufacturer), + Metric($"{SurfaceId}.mass", "Mass", mass), + Metric($"{SurfaceId}.price", "Price", price.ToString("N0"))) }; - if (state.HasEquipmentStatus) + if (hasEquipmentStatus) { children.Add(Card( $"{SurfaceId}.durability.card", "Durability", - Metric($"{SurfaceId}.durability", "Max Durability", state.Durability), - Metric($"{SurfaceId}.temperature_range", "Thermal Range", state.ThermalRange))); + Metric($"{SurfaceId}.durability", "Max Durability", durability), + Metric($"{SurfaceId}.temperature_range", "Thermal Range", thermalRange))); } - foreach (var section in state.BehaviorSections) + foreach (var section in behaviorSections) { if (section?.Metrics == null || section.Metrics.Count == 0) continue; @@ -210,7 +123,7 @@ namespace GameCult.Aetheria.State.Verse providerKind: "trade.menu", title: "Trade Item Details", version: version, - updatedAtUtc: state.UpdatedAtUtc, + updatedAtUtc: updated, surface: new AetheriaRuntimeSurfaceTree( SurfaceId, Node(