From 40870951281d19fcffa708bce3084f2e3715e464 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 29 Jun 2026 08:23:15 +0100 Subject: [PATCH] Collapse zone details surface state --- Aetheria.State.Verify/Program.cs | 13 +- ...etheriaRuntimeZoneDetailsSurfaceBuilder.cs | 249 ++++++------------ 2 files changed, 83 insertions(+), 179 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index cf43d47dc..4ac7623c3 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4670,7 +4670,6 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) "runtimeZone.PlanetInstances", "runtimeZone.AsteroidBelts", "runtimeZone.Entities", - "new AetheriaRuntimeZoneDetailsSurfaceState(", "private static bool IsBodyKind(", "private static bool IsPlanetBody(", "private static bool HasHullType(", @@ -4698,7 +4697,10 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) "Math.Max(0, zone.GravityTerrainRadius)", ".Sum(body => body.Mass)", "public static AetheriaRuntimeSurfaceDocument Build(", - "private static AetheriaRuntimeZoneDetailsSurfaceState ComposeState(", + "var bodyList = (bodies ?? Array.Empty())", + "var sortedFactions = (otherFactions ?? Array.Empty())", + "var planets = bodyList.Count(IsPlanetBody).ToString()", + "var stations = entityList.Count(entity => HasHullType(entity, \"Station\")).ToString()", "private static bool IsBodyKind(", "private static bool IsPlanetBody(", "private static bool HasHullType(", @@ -4708,7 +4710,6 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) "public readonly struct AetheriaRuntimeZoneDetailsCommand", "public static class AetheriaRuntimeZoneDetailsSurfaceCommands", "public static bool TryRead(", - "AetheriaRuntimeZoneDetailsSurfaceState", "public static AetheriaRuntimeSurfaceDocument Build(", "providerKind: \"sector.map\"", "Factions Present", @@ -4725,11 +4726,13 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) string.Join(", ", missingBuilderSymbols)); } - if (zoneDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeZoneDetailsSurfaceState Compose(", StringComparison.Ordinal) || + if (zoneDetailsSurfaceBuilder.Contains("AetheriaRuntimeZoneDetailsSurfaceState", StringComparison.Ordinal) || + zoneDetailsSurfaceBuilder.Contains("ComposeState(", StringComparison.Ordinal) || + zoneDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeZoneDetailsSurfaceState Compose(", StringComparison.Ordinal) || zoneDetailsSurfaceBuilder.Contains("public static AetheriaRuntimeZoneDetailsSurfaceState Project(", StringComparison.Ordinal)) { throw new InvalidOperationException( - "Runtime zone detail composition must stay behind Build(...); do not re-expose Compose/Project as the public zone details surface path."); + "Runtime zone 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/AetheriaRuntimeZoneDetailsSurfaceBuilder.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeZoneDetailsSurfaceBuilder.cs index 7527b62b0..1ef3fe868 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeZoneDetailsSurfaceBuilder.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeZoneDetailsSurfaceBuilder.cs @@ -5,56 +5,6 @@ using GameCult.Eve.Surface; namespace GameCult.Aetheria.State.Verse { - public sealed class AetheriaRuntimeZoneDetailsSurfaceState - { - public AetheriaRuntimeZoneDetailsSurfaceState( - string zoneName, - string ownerName, - string mass, - string radius, - IReadOnlyList otherFactions, - bool hasContents, - string planets, - string asteroidBelts, - string gasGiants, - string stars, - string stations, - string turrets, - string ships, - string updatedAtUtc) - { - ZoneName = zoneName ?? ""; - OwnerName = ownerName ?? ""; - Mass = mass ?? ""; - Radius = radius ?? ""; - OtherFactions = otherFactions ?? Array.Empty(); - HasContents = hasContents; - Planets = planets ?? ""; - AsteroidBelts = asteroidBelts ?? ""; - GasGiants = gasGiants ?? ""; - Stars = stars ?? ""; - Stations = stations ?? ""; - Turrets = turrets ?? ""; - Ships = ships ?? ""; - UpdatedAtUtc = updatedAtUtc ?? ""; - } - - public string ZoneName { get; } - public string OwnerName { get; } - public string Mass { get; } - public string Radius { get; } - public IReadOnlyList OtherFactions { get; } - public bool HasContents { get; } - public string Planets { get; } - public string AsteroidBelts { get; } - public string GasGiants { get; } - public string Stars { get; } - public string Stations { get; } - public string Turrets { get; } - public string Ships { get; } - public string UpdatedAtUtc { get; } - } - public sealed class AetheriaRuntimeZoneDetailsBodyFacts { public AetheriaRuntimeZoneDetailsBodyFacts(string kind) @@ -166,56 +116,88 @@ namespace GameCult.Aetheria.State.Verse string updatedAtUtc, long version = 1) { - return Build( - ComposeState( - zoneName, - ownerName, - mass, - radius, - otherFactions, - bodies, - entities, - hasContents, - updatedAtUtc), - version); - } - - private static AetheriaRuntimeZoneDetailsSurfaceState ComposeState( - string zoneName, - string ownerName, - string mass, - string radius, - IEnumerable otherFactions, - IEnumerable bodies, - IEnumerable entities, - bool hasContents, - string updatedAtUtc) - { + zoneName ??= ""; + ownerName ??= ""; + mass ??= ""; + radius ??= ""; + updatedAtUtc ??= ""; var bodyList = (bodies ?? Array.Empty()) .Where(body => body != null) .ToArray(); var entityList = (entities ?? Array.Empty()) .Where(entity => entity != null) .ToArray(); + var sortedFactions = (otherFactions ?? Array.Empty()) + .Where(name => !string.IsNullOrWhiteSpace(name)) + .OrderBy(name => name, StringComparer.Ordinal) + .ToArray(); + var planets = bodyList.Count(IsPlanetBody).ToString(); + var asteroidBelts = bodyList.Count(body => IsBodyKind(body, "asteroid_belt")).ToString(); + var gasGiants = bodyList.Count(body => IsBodyKind(body, "gas_giant")).ToString(); + var stars = bodyList.Count(body => IsBodyKind(body, "sun")).ToString(); + var stations = entityList.Count(entity => HasHullType(entity, "Station")).ToString(); + var turrets = entityList.Count(entity => HasHullType(entity, "Turret")).ToString(); + var ships = entityList.Count(entity => HasHullType(entity, "Ship")).ToString(); - return new AetheriaRuntimeZoneDetailsSurfaceState( - zoneName, - ownerName, - mass, - radius, - (otherFactions ?? Array.Empty()) - .Where(name => !string.IsNullOrWhiteSpace(name)) - .OrderBy(name => name, StringComparer.Ordinal) - .ToArray(), - hasContents, - bodyList.Count(IsPlanetBody).ToString(), - bodyList.Count(body => IsBodyKind(body, "asteroid_belt")).ToString(), - bodyList.Count(body => IsBodyKind(body, "gas_giant")).ToString(), - bodyList.Count(body => IsBodyKind(body, "sun")).ToString(), - entityList.Count(entity => HasHullType(entity, "Station")).ToString(), - entityList.Count(entity => HasHullType(entity, "Turret")).ToString(), - entityList.Count(entity => HasHullType(entity, "Ship")).ToString(), - updatedAtUtc); + var children = new List + { + Card( + $"{SurfaceId}.card", + zoneName, + Metric($"{SurfaceId}.owner", "Owner", string.IsNullOrWhiteSpace(ownerName) ? "None" : ownerName), + Metric($"{SurfaceId}.mass", "Mass", mass), + Metric($"{SurfaceId}.radius", "Radius", radius)) + }; + + if (sortedFactions.Length > 0) + { + children.Add(Text( + $"{SurfaceId}.factions", + $"Factions Present: {string.Join(", ", sortedFactions)}")); + } + + if (!hasContents) + { + children.Add(Text( + $"{SurfaceId}.unvisited", + "Has not been visited.")); + } + else + { + children.Add(Card( + $"{SurfaceId}.contents", + "Contents", + Metric($"{SurfaceId}.planets", "Planets", planets), + Metric($"{SurfaceId}.belts", "Asteroid Belts", asteroidBelts), + Metric($"{SurfaceId}.giants", "Gas Giants", gasGiants), + Metric($"{SurfaceId}.stars", "Stars", stars), + Metric($"{SurfaceId}.stations", "Stations", stations), + Metric($"{SurfaceId}.turrets", "Turrets", turrets), + Metric($"{SurfaceId}.ships", "Ships", ships))); + } + + children.Add(ButtonRow( + $"{SurfaceId}.actions", + Button($"{SurfaceId}.close", "Close", Close))); + + return new AetheriaRuntimeSurfaceDocument( + providerId: "aetheria", + providerKind: "sector.map", + title: zoneName, + version: version, + updatedAtUtc: updatedAtUtc, + surface: new AetheriaRuntimeSurfaceTree( + SurfaceId, + Node( + $"{SurfaceId}.root", + "surface", + Array.Empty<(string Key, string Value)>(), + children.ToArray()), + Array.Empty()), + commands: new[] + { + new AetheriaRuntimeSurfaceCommandTemplate(Close, "Close", AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport) + }); } private static IReadOnlyList BodyFacts( @@ -238,87 +220,6 @@ namespace GameCult.Aetheria.State.Verse .ToArray(); } - public static AetheriaRuntimeSurfaceDocument Build( - AetheriaRuntimeZoneDetailsSurfaceState state, - long version = 1) - { - state ??= new AetheriaRuntimeZoneDetailsSurfaceState( - "", - "", - "", - "", - Array.Empty(), - false, - "", - "", - "", - "", - "", - "", - "", - ""); - - var children = new List - { - Card( - $"{SurfaceId}.card", - state.ZoneName, - Metric($"{SurfaceId}.owner", "Owner", string.IsNullOrWhiteSpace(state.OwnerName) ? "None" : state.OwnerName), - Metric($"{SurfaceId}.mass", "Mass", state.Mass), - Metric($"{SurfaceId}.radius", "Radius", state.Radius)) - }; - - if (state.OtherFactions.Count > 0) - { - children.Add(Text( - $"{SurfaceId}.factions", - $"Factions Present: {string.Join(", ", state.OtherFactions)}")); - } - - if (!state.HasContents) - { - children.Add(Text( - $"{SurfaceId}.unvisited", - "Has not been visited.")); - } - else - { - children.Add(Card( - $"{SurfaceId}.contents", - "Contents", - Metric($"{SurfaceId}.planets", "Planets", state.Planets), - Metric($"{SurfaceId}.belts", "Asteroid Belts", state.AsteroidBelts), - Metric($"{SurfaceId}.giants", "Gas Giants", state.GasGiants), - Metric($"{SurfaceId}.stars", "Stars", state.Stars), - Metric($"{SurfaceId}.stations", "Stations", state.Stations), - Metric($"{SurfaceId}.turrets", "Turrets", state.Turrets), - Metric($"{SurfaceId}.ships", "Ships", state.Ships))); - } - - children.Add(ButtonRow( - $"{SurfaceId}.actions", - Button($"{SurfaceId}.close", "Close", Close))); - - return new AetheriaRuntimeSurfaceDocument( - providerId: "aetheria", - providerKind: "sector.map", - title: state.ZoneName, - version: version, - updatedAtUtc: state.UpdatedAtUtc, - surface: new AetheriaRuntimeSurfaceTree( - SurfaceId, - Node( - $"{SurfaceId}.root", - "surface", - Array.Empty<(string Key, string Value)>(), - children.ToArray()), - Array.Empty()), - commands: new[] - { - new AetheriaRuntimeSurfaceCommandTemplate(Close, "Close", AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport) - }); - } - private static AetheriaRuntimeSurfaceComponent Card( string id, string title,