diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index 5eafec108..6984a0a39 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -13888,10 +13888,10 @@ static void RequireMainMenuContinueRunState(string root) "GameplayLoopShell.LateTick()", "ApplyLatestZoneRender = () => ObservedFrameApplier.ApplyLatestZoneRender()", "private AetheriaUnityObservedFrameApplier ObservedFrameApplier =>", - "private Galaxy ObservedGalaxy { get; set; }", - "ObservedGalaxy = boot.ObservedGalaxy", + "ObservedZoneContextFactory = new AetheriaUnityObservedZoneContextFactory(", + "boot.ObservedGalaxy", "ObservedZoneContextFactory.ResolveGalaxyZone", - "private AetheriaUnityObservedZoneContextFactory ObservedZoneContextFactory =>", + "private AetheriaUnityObservedZoneContextFactory ObservedZoneContextFactory { get; set; }", "entity => CurrentEntityBinder.RestoreBinding(entity)", "ResolveObservedTarget = entity => _targetPresentation.GetObservedTarget(entity)", "TargetPresentation = _targetPresentation", @@ -14916,10 +14916,10 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) "ApplyLatestZoneRender = () => ObservedFrameApplier.ApplyLatestZoneRender()", "ResolveDaemonObserver()", "private AetheriaUnityObservedFrameApplier ObservedFrameApplier =>", - "private Galaxy ObservedGalaxy { get; set; }", - "ObservedGalaxy = boot.ObservedGalaxy", + "ObservedZoneContextFactory = new AetheriaUnityObservedZoneContextFactory(", + "boot.ObservedGalaxy", "ObservedZoneContextFactory.ResolveGalaxyZone", - "private AetheriaUnityObservedZoneContextFactory ObservedZoneContextFactory =>", + "private AetheriaUnityObservedZoneContextFactory ObservedZoneContextFactory { get; set; }", "entity => CurrentEntityBinder.RestoreBinding(entity)", "private AetheriaUnityEntityBlueprintMaterializer EntityBlueprintMaterializer =>", "EntityBlueprintMaterializer.MaterializeObservedEntity", @@ -15317,10 +15317,15 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) string.Join(", ", observedReadShimHits)); } - if (actionGameManager.Contains("public static Galaxy ObservedGalaxy", StringComparison.Ordinal)) + if (actionGameManager.Contains("private Galaxy ObservedGalaxy", StringComparison.Ordinal) || + actionGameManager.Contains("ObservedGalaxy = boot.ObservedGalaxy", StringComparison.Ordinal) || + actionGameManager.Contains("() => ObservedGalaxy", StringComparison.Ordinal) || + observedZoneContextFactory.Contains("Func resolveObservedGalaxy", StringComparison.Ordinal) || + observedZoneContextFactory.Contains("_resolveObservedGalaxy", StringComparison.Ordinal) || + observedZoneContextFactory.Contains("_observedGalaxy ??=", StringComparison.Ordinal)) { throw new InvalidOperationException( - "ActionGameManager must not expose the raw observed galaxy projection as public gameplay state; keep it as a private renderer adapter behind managed typed documents."); + "ActionGameManager must not own the raw observed galaxy projection; gameplay boot may pass it once into the legacy Zone construction adapter only."); } if (actionGameManager.Contains("public static void ProjectObservedDaemonRun(", StringComparison.Ordinal) || diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 388a01fd9..236d82acd 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -19,7 +19,6 @@ public class ActionGameManager : MonoBehaviour private AetheriaUnityPilotCommandSender _pilotCommands; private AetheriaUnityObservedEntityRestorer _observedEntityRestorer; private AetheriaUnityCurrentEntityBinder _currentEntityBinder; - private AetheriaUnityObservedZoneContextFactory _observedZoneContextFactory; private AetheriaUnityPilotFrameController _pilotFrameController; private AetheriaUnityPilotOperationController _pilotOperationController; private AetheriaUnityObservedFrameApplier _observedFrameApplier; @@ -45,13 +44,7 @@ public class ActionGameManager : MonoBehaviour EntityBlueprintMaterializer.MaterializeObservedEntity, _loadoutItemFactory.CreateLoadoutItem, Debug.LogWarning); - private AetheriaUnityObservedZoneContextFactory ObservedZoneContextFactory => - _observedZoneContextFactory ??= new AetheriaUnityObservedZoneContextFactory( - ItemManager, - Settings.PlanetSettings, - () => ObservedGalaxy, - Debug.LogWarning, - PlayMusic); + private AetheriaUnityObservedZoneContextFactory ObservedZoneContextFactory { get; set; } private AetheriaUnityCurrentEntityBinder CurrentEntityBinder => _currentEntityBinder ??= new AetheriaUnityCurrentEntityBinder { @@ -282,7 +275,6 @@ public class ActionGameManager : MonoBehaviour private ItemManager ItemManager { get; set; } private AetheriaUnityLoadoutItemFactory _loadoutItemFactory; - private Galaxy ObservedGalaxy { get; set; } private Zone Zone { get; set; } private readonly AetheriaUnityDragSession _dragSession = new AetheriaUnityDragSession(); @@ -299,7 +291,12 @@ public class ActionGameManager : MonoBehaviour var boot = GameplayBootShell.Boot(); ItemManager = boot.ItemManager; _loadoutItemFactory = boot.LoadoutItemFactory; - ObservedGalaxy = boot.ObservedGalaxy; + ObservedZoneContextFactory = new AetheriaUnityObservedZoneContextFactory( + ItemManager, + Settings.PlanetSettings, + boot.ObservedGalaxy, + Debug.LogWarning, + PlayMusic); SceneWiring.ConfigureCurrentEntityPresentation(_currentEntityPresentation, boot.RuntimeCatalog); SceneWiring.ConfigureTargetPresentation( _targetPresentation, diff --git a/Assets/Scripts/Gameplay/AetheriaUnityObservedZoneContextFactory.cs b/Assets/Scripts/Gameplay/AetheriaUnityObservedZoneContextFactory.cs index 329d5d689..1a6317d1a 100644 --- a/Assets/Scripts/Gameplay/AetheriaUnityObservedZoneContextFactory.cs +++ b/Assets/Scripts/Gameplay/AetheriaUnityObservedZoneContextFactory.cs @@ -15,21 +15,20 @@ public sealed class AetheriaUnityObservedZoneContextFactory private readonly Dictionary _observedZoneContextsByDaemonIndex = new Dictionary(); private readonly ItemManager _itemManager; private readonly PlanetSettings _planetSettings; - private readonly Func _resolveObservedGalaxy; private readonly Action _logWarning; private readonly Action _playMusic; - private Galaxy _observedGalaxy; + private readonly Galaxy _observedGalaxy; public AetheriaUnityObservedZoneContextFactory( ItemManager itemManager, PlanetSettings planetSettings, - Func resolveObservedGalaxy, + Galaxy observedGalaxy, Action logWarning, Action playMusic) { _itemManager = itemManager ?? throw new ArgumentNullException(nameof(itemManager)); _planetSettings = planetSettings ?? throw new ArgumentNullException(nameof(planetSettings)); - _resolveObservedGalaxy = resolveObservedGalaxy ?? (() => null); + _observedGalaxy = observedGalaxy; _logWarning = logWarning ?? (_ => { }); _playMusic = playMusic ?? (_ => { }); } @@ -50,7 +49,6 @@ public sealed class AetheriaUnityObservedZoneContextFactory var zoneIndex = render.ZoneIndex; if (!_observedZoneContextsByDaemonIndex.TryGetValue(zoneIndex, out var observedZoneContext)) { - _observedGalaxy = _resolveObservedGalaxy(); if (_observedGalaxy == null) { _logWarning($"Daemon-authoritative zone population suppressed for {galaxyZone.Name}; no observed sector projection is available."); @@ -72,7 +70,6 @@ public sealed class AetheriaUnityObservedZoneContextFactory if (daemonZoneIndex < 0) return null; - _observedGalaxy ??= _resolveObservedGalaxy(); return _observedGalaxy?.Zones?.FirstOrDefault(zone => zone != null && zone.ZoneIndex == daemonZoneIndex); }