A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Keep gdd-0.3 gameplay facing north (#1908)
Eyal Golan6d55f640502d
diff --git a/changelog.d/1720-camera.md b/changelog.d/1720-camera.mdnew file mode 100644index 000000000..d9db1baf7--- /dev/null+++ b/changelog.d/1720-camera.md@@ -0,0 +1,3 @@+### Changed++- Keep the gdd-0.3 gameplay camera facing north while retaining pan and the existing 6 to 250 km zoom. Legacy and gdd-0.1 retain orbit.diff --git a/docs/rules/mvp.md b/docs/rules/mvp.mdindex fc0483901..768e71ac3 100644--- a/docs/rules/mvp.md+++ b/docs/rules/mvp.md@@ -509,6 +509,10 @@ R-ALT-011: A shareable build refuses while any consequence card, or any event wiR-ALT-012: The historical run (the reference player's orders from 15 May 1948 to 15 January 1952) raises no consequence card and diverges nowhere.+## Gameplay camera (gdd-0.3 only)++R-CAMERA-001: Only exact `gdd-0.3` fixes gameplay yaw at zero (north), including entry, input frames and minimap settling. Orbit input has no effect. Legacy and gdd-0.1 retain orbit. Pan, the 30 px drag onset, fixed pitch and view-axis zoom retain their existing behavior, rates and 6 to 250 km distance range. Explicit promo poses remain separate. Heading and zoom: owner ruling, 27 October 2026, #1720. Camp marker and label dimensions remain subject to measurement and owner approval.+## Population identity foundation (gdd-0.3 only)These contracts cover #1689 steps 1–2 only. Production era selection, Food consumption and command/save/reload integration remain held; helper coverage does not complete #1689. See [population-ledger.md](../population-ledger.md).diff --git a/sim/Statecraft.Sim.Tests/CameraHeadingPolicyTests.cs b/sim/Statecraft.Sim.Tests/CameraHeadingPolicyTests.csnew file mode 100644index 000000000..9a88f48be--- /dev/null+++ b/sim/Statecraft.Sim.Tests/CameraHeadingPolicyTests.cs@@ -0,0 +1,20 @@+using Statecraft.Game.UI;++namespace Statecraft.Sim.Tests;++public class CameraHeadingPolicyTests+{+ // R-CAMERA-001+ [Theory]+ [InlineData("legacy", false)]+ [InlineData("gdd-0.1", false)]+ [InlineData("gdd-0.3", true)]+ [InlineData("gdd-0.30", false)]+ [InlineData("gdd-0.3 ", false)]+ [InlineData(" gdd-0.3", false)]+ [InlineData("GDD-0.3", false)]+ [InlineData("gdd-0.3-preview", false)]+ [InlineData("", false)]+ public void OnlyTheExactRulesetFixesNorth(string ruleset, bool expected) =>+ Assert.Equal(expected, CameraHeadingPolicy.IsFixedNorth(ruleset));+}diff --git a/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj b/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csprojindex fdf4287ee..7200b6191 100644--- a/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj+++ b/sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj@@ -15,6 +15,7 @@</ItemGroup><ItemGroup><Compile Include="../../unity/Assets/Scripts/UI/StockMeter.cs" Link="Presentation/StockMeter.cs" />+ <Compile Include="../../unity/Assets/Scripts/UI/CameraHeadingPolicy.cs" Link="Presentation/CameraHeadingPolicy.cs" /></ItemGroup><ItemGroup><Using Include="Xunit" />diff --git a/tools/tests/test_population_hash_cleanup.py b/tools/tests/test_population_hash_cleanup.pyindex 52ad86748..8023b94f0 100644--- a/tools/tests/test_population_hash_cleanup.py+++ b/tools/tests/test_population_hash_cleanup.py@@ -24,10 +24,13 @@ def test_population_hash_check_cleans_its_copy_on_success_and_failure(tmp_path,repo = root / "repo"shutil.copytree(REPO / "sim", repo / "sim", ignore=shutil.ignore_patterns("bin", "obj", "TestResults"))shutil.copytree(REPO / "content", repo / "content")- # The managed HUD tests compile the real Unity-free formatter via a linked source.- formatter = Path("unity/Assets/Scripts/UI/StockMeter.cs")- (repo / formatter).parent.mkdir(parents=True)- shutil.copyfile(REPO / formatter, repo / formatter)+ # The managed tests compile some real Unity-free sources through links outside sim/; copy each one.+ project = REPO / "sim/Statecraft.Sim.Tests/Statecraft.Sim.Tests.csproj"+ for item in ET.parse(project).getroot().iter("Compile"):+ linked = (project.parent / item.get("Include", "")).resolve().relative_to(REPO)+ if linked.parts[0] != "sim":+ (repo / linked).parent.mkdir(parents=True, exist_ok=True)+ shutil.copyfile(REPO / linked, repo / linked)source = repo / "sim/Statecraft.Sim.Tests/SaveGameTests.cs"text = source.read_text(encoding="utf-8")diff --git a/unity/Assets/Scripts/Map/CameraController.cs b/unity/Assets/Scripts/Map/CameraController.csindex 0721a663f..c32f975e6 100644--- a/unity/Assets/Scripts/Map/CameraController.cs+++ b/unity/Assets/Scripts/Map/CameraController.cs@@ -94,6 +94,18 @@ namespace Statecraft.Game.Mapinternal Func<float> TrackpadMagnification = DrainTrackpadMagnification;CameraRig rig = null!;+ /// <summary>Gameplay heading policy supplied by GameRoot, separate from explicit promo poses.</summary>+ internal bool FixedNorth { get; private set; }++ internal void SetFixedNorth(bool value)+ {+ FixedNorth = value;+ if (!value) return;+ var view = GetComponent<CameraRig>();+ view.Yaw = 0f;+ view.Apply();+ }+InputAction? pan, dragPan, zoom, zoomKeys, orbit;InputAction? mousePress, mousePosition, touchPress, touchPosition;@@ -187,7 +199,7 @@ namespace Statecraft.Game.Mapvar modifier = ModifierHeld(Keyboard.current);var input = Gather(pan.ReadValue<Vector2>(), drag, zoomRaw, orbit.ReadValue<float>(), down, pointer, zoomKeys.ReadValue<float>(), modifier);if (down) input.DragFromUi = fromUi; // latched at the actual press, even between camera frames- Step(rig, input, ClampDt(dt), Bounds, Ground, GroundTop);+ Step(rig, input, ClampDt(dt), Bounds, Ground, GroundTop, FixedNorth);}/// <summary>Position history scoped to one press. Begin resets even if release/repress happens between@@ -274,7 +286,7 @@ namespace Statecraft.Game.Map/// <summary>Fits the rig's current pose with no input (review B-m3: a minimap jump goes through the same view fit and/// ground clearance as panning, so no frame shows the map's frame or the inside of a hill).</summary>- public void Settle() => Step(GetComponent<CameraRig>(), default, 0f, Bounds, Ground, GroundTop);+ public void Settle() => Step(GetComponent<CameraRig>(), default, 0f, Bounds, Ground, GroundTop, FixedNorth);/// <summary>The frame's wheel in notches. In WebGL, from the browser's own events (WheelInput.jslib): Unity's player/// takes the smallest delta it has seen since the page loaded as one notch, whatever the mode, so a touchpad's@@ -369,19 +381,19 @@ namespace Statecraft.Game.Map// notch; in WebGL WheelOr counts the browser's events (#43). Clamp bursts.Zoom = Mathf.Clamp(zoomRaw, -3f, 3f),KeyZoom = modifierHeld ? 0f : Mathf.Clamp(zoomKeys, -1f, 1f),- Orbit = orbitValue, OverUi = over, DragFromUi = dragFromUi,+ Orbit = FixedNorth ? 0f : orbitValue, OverUi = over, DragFromUi = dragFromUi,};}/// <summary>Applies one frame of input to the rig and calls rig.Apply(). Pure apart from the rig (and the ground's/// height, when given), so it is testable. <paramref name="groundTop"/>: see GroundTop.</summary>public static void Step(CameraRig rig, CameraInput input, float dt, Rect bounds, Func<Vector2, float>? ground = null,- float groundTop = ShadowFit.GroundY)+ float groundTop = ShadowFit.GroundY, bool fixedNorth = false){// The wheel is the UI's while the pointer is over it; the zoom keys are not (plan amendment A4, as keyboard pan).var zoom = (input.OverUi ? 0f : input.Zoom) + input.KeyZoom * ZoomKeysPerSecond * dt;var drag = input.DragFromUi ? Vector2.zero : input.DragPan;- rig.Yaw = Mathf.Repeat(rig.Yaw + input.Orbit * OrbitDegreesPerSecond * dt, 360f);+ rig.Yaw = fixedNorth ? 0f : Mathf.Repeat(rig.Yaw + input.Orbit * OrbitDegreesPerSecond * dt, 360f);// (1 - step)^zoom: one notch in is exactly ZoomPerStep closer, and n notches out undo n notches in (Task 24 review M3).rig.Distance = Mathf.Clamp(rig.Distance * Mathf.Pow(1f - ZoomPerStep, zoom), MinDistance, MaxDistance);var yaw = Quaternion.Euler(0, rig.Yaw, 0);diff --git a/unity/Assets/Scripts/UI/CameraHeadingPolicy.cs b/unity/Assets/Scripts/UI/CameraHeadingPolicy.csnew file mode 100644index 000000000..8d5941931--- /dev/null+++ b/unity/Assets/Scripts/UI/CameraHeadingPolicy.cs@@ -0,0 +1,8 @@+namespace Statecraft.Game.UI+{+ /// <summary>Presentation-only heading selection, shared with the managed contract tests.</summary>+ public static class CameraHeadingPolicy+ {+ public static bool IsFixedNorth(string ruleset) => ruleset == "gdd-0.3";+ }+}diff --git a/unity/Assets/Scripts/UI/CameraHeadingPolicy.cs.meta b/unity/Assets/Scripts/UI/CameraHeadingPolicy.cs.metanew file mode 100644index 000000000..2a21bb9b3--- /dev/null+++ b/unity/Assets/Scripts/UI/CameraHeadingPolicy.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 32b0359392f8427998a62758dc565b36diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex 42c875255..546675991 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -233,6 +233,9 @@ namespace Statecraft.Game.UI: GameStart.Begin(inputs.Content, store, GameStart.NewSeed, notes, text, out resumed));DiagLog.BootPhase($"session started (turn {session.State.Turn}, replayed)");var bridge = Bridge = new SimBridge(session, text);+ var oldFixedNorth = cameraController.FixedNorth;+ ConfigureCameraHeading(cameraController, bridge.Content.Ruleset);+ owned.Add(new Undo(() => cameraController.SetFixedNorth(oldFixedNorth)));if (keep != null) foreach (var order in keep.Queued) bridge.Queue(order); // in their order: each was within the attention leftif (keep != null) foreach (var unit in keep.Skipped) bridge.Skip(unit); // this turn's skips too: no reload, no new turnif (Statecraft.HexTiles.HexTilesLook.Requested()) // opt-in hex-tile map (docs/hex-tiles/README.md); presentation only@@ -780,6 +783,10 @@ namespace Statecraft.Game.UIstatic void HandCursor(bool on) { } // the game ships as the browser build; the editor keeps its own cursor#endif+ // R-CAMERA-001: exact ruleset identity; gdd-0.1 retains orbit.+ internal static void ConfigureCameraHeading(CameraController controller, string ruleset) =>+ controller.SetFixedNorth(CameraHeadingPolicy.IsFixedNorth(ruleset));+/// <summary>Disposes every presenter, the autosave and the camera/pointer hooks (newest first). Safe to call twice.</summary>void Shutdown(){diff --git a/unity/Assets/Tests/EditMode/FixedNorthCameraTests.cs b/unity/Assets/Tests/EditMode/FixedNorthCameraTests.csnew file mode 100644index 000000000..b21251ecb--- /dev/null+++ b/unity/Assets/Tests/EditMode/FixedNorthCameraTests.cs@@ -0,0 +1,169 @@+#nullable enable+using NUnit.Framework;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor;+using UnityEngine;+using UnityEngine.InputSystem;++// R-CAMERA-001: owner ruling, 27 October 2026, #1720.+public class FixedNorthCameraTests : InputTestFixture+{+ GameObject go = null!;+ CameraRig rig = null!;+ CameraController controller = null!;+ InputActionAsset actions = null!;++ static void Send(CameraController c, string method) => typeof(CameraController).GetMethod(method,+ System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.Invoke(c, null);++ void Open(string ruleset)+ {+ // The persisted shipped asset, as CameraInputTests uses it; InputTestFixture restores the input system.+ actions = AssetDatabase.LoadAssetAtPath<InputActionAsset>("Assets/InputSystem_Actions.inputactions");+ Assert.IsNotNull(actions, "the shipped input asset must exist");+ InputSystem.actions = actions;+ go = new GameObject("FixedNorthCamera", typeof(Camera), typeof(CameraRig));+ rig = go.GetComponent<CameraRig>();+ rig.LookAt = new Vector3(500000, 0, 500000); rig.Distance = 100000f; rig.Yaw = 37f;+ controller = go.AddComponent<CameraController>();+ controller.Bounds = new Rect(0, 0, 1000000, 1000000);+ GameRoot.ConfigureCameraHeading(controller, ruleset);+ Send(controller, "Awake"); Send(controller, "OnEnable");+ }++ void Close()+ {+ try+ {+ if (controller != null) Send(controller, "OnDisable");+ }+ finally+ {+ if (go != null) Object.DestroyImmediate(go);+ go = null!; controller = null!;+ }+ }++ [TestCase(false)]+ [TestCase(true)]+ public void Gdd03KeyboardOrbitCannotTurnNorth(bool clockwise)+ {+ var keyboard = InputSystem.AddDevice<Keyboard>();+ Open(SaveGame.Gdd03Ruleset);+ try+ {+ Assert.AreEqual(0f, rig.Yaw, "entering gameplay resets an inherited heading immediately");+ Press(clockwise ? keyboard.eKey : keyboard.qKey);+ for (int i = 0; i < 10; i++) controller.Tick(0.1f);+ Assert.AreEqual(0f, rig.Yaw);+ }+ finally { Close(); }+ }++ [TestCase("legacy")]+ [TestCase("gdd-0.1")]+ public void OlderRulesetsKeepTheExistingOrbit(string ruleset)+ {+ var keyboard = InputSystem.AddDevice<Keyboard>();+ Open(ruleset);+ try+ {+ Assert.AreEqual(37f, rig.Yaw);+ var orbit = actions.FindAction("Camera/Orbit", true);+ Press(keyboard.eKey);+ Assert.AreEqual(1f, orbit.ReadValue<float>(), "E reaches the shipped positive orbit binding");+ controller.Tick(0.1f);+ Assert.AreEqual(43f, rig.Yaw, 0.001f);+ Release(keyboard.eKey); Press(keyboard.qKey);+ Assert.AreEqual(-1f, orbit.ReadValue<float>(), "Q reaches the shipped negative orbit binding");+ controller.Tick(0.1f);+ Assert.AreEqual(37f, rig.Yaw, 0.001f);+ }+ finally { Close(); }+ }++ [TestCase(false)]+ [TestCase(true)]+ public void Gdd03MouseDragPansWithoutOrbit(bool left)+ {+ var mouse = InputSystem.AddDevice<Mouse>();+ Open(SaveGame.Gdd03Ruleset);+ try+ {+ controller.HoldsMouseDrag = () => false;+ Set(mouse.position, new Vector2(400, 400));+ Press(left ? mouse.leftButton : mouse.rightButton); controller.Tick(0.016f);+ Move(mouse.position, new Vector2(450, 400), new Vector2(50, 0)); controller.Tick(0.016f);+ Assert.AreEqual(0f, rig.Yaw);+ Assert.AreEqual(497600f, rig.LookAt.x, 0.1f, "only the 20 px beyond the 30 px onset pan");+ }+ finally { Close(); }+ }++ [Test]+ public void Gdd03TouchDragAndTwistCannotOrbitAndPinchStillZooms()+ {+ InputSystem.AddDevice<Touchscreen>();+ Open(SaveGame.Gdd03Ruleset);+ try+ {+ BeginTouch(1, new Vector2(400, 400)); controller.Tick(0.016f);+ MoveTouch(1, new Vector2(410, 400)); controller.Tick(0.016f);+ Assert.Less(rig.LookAt.x, 500000f, "one finger still pans");+ BeginTouch(2, new Vector2(510, 400)); controller.Tick(0.016f);+ MoveTouch(1, new Vector2(460, 350)); MoveTouch(2, new Vector2(460, 450));+ controller.Tick(0.016f);+ Assert.AreEqual(0f, rig.Yaw, "a two-finger twist has no orbit binding");+ var before = rig.Distance;+ MoveTouch(2, new Vector2(460, 470)); controller.Tick(0.016f);+ Assert.AreEqual(before * Mathf.Pow(0.9f, 0.2f), rig.Distance, 1f);+ Assert.AreEqual(0f, rig.Yaw);+ }+ finally { Close(); }+ }++ [Test]+ public void Gdd03WheelKeysAndTrackpadPinchKeepTheirExistingRates()+ {+ var mouse = InputSystem.AddDevice<Mouse>();+ var keyboard = InputSystem.AddDevice<Keyboard>();+ Open(SaveGame.Gdd03Ruleset);+ try+ {+ Set(mouse.position, new Vector2(400, 400)); controller.Tick(0.016f);+ Set(mouse.scroll, new Vector2(0, 1)); controller.Tick(0.016f);+ Assert.AreEqual(90000f, rig.Distance, 1f);+ Set(mouse.scroll, Vector2.zero);+ Press(keyboard.equalsKey); controller.Tick(0.1f); Release(keyboard.equalsKey);+ var expected = 90000f * Mathf.Pow(0.9f, 0.6f);+ Assert.AreEqual(expected, rig.Distance, 1f);+ float pending = 0.05f;+ controller.TrackpadMagnification = () => { var value = pending; pending = 0; return value; };+ controller.Tick(0.016f); controller.Tick(0.016f);+ Assert.AreEqual(expected / 1.05f, rig.Distance, 1f, "magnification is consumed once");+ Assert.AreEqual(0f, rig.Yaw);+ }+ finally { Close(); }+ }++ [Test]+ public void FixedNorthStepAndSettleRepairYawAndPolicyCanBeReleased()+ {+ Open(SaveGame.Gdd03Ruleset);+ try+ {+ rig.Yaw = 91f; controller.Settle(); Assert.AreEqual(0f, rig.Yaw);+ rig.Yaw = 123f;+ CameraController.Step(rig, new CameraInput { Orbit = 1 }, 0.1f, controller.Bounds, fixedNorth: true);+ Assert.AreEqual(0f, rig.Yaw, "Step defends against input bypassing Gather");+ GameRoot.ConfigureCameraHeading(controller, SaveGame.LegacyRuleset);+ var input = controller.Gather(Vector2.zero, Vector2.zero, 0, 1, false, null);+ CameraController.Step(rig, input, 0.1f, controller.Bounds);+ Assert.AreEqual(6f, rig.Yaw, 0.001f, "policy release restores orbit");+ }+ finally { Close(); }+ }++}diff --git a/unity/Assets/Tests/EditMode/FixedNorthCameraTests.cs.meta b/unity/Assets/Tests/EditMode/FixedNorthCameraTests.cs.metanew file mode 100644index 000000000..37ee095fe--- /dev/null+++ b/unity/Assets/Tests/EditMode/FixedNorthCameraTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: a0d87caa1569440b893bfe596315a209diff --git a/unity/Assets/Tests/EditMode/FixedNorthGameRootTests.cs b/unity/Assets/Tests/EditMode/FixedNorthGameRootTests.csnew file mode 100644index 000000000..e97cf0433--- /dev/null+++ b/unity/Assets/Tests/EditMode/FixedNorthGameRootTests.cs@@ -0,0 +1,198 @@+#nullable enable+using System;+using System.Collections;+using System.IO;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Boot;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor.SceneManagement;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++public class FixedNorthGameRootTests+{+ string saveDir = "";+ GameRoot game = null!;+ CameraController controller = null!;+ CameraRig rig = null!;+ VisualElement ui = null!;+ GameInputs inputs = null!;++ [SetUp]+ public void TempSaves() => saveDir = Path.Combine(Path.GetTempPath(), "statecraft-heading-" + Guid.NewGuid().ToString("N"));++ [TearDown]+ public void Close()+ {+ // Release owned policy while the scene's camera controller is still alive.+ if (game != null) Object.DestroyImmediate(game);+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);+ VisualToggles.Clear();+ }++ void Open(string ruleset, bool oldPolicy = false)+ {+ // Fresh inputs: never change the shared MapFocusTests content or any file on disk.+ inputs = GameInputs.FromDisk(Paths.Content, Paths.StreamingMap);+ foreach (var era in inputs.Content.Eras)+ {+ era.Systems.Ruleset = ruleset;+ era.Systems.Loop = ruleset == SaveGame.LegacyRuleset ? EraSystems.Legacy : EraSystems.Gdd;+ }+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ Object.FindFirstObjectByType<MapScene>().Build(inputs.Map);+ game = Object.FindFirstObjectByType<GameRoot>();+ game.Store = new SaveStore(saveDir);+ game.Language = UiLanguage.English;+ controller = Camera.main.GetComponent<CameraController>();+ rig = controller.GetComponent<CameraRig>();+ controller.SetFixedNorth(oldPolicy);+ rig.Yaw = 37f; rig.Apply();+ ui = Object.FindFirstObjectByType<UIDocument>().rootVisualElement;+ Assert.IsNotNull(ui.panel, "GameRoot integration needs a real panel");+ }++ void Heading(bool north)+ {+ Assert.AreEqual(north, controller.FixedNorth);+ if (north)+ {+ Assert.AreEqual(0f, rig.Yaw);+ Assert.AreEqual(0f, rig.transform.forward.x, 0.00001f);+ Assert.Greater(rig.transform.forward.z, 0f, "north-up minimap and camera agree");+ Assert.Less(rig.transform.forward.y, 0f, "fixed pitch looks down");+ }+ }++ [TestCase("legacy", false)]+ [TestCase("legacy", true)]+ [TestCase("gdd-0.1", false)]+ [TestCase("gdd-0.1", true)]+ [TestCase("gdd-0.3", false)]+ [TestCase("gdd-0.3", true)]+ public void BeginReentryAndDisableRestoreTheOwnedPolicy(string ruleset, bool oldPolicy)+ {+ Open(ruleset, oldPolicy);+ bool north = ruleset == SaveGame.Gdd03Ruleset;+ game.Begin(inputs, 0);+ Heading(north);+ if (!north) Assert.AreEqual(37f, rig.Yaw, "Begin must not normalize legacy yaw");+ rig.Yaw = 83f; rig.Apply();+ game.Begin(inputs, 0); // Executes Shutdown and its Undo before registering the next owner.+ Heading(north);+ if (!north && !oldPolicy) Assert.AreEqual(83f, rig.Yaw);+ rig.Yaw = 71f; rig.Apply();+ game.enabled = false; // OnDisable -> Shutdown -> owned Undo.+ Heading(oldPolicy);+ if (!oldPolicy) Assert.AreEqual(71f, rig.Yaw, "release does not apply or normalize yaw");+ game.enabled = true;+ game.Begin(inputs, 0);+ Heading(north);+ Object.DestroyImmediate(game); // Scene teardown uses the same OnDisable path.+ Heading(oldPolicy);+ }++ [TestCase("legacy")]+ [TestCase("gdd-0.1")]+ [TestCase("gdd-0.3")]+ public void NewGameLoadAndLanguageRebuildKeepTheSessionPolicy(string ruleset)+ {+ Open(ruleset);+ var saved = GameSession.New(inputs.Content, 123, Mode.Historical);+ Directory.CreateDirectory(saveDir);+ File.WriteAllText(Path.Combine(saveDir, SaveStore.AutosaveName), saved.Save.Write());+ game.Begin(inputs, 0);+ Assert.AreEqual(saved.State.Hash(), game.Bridge!.State.Hash(), "Begin resumes the isolated autosave");+ bool north = ruleset == SaveGame.Gdd03Ruleset;+ Heading(north);+ var loaded = game.Bridge.Session;+ UiTestKit.Press(ui.Q<Button>("new-game"));+ UiTestKit.Press(ui.Q<Button>("new-game"));+ Assert.AreNotSame(loaded, game.Bridge.Session, "the actual New Game presenter replaced the session");+ Heading(north);+ var keep = game.Bridge;+ typeof(GameRoot).GetMethod("SwitchLanguage", System.Reflection.BindingFlags.Instance |+ System.Reflection.BindingFlags.NonPublic)!.Invoke(game, new object[] { inputs, UiLanguage.Hebrew });+ Assert.AreSame(keep.Session, game.Bridge!.Session, "language rebuild retains the session");+ Heading(north);+ game.enabled = false;+ Assert.IsFalse(controller.FixedNorth);+ }++ [TestCase("legacy")]+ [TestCase("gdd-0.1")]+ public void BeginSwitchesRulesetsOnTheSameController(string olderRuleset)+ {+ Open(SaveGame.Gdd03Ruleset);+ game.Begin(inputs, 0);+ Heading(true);+ var older = GameInputs.FromDisk(Paths.Content, Paths.StreamingMap);+ foreach (var era in older.Content.Eras)+ {+ era.Systems.Ruleset = olderRuleset;+ era.Systems.Loop = olderRuleset == SaveGame.LegacyRuleset ? EraSystems.Legacy : EraSystems.Gdd;+ }+ rig.Yaw = 29f; rig.Apply();+ game.Begin(older, 0);+ Heading(false);+ Assert.AreEqual(29f, rig.Yaw, "releasing the old session does not normalize the next one");+ game.Begin(inputs, 0);+ Heading(true);+ }++ [UnityTest]+ public IEnumerator Gdd03MinimapClickAndOverviewSettleBeforeSyncAndKeepNorth()+ {+ Open(SaveGame.Gdd03Ruleset);+ game.Begin(inputs, 0);+ GameSceneTests.HideTheOpeningCard(ui);+ var image = ui.Q("minimap-image");+ for (int frame = 0; frame < 60 && !(image.layout.width > 0 && image.layout.height > 0); frame++) yield return null;+ Assert.Greater(image.layout.width, 0f, "minimap geometry not ready after 60 frames");+ Assert.Greater(image.layout.height, 0f);+ var view = ui.Q("minimap-view");+ rig.Yaw = 47f; rig.Apply();+ view.style.left = -999f;+ using (var e = PointerDownEvent.GetPooled(new Event+ { type = EventType.MouseDown, button = 0,+ mousePosition = image.worldBound.position + Vector2.Scale(image.worldBound.size, new Vector2(0.1f, 0.1f)) }))+ {+ e.target = image;+ image.SendEvent(e); // The presenter's callback performs Settle then SyncMinimap synchronously.+ }+ Heading(true);+ Assert.AreNotEqual(-999f, view.style.left.value.value, "click synchronized the minimap before returning");+ Assert.That(view.style.left.value.value, Is.InRange(0f, 100f));+ AssertViewMatchesSettledRig(view);+ rig.Yaw = 91f; rig.Apply();+ view.style.left = -999f;+ UiTestKit.Press(ui.Q<Button>("minimap-overview"));+ Heading(true);+ Assert.AreEqual(CameraController.MaxDistance, rig.Distance);+ Assert.AreNotEqual(-999f, view.style.left.value.value, "overview synchronized after settling");+ AssertViewMatchesSettledRig(view);+ }++ void AssertViewMatchesSettledRig(VisualElement view)+ {+ var map = Object.FindFirstObjectByType<MapScene>();+ var b = map.Hexes.bounds;+ var (lon, lat) = map.Frame.ToLonLat(rig.LookAt);+ double widthKm = (b.lon1 - b.lon0) * HexPicker.KmPerDegLon(b.lat0, b.lat1);+ double heightKm = (b.lat1 - b.lat0) * HexPicker.KmPerDegLat;+ float w = Mathf.Min(1f, (float)(1.5 * rig.Distance / 1000 / widthKm));+ float h = Mathf.Min(1f, (float)(rig.Distance / 1000 / heightKm));+ float u = (float)((lon - b.lon0) / (b.lon1 - b.lon0));+ float v = (float)((b.lat1 - lat) / (b.lat1 - b.lat0));+ Assert.AreEqual(Mathf.Clamp(u - w / 2, 0, 1 - w) * 100, view.style.left.value.value, 0.001f);+ Assert.AreEqual(Mathf.Clamp(v - h / 2, 0, 1 - h) * 100, view.style.top.value.value, 0.001f);+ Assert.AreEqual(w * 100, view.style.width.value.value, 0.001f);+ Assert.AreEqual(h * 100, view.style.height.value.value, 0.001f);+ }+}diff --git a/unity/Assets/Tests/EditMode/FixedNorthGameRootTests.cs.meta b/unity/Assets/Tests/EditMode/FixedNorthGameRootTests.cs.metanew file mode 100644index 000000000..837732bf4--- /dev/null+++ b/unity/Assets/Tests/EditMode/FixedNorthGameRootTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 6749f28783884ee983c5599afcc2b4fediff --git a/unity/Assets/Tests/EditMode/MapFocusTests.cs b/unity/Assets/Tests/EditMode/MapFocusTests.csindex 62eaae439..3954dc758 100644--- a/unity/Assets/Tests/EditMode/MapFocusTests.cs+++ b/unity/Assets/Tests/EditMode/MapFocusTests.cs@@ -390,8 +390,12 @@ public class MapFocusCameraKeysTests : InputTestFixture[Test]public void TheCameraKeysStillPanWithTheStopFocused(){- InputSystem.actions = AssetDatabase.LoadAssetAtPath<InputActionAsset>("Assets/InputSystem_Actions.inputactions");+ var actions = AssetDatabase.LoadAssetAtPath<InputActionAsset>("Assets/InputSystem_Actions.inputactions");+ InputSystem.actions = actions;var keyboard = InputSystem.AddDevice<Keyboard>();+ // Resolve the shared asset against this fixture's own keyboard only. Earlier tests can leave it resolved against+ // devices this fixture does not have, and enabling the Camera map then fails (a test isolation issue).+ actions.devices = new InputDevice[] { keyboard };using var kit = new UiTestKit();kit.Q<VisualElement>("root").RemoveFromClassList("loading");var stop = kit.Q<VisualElement>("map-focus");@@ -423,6 +427,6 @@ public class MapFocusCameraKeysTests : InputTestFixtureAssert.AreSame(stop, kit.Root.panel.focusController.focusedElement, "the focus stays on the stop");Assert.AreEqual(0, picked, "a pan picks nothing");}- finally { presenter.Dispose(); Send(c, "OnDisable"); Object.DestroyImmediate(go); }+ finally { presenter.Dispose(); Send(c, "OnDisable"); Object.DestroyImmediate(go); actions.devices = null; }}}