From a2ce1b27d9ddf234abe0c8be2755fa6a77962296 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 21 Jun 2026 18:48:06 +0100 Subject: [PATCH] Stop rebuilding Unity zone entity membership --- Aetheria.State.Verify/Program.cs | 13 ++++--------- Assets/Scripts/Gameplay/ActionGameManager.cs | 12 ++---------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index d5939a570..eb5d22b36 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -7755,7 +7755,7 @@ static void RequireMainMenuContinueRunState(string root) "CanApplyDaemonEntitySnapshotsInPlace", "ZoneRenderer?.ApplyDaemonFrame(daemonZone, run)", "ApplyDaemonEntitySnapshotsInPlace", - "ReplaceZoneEntitiesFromTypedSnapshots", + "ReplaceObservedEntityFacadesFromTypedSnapshots", "RestoreCurrentEntityBinding", "RestoreCurrentEntityBinding(currentEntity, actionBarBindings)", "RestoreActiveConsumablesFromTypedEntitySnapshot(entity, entitySnapshot)", @@ -8070,7 +8070,7 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) "daemonZone?.Orbits ?? Array.Empty()", "ZoneRenderer.TryGetBodyView(parentOrbitPlanetBodyKey, out var parentBodyView)", "ResolveDaemonObserver()?.LastObservedState?.Run", - "ReplaceZoneEntitiesFromTypedSnapshots", + "ReplaceObservedEntityFacadesFromTypedSnapshots", "EntityConstructionBlueprintProjector.ProjectObservedFromBlueprint", "public static Galaxy ObservedGalaxy", "TryRequestDaemonMoveVector", @@ -8134,20 +8134,15 @@ static void RequireUnityObserverDoesNotTickLocalSimulation(string root) "Unity frame application must project observed daemon state, not instantiate authoritative gameplay entities."); } - var permittedEntityProjectionMethods = new[] - { - "ReplaceZoneEntitiesFromTypedSnapshots" - }; var unauthorizedEntityProjectionHits = FindMethodScopedLineHits( actionGameManager, - new[] { "Zone.Entities.Add(", "Zone.Entities.Remove(" }) - .Where(hit => !permittedEntityProjectionMethods.Contains(hit.MethodName, StringComparer.Ordinal)) + new[] { "Zone.Entities.Add(", "Zone.Entities.Remove(", "Zone.Agents.Clear()" }) .Select(hit => $"{hit.MethodName}:{hit.LineNumber}: {hit.Line.Trim()}") .ToArray(); if (unauthorizedEntityProjectionHits.Length > 0) { throw new InvalidOperationException( - "Unity gameplay may only add/remove zone entities while lowering observed daemon snapshots: " + + "Unity gameplay must not rebuild renderer-local Zone entity membership while lowering daemon snapshots: " + string.Join("; ", unauthorizedEntityProjectionHits)); } diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 51f681b9d..8e9d3de9e 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -2261,7 +2261,7 @@ public class ActionGameManager : MonoBehaviour .Select(ToActionBarBindingSnapshot) .Where(binding => binding != null) .ToArray() ?? Array.Empty(); - ReplaceZoneEntitiesFromTypedSnapshots(entitySnapshots, currentEntityKey, actionBarBindings); + ReplaceObservedEntityFacadesFromTypedSnapshots(entitySnapshots, currentEntityKey, actionBarBindings); ZoneRenderer?.ApplyDaemonFrame(daemonZone, run); RestoreDroppedPickupsFromDaemonZoneState(daemonZone); _lastAppliedAuthoritativeDaemonRunId = runId; @@ -2718,17 +2718,11 @@ public class ActionGameManager : MonoBehaviour } } - private void ReplaceZoneEntitiesFromTypedSnapshots( + private void ReplaceObservedEntityFacadesFromTypedSnapshots( IReadOnlyList entitySnapshots, string currentEntityKey, IReadOnlyList actionBarBindings) { - foreach (var existingEntity in Zone.Entities.ToArray()) - { - Zone.Entities.Remove(existingEntity); - } - Zone.Agents.Clear(); - var restoredEntities = new Dictionary(); foreach (var entitySnapshot in entitySnapshots) { @@ -2752,8 +2746,6 @@ public class ActionGameManager : MonoBehaviour entity.TractorPower = (float)entitySnapshot.TractorPower; entity.RestoreActiveState(entitySnapshot.IsActive); entity.DaemonEntityIndex = EntityIndexFromRecordKey(entitySnapshot.RecordKey); - entity.Zone = Zone; - Zone.Entities.Add(entity); restoredEntities[entitySnapshot.RecordKey] = entity; }