From 142e1db6a9e2c78689cee52bc5dbbdf0858d53ec Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 21 Jun 2026 16:53:33 +0100 Subject: [PATCH] Project sector details from daemon zone snapshots --- Aetheria.State.Verify/Program.cs | 8 ++++ Assets/Scripts/Gameplay/ActionGameManager.cs | 22 ++++++++--- Assets/Scripts/UI/Menu/SectorRenderer.cs | 41 +++++++++++++------- 3 files changed, 53 insertions(+), 18 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 3d9c7187d..cf430042d 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -3638,6 +3638,10 @@ static void RequireSectorMapZoneDetailsUseEveSurface(string root) "AetheriaEveUnitySurfaceHost.Hide(_zoneDetailsSurfaceDocument)", "AetheriaRuntimeZoneDetailsSurfaceBuilder.Build(ProjectZoneDetailsSurfaceState(", "ProjectZoneDetailsSurfaceState(", + "GameManager?.FindDaemonZoneSnapshot(zone)", + "daemonZone.Bodies ?? Array.Empty()", + "daemonZone.Entities ?? Array.Empty()", + "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)", diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 20317770b..fd20c0247 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -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()) + .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()) - .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() diff --git a/Assets/Scripts/UI/Menu/SectorRenderer.cs b/Assets/Scripts/UI/Menu/SectorRenderer.cs index 7bb48139d..4b53092ca 100644 --- a/Assets/Scripts/UI/Menu/SectorRenderer.cs +++ b/Assets/Scripts/UI/Menu/SectorRenderer.cs @@ -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(); + var entities = daemonZone.Entities ?? Array.Empty(); 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")); }