Collapse zone details surface state

This commit is contained in:
Meta Vens 2026-06-29 08:23:15 +01:00
commit 4087095128
2 changed files with 59 additions and 155 deletions

View file

@ -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<AetheriaRuntimeZoneDetailsBodyFacts>())",
"var sortedFactions = (otherFactions ?? Array.Empty<string>())",
"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.");
}
}

View file

@ -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<string> 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<string>();
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<string> 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<string> otherFactions,
IEnumerable<AetheriaRuntimeZoneDetailsBodyFacts> bodies,
IEnumerable<AetheriaRuntimeZoneDetailsEntityFacts> entities,
bool hasContents,
string updatedAtUtc)
{
zoneName ??= "";
ownerName ??= "";
mass ??= "";
radius ??= "";
updatedAtUtc ??= "";
var bodyList = (bodies ?? Array.Empty<AetheriaRuntimeZoneDetailsBodyFacts>())
.Where(body => body != null)
.ToArray();
var entityList = (entities ?? Array.Empty<AetheriaRuntimeZoneDetailsEntityFacts>())
.Where(entity => entity != null)
.ToArray();
var sortedFactions = (otherFactions ?? Array.Empty<string>())
.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<string>())
.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<AetheriaRuntimeSurfaceComponent>
{
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<AetheriaRuntimeSurfaceStyleToken>()),
commands: new[]
{
new AetheriaRuntimeSurfaceCommandTemplate(Close, "Close", AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport)
});
}
private static IReadOnlyList<AetheriaRuntimeZoneDetailsBodyFacts> 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<string>(),
false,
"",
"",
"",
"",
"",
"",
"",
"");
var children = new List<AetheriaRuntimeSurfaceComponent>
{
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<AetheriaRuntimeSurfaceStyleToken>()),
commands: new[]
{
new AetheriaRuntimeSurfaceCommandTemplate(Close, "Close", AetheriaRuntimeSurfaceCommandTemplate.CultMeshTransport)
});
}
private static AetheriaRuntimeSurfaceComponent Card(
string id,
string title,