A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(unity): GameRoot shutdown restores the terrain pixel error (Task 24 review M1)
eyalgolan2c77a0943dcd
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex b827879e7..66c768c13 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -192,6 +192,9 @@ namespace Statecraft.Game.UIfor (int i = owned.Count - 1; i >= 0; i--) owned[i].Dispose();owned.Clear();minimap = null; rig = null; drawn = null; logCamera = false;+ // A ?profile run cut short (a stopped coroutine never reaches its restore line) must not leave the terrain at the+ // profile's pixel error (Task 24 review M1). Nothing else changes it, so restoring is always right.+ if (map != null && map.Terrain != null) map.Terrain.heightmapPixelError = MapBuilder.TerrainPixelError;}/// <summary>Draws the placements only when State.Placements differs from what was drawn (every order and every turndiff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.csindex 62114cc6d..7bcd11ff7 100644--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs@@ -478,4 +478,16 @@ public class GameSceneTestsAssert.IsFalse(GameRoot.CameraLogRequested(null, new[] { "x" }, false));Assert.AreEqual("CAMERA distance=120000 yaw=0.0", GameRoot.CameraLine(120000f, 0f));}++ /// <summary>Task 24 review M1: a profile cut short (GameRoot disabled or restarted while ?profile runs; a stopped+ /// coroutine never reaches its restore line) does not leave the terrain at the profile's pixel error.</summary>+ [Test]+ public void ShuttingDownRestoresTheTerrainPixelError()+ {+ var root = Boot();+ var terrain = Object.FindFirstObjectByType<MapScene>().Terrain;+ terrain.heightmapPixelError = 5f; // where an interrupted profile leaves it+ root.enabled = false;+ Assert.AreEqual(MapBuilder.TerrainPixelError, terrain.heightmapPixelError);+ }}