Project sector details from daemon zone snapshots

This commit is contained in:
Meta Vens 2026-06-21 16:53:33 +01:00
commit 142e1db6a9
3 changed files with 53 additions and 18 deletions

View file

@ -3638,6 +3638,10 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root)
"AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument)",
"AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(ProjectZoneDetailsSurfaceState(",
"ProjectZoneDetailsSurfaceState(",
"GameManager?.FindDaemonZoneSnapshot(zone)",
"daemonZone.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>()",
"daemonZone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>()",
"typedHull.HullType",
"AetheriaRuntimeZoneDetailsSurfaceCommands.TryRead(request, out var command)",
"AetheriaRuntimeZoneDetailsCommandKind.Close"
};
@ -3673,6 +3677,9 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root)
"Properties.AddProperty(\"Stations\"",
"Properties.AddProperty(\"Turrets\"",
"Properties.AddProperty(\"Ships\"",
"runtimeZone.PlanetInstances",
"runtimeZone.AsteroidBelts",
"runtimeZone.Entities",
"string.Equals(request.Command, AetheriaRuntimeZoneDetailsSurfaceBuilder.Close"
};
@ -7906,6 +7913,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root)
{
"ApplyLatestAuthoritativeDaemonFrame()",
"ResolveDaemonObserver()",
"public AetheriaRuntimeZoneSnapshotCommit FindDaemonZoneSnapshot(GalaxyZone zone)",
"observed.IsAuthoritative",
"TryRestoreEntityGraphFromDaemonRun(observed.Run)",
"CreateDaemonZoneConstructionBlueprint(daemonZone)",

View file

@ -850,6 +850,17 @@ public class ActionGameManager : MonoBehaviour
return ObservedGalaxy?.Zones == null || zone == null ? -1 : Array.IndexOf(ObservedGalaxy.Zones, zone);
}
public AetheriaRuntimeZoneSnapshotCommit FindDaemonZoneSnapshot(GalaxyZone zone)
{
var zoneIndex = ZoneIndex(zone);
if (zoneIndex < 0)
return null;
var run = ResolveDaemonObserver()?.LastObservedState?.Run;
return (run?.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
.FirstOrDefault(snapshot => snapshot != null && snapshot.ZoneIndex == zoneIndex);
}
private static int FactionIndex(Faction faction)
{
return ObservedGalaxy?.Factions == null || faction == null ? -1 : Array.IndexOf(ObservedGalaxy.Factions, faction);
@ -3099,11 +3110,12 @@ public class ActionGameManager : MonoBehaviour
private AetheriaRuntimeZoneSnapshotCommit FindCurrentDaemonZoneSnapshot()
{
var run = ResolveDaemonObserver()?.LastObservedState?.Run;
if (run == null)
return null;
return (run.Zones ?? Array.Empty<AetheriaRuntimeZoneSnapshotCommit>())
.FirstOrDefault(zone => zone != null && zone.ZoneIndex == run.CurrentZoneIndex);
var zone = run?.CurrentZoneIndex >= 0 &&
ActionGameManager.ObservedGalaxy?.Zones != null &&
run.CurrentZoneIndex < ActionGameManager.ObservedGalaxy.Zones.Length
? ActionGameManager.ObservedGalaxy.Zones[run.CurrentZoneIndex]
: null;
return FindDaemonZoneSnapshot(zone);
}
public void RequestTowToStation()

View file

@ -84,11 +84,24 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
// });
}
private bool HasHullType(Entity entity, HullType hullType)
private static bool IsBodyKind(AetheriaRuntimeBodySnapshotCommit body, string kind)
{
var typedItem = entity?.ItemManager.GetRuntimeItem(entity.Hull);
return typedItem != null &&
string.Equals(typedItem.HullType, hullType.ToString(), StringComparison.Ordinal);
return body != null && string.Equals(body.Kind ?? "", kind, StringComparison.OrdinalIgnoreCase);
}
private static bool IsPlanetBody(AetheriaRuntimeBodySnapshotCommit body)
{
return body != null &&
!IsBodyKind(body, "asteroid_belt") &&
!IsBodyKind(body, "gas_giant") &&
!IsBodyKind(body, "sun");
}
private static bool HasHullType(AetheriaRuntimeEntitySnapshotCommit entity, HullType hullType)
{
var typedHull = ActionGameManager.RuntimeCatalog?.FindItem(entity?.HullItemKey ?? "");
return typedHull != null &&
string.Equals(typedHull.HullType, hullType.ToString(), StringComparison.Ordinal);
}
private void RenderZoneDetailsSurface(GalaxyZone zone)
@ -138,7 +151,8 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
.Where(name => !string.IsNullOrWhiteSpace(name))
.ToArray();
if (zone.Contents == null)
var daemonZone = GameManager?.FindDaemonZoneSnapshot(zone);
if (daemonZone == null)
{
return new AetheriaRuntimeZoneDetailsSurfaceState(
zone.Name,
@ -157,7 +171,8 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
updatedAtUtc: DateTime.UtcNow.ToString("O"));
}
var runtimeZone = zone.Contents;
var bodies = daemonZone.Bodies ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>();
var entities = daemonZone.Entities ?? Array.Empty<AetheriaRuntimeEntitySnapshotCommit>();
return new AetheriaRuntimeZoneDetailsSurfaceState(
zone.Name,
zone.Owner?.Name ?? "None",
@ -165,13 +180,13 @@ public class SectorRenderer : MonoBehaviour, IBeginDragHandler, IDragHandler, IS
ActionGameManager.RuntimePlayerSettings.Format(radius),
otherFactions,
hasContents: true,
planets: runtimeZone.PlanetInstances.Values.Count(body => !(body is GasGiant)).ToString(),
asteroidBelts: runtimeZone.AsteroidBelts.Count.ToString(),
gasGiants: runtimeZone.PlanetInstances.Values.Count(body => body is GasGiant && !(body is Sun)).ToString(),
stars: runtimeZone.PlanetInstances.Values.Count(body => body is Sun).ToString(),
stations: runtimeZone.Entities.Count(entity => HasHullType(entity, HullType.Station)).ToString(),
turrets: runtimeZone.Entities.Count(entity => HasHullType(entity, HullType.Turret)).ToString(),
ships: runtimeZone.Entities.Count(entity => HasHullType(entity, HullType.Ship)).ToString(),
planets: bodies.Count(IsPlanetBody).ToString(),
asteroidBelts: bodies.Count(body => IsBodyKind(body, "asteroid_belt")).ToString(),
gasGiants: bodies.Count(body => IsBodyKind(body, "gas_giant")).ToString(),
stars: bodies.Count(body => IsBodyKind(body, "sun")).ToString(),
stations: entities.Count(entity => HasHullType(entity, HullType.Station)).ToString(),
turrets: entities.Count(entity => HasHullType(entity, HullType.Turret)).ToString(),
ships: entities.Count(entity => HasHullType(entity, HullType.Ship)).ToString(),
updatedAtUtc: DateTime.UtcNow.ToString("O"));
}