Treat zone details as managed facts

This commit is contained in:
Meta Vens 2026-06-29 04:54:16 +01:00
commit 0e10805e33
4 changed files with 71 additions and 67 deletions

View file

@ -4552,9 +4552,9 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root)
"HideZoneDetailsSurface(",
"AetheriaEveUnitySurfaceHost.RenderRuntime(",
"AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument)",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(ProjectZoneDetailsSurfaceState(zoneIndex))",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.ProjectDaemonZone(",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Project(",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(ComposeZoneDetailsSurfaceState(zoneIndex))",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Compose(",
"ZoneDetailsSurfaceState(",
"AetheriaUnityRuntimeClientProvider.ResolveClient(",
".State",
@ -4643,6 +4643,10 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root)
"OpenRuntimeCatalog()",
"ProjectZoneBodies(",
"ProjectZoneEntities(",
"ProjectZoneDetailsSurfaceState(",
"ProjectDaemonZone(",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Project(",
"AetheriaRuntimeZoneDetailsDaemonProjection",
"new AetheriaRuntimeZoneDetailsBodyProjection(",
"new AetheriaRuntimeZoneDetailsEntityProjection(",
"runtimeZone.PlanetInstances",
@ -4669,13 +4673,13 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root)
var requiredBuilderSymbols = new[]
{
"public static class AetheriaRuntimeZoneDetailsSurfaceBuilder",
"public sealed class AetheriaRuntimeZoneDetailsDaemonProjection",
"public sealed class AetheriaRuntimeZoneDetailsBodyProjection",
"public sealed class AetheriaRuntimeZoneDetailsEntityProjection",
"public static AetheriaRuntimeZoneDetailsDaemonProjection ProjectDaemonZone(",
"public sealed class AetheriaRuntimeZoneDetailsFacts",
"public sealed class AetheriaRuntimeZoneDetailsBodyFacts",
"public sealed class AetheriaRuntimeZoneDetailsEntityFacts",
"public static AetheriaRuntimeZoneDetailsFacts Facts(",
"Math.Max(0, zone.GravityTerrainRadius)",
".Sum(body => body.Mass)",
"public static AetheriaRuntimeZoneDetailsSurfaceState Project(",
"public static AetheriaRuntimeZoneDetailsSurfaceState Compose(",
"private static bool IsBodyKind(",
"private static bool IsPlanetBody(",
"private static bool HasHullType(",
@ -14511,7 +14515,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
!compactSectorRenderer.Contains(".State.Reactive<AetheriaRuntimePlayerSettingsDocument>()", StringComparison.Ordinal) ||
!sectorMap.Contains("AetheriaUnityRuntimeClientProvider.ResolveClient(", StringComparison.Ordinal) ||
!compactSectorMap.Contains(".State.Reactive<AetheriaRuntimeSectorMapDocument>()", StringComparison.Ordinal) ||
!sectorRenderer.Contains("AetheriaRuntimeZoneDetailsSurfaceBuilder.ProjectDaemonZone(", StringComparison.Ordinal))
!sectorRenderer.Contains("AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"Map and sector UI must request projected galaxy/zone data through explicit observed daemon boundaries.");

View file

@ -1226,7 +1226,7 @@ public class DaemonRuntimeDocumentTests
}
[Test]
public void ZoneDetailsProjectionReadsMassRadiusAndContentsFromDaemonZone()
public void ZoneDetailsFactsReadMassRadiusAndContentsFromDaemonZone()
{
var zone = new AetheriaRuntimeZoneSnapshotCommit
{
@ -1245,23 +1245,23 @@ public class DaemonRuntimeDocumentTests
}
};
var projection = AetheriaRuntimeZoneDetailsSurfaceBuilder.ProjectDaemonZone(
var facts = AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(
zone,
key => key == "station-hull" ? "Station" : "Ship");
var state = AetheriaRuntimeZoneDetailsSurfaceBuilder.Project(
var state = AetheriaRuntimeZoneDetailsSurfaceBuilder.Compose(
zone.Name,
"GameCult",
projection.Mass.ToString("0"),
projection.Radius.ToString("0"),
facts.Mass.ToString("0"),
facts.Radius.ToString("0"),
new[] { "A", "B" },
projection.Bodies,
projection.Entities,
projection.HasContents,
facts.Bodies,
facts.Entities,
facts.HasContents,
"");
Assert.AreEqual(40, projection.Mass, 0.0001);
Assert.AreEqual(420, projection.Radius, 0.0001);
Assert.IsTrue(projection.HasContents);
Assert.AreEqual(40, facts.Mass, 0.0001);
Assert.AreEqual(420, facts.Radius, 0.0001);
Assert.IsTrue(facts.HasContents);
Assert.AreEqual("1", state.Planets);
Assert.AreEqual("1", state.GasGiants);
Assert.AreEqual("1", state.AsteroidBelts);

View file

@ -98,7 +98,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
transform,
_zoneDetailsSurfaceDocument,
"Aetheria Sector Zone Details Surface",
AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(ProjectZoneDetailsSurfaceState(zoneIndex)),
AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(ComposeZoneDetailsSurfaceState(zoneIndex)),
HandleZoneDetailsSurfaceCommand,
_zoneDetailsSurfaceChrome);
}
@ -128,7 +128,7 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument);
}
private AetheriaRuntimeZoneDetailsSurfaceState ProjectZoneDetailsSurfaceState(int zoneIndex)
private AetheriaRuntimeZoneDetailsSurfaceState ComposeZoneDetailsSurfaceState(int zoneIndex)
{
var sectorZone = ResolveSectorZone(zoneIndex);
var zoneDetails = ResolveZoneDetails(zoneIndex);
@ -139,18 +139,18 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
.Select(FormatFaction)
.ToArray();
var daemonProjection = AetheriaRuntimeZoneDetailsSurfaceBuilder.ProjectDaemonZone(
var zoneFacts = AetheriaRuntimeZoneDetailsSurfaceBuilder.Facts(
zoneDetails,
ResolveHullType);
return AetheriaRuntimeZoneDetailsSurfaceBuilder.Project(
return AetheriaRuntimeZoneDetailsSurfaceBuilder.Compose(
ResolveZoneName(sectorZone, zoneDetails),
ownerFactionIndex >= 0 ? FormatFaction(ownerFactionIndex) : "None",
FormatValue((float)daemonProjection.Mass),
FormatValue((float)daemonProjection.Radius),
FormatValue((float)zoneFacts.Mass),
FormatValue((float)zoneFacts.Radius),
otherFactions,
daemonProjection.Bodies,
daemonProjection.Entities,
daemonProjection.HasContents,
zoneFacts.Bodies,
zoneFacts.Entities,
zoneFacts.HasContents,
updatedAtUtc: DateTime.UtcNow.ToString("O"));
}

View file

@ -55,9 +55,9 @@ namespace GameCult.Aetheria.State.Verse
public string UpdatedAtUtc { get; }
}
public sealed class AetheriaRuntimeZoneDetailsBodyProjection
public sealed class AetheriaRuntimeZoneDetailsBodyFacts
{
public AetheriaRuntimeZoneDetailsBodyProjection(string kind)
public AetheriaRuntimeZoneDetailsBodyFacts(string kind)
{
Kind = kind ?? "";
}
@ -65,9 +65,9 @@ namespace GameCult.Aetheria.State.Verse
public string Kind { get; }
}
public sealed class AetheriaRuntimeZoneDetailsEntityProjection
public sealed class AetheriaRuntimeZoneDetailsEntityFacts
{
public AetheriaRuntimeZoneDetailsEntityProjection(string hullType)
public AetheriaRuntimeZoneDetailsEntityFacts(string hullType)
{
HullType = hullType ?? "";
}
@ -75,26 +75,26 @@ namespace GameCult.Aetheria.State.Verse
public string HullType { get; }
}
public sealed class AetheriaRuntimeZoneDetailsDaemonProjection
public sealed class AetheriaRuntimeZoneDetailsFacts
{
public AetheriaRuntimeZoneDetailsDaemonProjection(
public AetheriaRuntimeZoneDetailsFacts(
double mass,
double radius,
IReadOnlyList<AetheriaRuntimeZoneDetailsBodyProjection> bodies,
IReadOnlyList<AetheriaRuntimeZoneDetailsEntityProjection> entities,
IReadOnlyList<AetheriaRuntimeZoneDetailsBodyFacts> bodies,
IReadOnlyList<AetheriaRuntimeZoneDetailsEntityFacts> entities,
bool hasContents)
{
Mass = mass;
Radius = radius;
Bodies = bodies ?? Array.Empty<AetheriaRuntimeZoneDetailsBodyProjection>();
Entities = entities ?? Array.Empty<AetheriaRuntimeZoneDetailsEntityProjection>();
Bodies = bodies ?? Array.Empty<AetheriaRuntimeZoneDetailsBodyFacts>();
Entities = entities ?? Array.Empty<AetheriaRuntimeZoneDetailsEntityFacts>();
HasContents = hasContents;
}
public double Mass { get; }
public double Radius { get; }
public IReadOnlyList<AetheriaRuntimeZoneDetailsBodyProjection> Bodies { get; }
public IReadOnlyList<AetheriaRuntimeZoneDetailsEntityProjection> Entities { get; }
public IReadOnlyList<AetheriaRuntimeZoneDetailsBodyFacts> Bodies { get; }
public IReadOnlyList<AetheriaRuntimeZoneDetailsEntityFacts> Entities { get; }
public bool HasContents { get; }
}
@ -103,72 +103,72 @@ namespace GameCult.Aetheria.State.Verse
public const string SurfaceId = "aetheria.sector_map.zone_details";
public const string Close = "aetheria.sector_map.zone_details.close";
public static AetheriaRuntimeZoneDetailsDaemonProjection ProjectDaemonZone(
public static AetheriaRuntimeZoneDetailsFacts Facts(
AetheriaRuntimeZoneSnapshotCommit zone,
Func<string, string> resolveHullType)
{
if (zone == null)
{
return new AetheriaRuntimeZoneDetailsDaemonProjection(
return new AetheriaRuntimeZoneDetailsFacts(
0,
0,
Array.Empty<AetheriaRuntimeZoneDetailsBodyProjection>(),
Array.Empty<AetheriaRuntimeZoneDetailsEntityProjection>(),
Array.Empty<AetheriaRuntimeZoneDetailsBodyFacts>(),
Array.Empty<AetheriaRuntimeZoneDetailsEntityFacts>(),
false);
}
return new AetheriaRuntimeZoneDetailsDaemonProjection(
return new AetheriaRuntimeZoneDetailsFacts(
(zone.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>())
.Where(body => body != null)
.Sum(body => body.Mass),
Math.Max(0, zone.GravityTerrainRadius),
ProjectBodies(zone),
ProjectEntities(zone, resolveHullType),
BodyFacts(zone),
EntityFacts(zone, resolveHullType),
true);
}
public static AetheriaRuntimeZoneDetailsDaemonProjection ProjectDaemonZone(
public static AetheriaRuntimeZoneDetailsFacts Facts(
AetheriaRuntimeZoneDetailsDocument zone,
Func<string, string> resolveHullType)
{
if (zone == null)
{
return new AetheriaRuntimeZoneDetailsDaemonProjection(
return new AetheriaRuntimeZoneDetailsFacts(
0,
0,
Array.Empty<AetheriaRuntimeZoneDetailsBodyProjection>(),
Array.Empty<AetheriaRuntimeZoneDetailsEntityProjection>(),
Array.Empty<AetheriaRuntimeZoneDetailsBodyFacts>(),
Array.Empty<AetheriaRuntimeZoneDetailsEntityFacts>(),
false);
}
resolveHullType ??= _ => "";
return new AetheriaRuntimeZoneDetailsDaemonProjection(
return new AetheriaRuntimeZoneDetailsFacts(
zone.Mass,
Math.Max(0, zone.Radius),
(zone.BodyKinds ?? Array.Empty<string>())
.Select(kind => new AetheriaRuntimeZoneDetailsBodyProjection(kind))
.Select(kind => new AetheriaRuntimeZoneDetailsBodyFacts(kind))
.ToArray(),
(zone.EntityHullItemKeys ?? Array.Empty<string>())
.Select(hullItemKey => new AetheriaRuntimeZoneDetailsEntityProjection(resolveHullType(hullItemKey)))
.Select(hullItemKey => new AetheriaRuntimeZoneDetailsEntityFacts(resolveHullType(hullItemKey)))
.ToArray(),
zone.HasContents);
}
public static AetheriaRuntimeZoneDetailsSurfaceState Project(
public static AetheriaRuntimeZoneDetailsSurfaceState Compose(
string zoneName,
string ownerName,
string mass,
string radius,
IEnumerable<string> otherFactions,
IEnumerable<AetheriaRuntimeZoneDetailsBodyProjection> bodies,
IEnumerable<AetheriaRuntimeZoneDetailsEntityProjection> entities,
IEnumerable<AetheriaRuntimeZoneDetailsBodyFacts> bodies,
IEnumerable<AetheriaRuntimeZoneDetailsEntityFacts> entities,
bool hasContents,
string updatedAtUtc)
{
var bodyList = (bodies ?? Array.Empty<AetheriaRuntimeZoneDetailsBodyProjection>())
var bodyList = (bodies ?? Array.Empty<AetheriaRuntimeZoneDetailsBodyFacts>())
.Where(body => body != null)
.ToArray();
var entityList = (entities ?? Array.Empty<AetheriaRuntimeZoneDetailsEntityProjection>())
var entityList = (entities ?? Array.Empty<AetheriaRuntimeZoneDetailsEntityFacts>())
.Where(entity => entity != null)
.ToArray();
@ -192,23 +192,23 @@ namespace GameCult.Aetheria.State.Verse
updatedAtUtc);
}
private static IReadOnlyList<AetheriaRuntimeZoneDetailsBodyProjection> ProjectBodies(
private static IReadOnlyList<AetheriaRuntimeZoneDetailsBodyFacts> BodyFacts(
AetheriaRuntimeZoneSnapshotCommit zone)
{
return (zone?.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>())
.Where(body => body != null)
.Select(body => new AetheriaRuntimeZoneDetailsBodyProjection(body.Kind))
.Select(body => new AetheriaRuntimeZoneDetailsBodyFacts(body.Kind))
.ToArray();
}
private static IReadOnlyList<AetheriaRuntimeZoneDetailsEntityProjection> ProjectEntities(
private static IReadOnlyList<AetheriaRuntimeZoneDetailsEntityFacts> EntityFacts(
AetheriaRuntimeZoneSnapshotCommit zone,
Func<string, string> resolveHullType)
{
resolveHullType ??= _ => "";
return (zone?.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.Where(entity => entity != null)
.Select(entity => new AetheriaRuntimeZoneDetailsEntityProjection(resolveHullType(entity.HullItemKey)))
.Select(entity => new AetheriaRuntimeZoneDetailsEntityFacts(resolveHullType(entity.HullItemKey)))
.ToArray();
}
@ -337,12 +337,12 @@ namespace GameCult.Aetheria.State.Verse
children ?? Array.Empty<AetheriaRuntimeSurfaceComponent>());
}
private static bool IsBodyKind(AetheriaRuntimeZoneDetailsBodyProjection body, string kind)
private static bool IsBodyKind(AetheriaRuntimeZoneDetailsBodyFacts body, string kind)
{
return body != null && string.Equals(body.Kind ?? "", kind, StringComparison.OrdinalIgnoreCase);
}
private static bool IsPlanetBody(AetheriaRuntimeZoneDetailsBodyProjection body)
private static bool IsPlanetBody(AetheriaRuntimeZoneDetailsBodyFacts body)
{
return body != null &&
!IsBodyKind(body, "asteroid_belt") &&
@ -350,7 +350,7 @@ namespace GameCult.Aetheria.State.Verse
!IsBodyKind(body, "sun");
}
private static bool HasHullType(AetheriaRuntimeZoneDetailsEntityProjection entity, string hullType)
private static bool HasHullType(AetheriaRuntimeZoneDetailsEntityFacts entity, string hullType)
{
return entity != null && string.Equals(entity.HullType ?? "", hullType, StringComparison.Ordinal);
}