Project sector zone details from daemon snapshots

This commit is contained in:
Meta Vens 2026-06-21 23:07:16 +01:00
commit 3370802cd0
4 changed files with 135 additions and 35 deletions

View file

@ -929,6 +929,50 @@ public class DaemonRuntimeDocumentTests
Assert.AreEqual(11.75, band.DepthRange, 0.0001);
}
[Test]
public void ZoneDetailsProjectionReadsMassRadiusAndContentsFromDaemonZone()
{
var zone = new AetheriaRuntimeZoneSnapshotCommit
{
Name = "Tir Na Nog",
GravityTerrainRadius = 420,
Bodies = new[]
{
new AetheriaRuntimeBodySnapshotCommit { Kind = "planet", Mass = 10 },
new AetheriaRuntimeBodySnapshotCommit { Kind = "gas_giant", Mass = 30 },
new AetheriaRuntimeBodySnapshotCommit { Kind = "asteroid_belt" }
},
Entities = new[]
{
new AetheriaRuntimeEntitySnapshotCommit { HullItemKey = "station-hull" },
new AetheriaRuntimeEntitySnapshotCommit { HullItemKey = "ship-hull" }
}
};
var projection = AetheriaRuntimeZoneDetailsSurfaceBuilder.ProjectDaemonZone(
zone,
key => key == "station-hull" ? "Station" : "Ship");
var state = AetheriaRuntimeZoneDetailsSurfaceBuilder.Project(
zone.Name,
"GameCult",
projection.Mass.ToString("0"),
projection.Radius.ToString("0"),
new[] { "A", "B" },
projection.Bodies,
projection.Entities,
projection.HasContents,
"");
Assert.AreEqual(40, projection.Mass, 0.0001);
Assert.AreEqual(420, projection.Radius, 0.0001);
Assert.IsTrue(projection.HasContents);
Assert.AreEqual("1", state.Planets);
Assert.AreEqual("1", state.GasGiants);
Assert.AreEqual("1", state.AsteroidBelts);
Assert.AreEqual("1", state.Stations);
Assert.AreEqual("1", state.Ships);
}
[Test]
public void DaemonRenderQueriesPublishBodyPosesFromZoneSnapshot()
{

View file

@ -122,11 +122,6 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
private AetheriaRuntimeZoneDetailsSurfaceState ProjectZoneDetailsSurfaceState(GalaxyZone zone)
{
var density = ActionGameManager.TryGetObservedGalaxy(out var observedGalaxy)
? saturate(observedGalaxy.Background.CloudDensity(zone.Position) / 2)
: 0f;
var radius = GameManager.Settings.ZoneSettings.ZoneRadius.Evaluate(density);
var mass = GameManager.Settings.ZoneSettings.ZoneMass.Evaluate(density);
var otherFactions = zone.Factions
.Where(faction => !faction.HasSameKey(zone.Owner))
.Select(faction => faction.Name)
@ -135,37 +130,24 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
var hasContents = GameManager != null &&
GameManager.TryGetObservedZoneSnapshot(zone?.ZoneIndex ?? -1, out var daemonZone);
var daemonProjection = AetheriaRuntimeZoneDetailsSurfaceBuilder.ProjectDaemonZone(
hasContents ? daemonZone : null,
ResolveHullType);
return AetheriaRuntimeZoneDetailsSurfaceBuilder.Project(
zone.Name,
string.IsNullOrWhiteSpace(daemonZone?.Name) ? zone.Name : daemonZone.Name,
zone.Owner?.Name ?? "None",
ActionGameManager.RuntimePlayerSettings.Format(mass),
ActionGameManager.RuntimePlayerSettings.Format(radius),
ActionGameManager.RuntimePlayerSettings.Format(daemonProjection.Mass),
ActionGameManager.RuntimePlayerSettings.Format(daemonProjection.Radius),
otherFactions,
ProjectZoneBodies(hasContents ? daemonZone : null),
ProjectZoneEntities(hasContents ? daemonZone : null),
hasContents,
daemonProjection.Bodies,
daemonProjection.Entities,
daemonProjection.HasContents,
updatedAtUtc: DateTime.UtcNow.ToString("O"));
}
private static IReadOnlyList<AetheriaRuntimeZoneDetailsBodyProjection> ProjectZoneBodies(
AetheriaRuntimeZoneSnapshotCommit daemonZone)
private static string ResolveHullType(string hullItemKey)
{
return (daemonZone?.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>())
.Select(body => new AetheriaRuntimeZoneDetailsBodyProjection(body?.Kind ?? ""))
.ToArray();
}
private static IReadOnlyList<AetheriaRuntimeZoneDetailsEntityProjection> ProjectZoneEntities(
AetheriaRuntimeZoneSnapshotCommit daemonZone)
{
return (daemonZone?.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>())
.Select(entity => new AetheriaRuntimeZoneDetailsEntityProjection(ResolveHullType(entity)))
.ToArray();
}
private static string ResolveHullType(AetheriaRuntimeEntitySnapshotCommit entity)
{
var typedHull = ActionGameManager.RuntimeCatalog?.FindItem(entity?.HullItemKey ?? "");
var typedHull = ActionGameManager.RuntimeCatalog?.FindItem(hullItemKey ?? "");
return typedHull?.HullType ?? "";
}