A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(map): clear error for a scene without MapScene, unambiguous Ramla label, independent overlay probes
eyalgolanf6aa1e9094d6
diff --git a/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md b/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.mdindex 8b9deebc8..d9d3a58a2 100644--- a/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md+++ b/docs/superpowers/plans/2026-10-09-statecraft-m0-m2.md@@ -6277,6 +6277,7 @@ Each item below is in the spec and has a home. None is silently dropped.| Per-era art prefabs that replace the M2 placeholder markers; in-game portrait pipeline | M3–M4 || Steam page and AI-disclosure manifest | M5 || Legal review of map data licences before release: IMS station rainfall from data.gov.il is labelled "Other (Open)" with no licence URL (content/map/precip_stations.json); CHELSA is CC0; Copernicus DEM attribution | M5 (release pipeline) |+| Profile terrain `heightmapPixelError = 1` (needed so the hex overlay drape stays visible) on the WebGL target; measured only on macOS batch mode (+2 ms/frame flythrough) | M3 (first player build) || Open fact: how the budget was approved in 1948–56 (`open_questions: [budget_approval]` is pinned by a test) | Content work before M4 || Hebrew names (`name_he`) and birth/death dates for people (spec §5.3) | Content work before M4 || "Military or economic collapse ends the state" (spec §4) | M4 |diff --git a/unity/Assets/Editor/MapCapture.cs b/unity/Assets/Editor/MapCapture.csindex 471e91e0c..dfe1df0bf 100644--- a/unity/Assets/Editor/MapCapture.cs+++ b/unity/Assets/Editor/MapCapture.cs@@ -31,7 +31,17 @@ public static class MapCapture{if (AssetDatabase.LoadAssetAtPath<SceneAsset>(ScenePath) == null) MakeScene();else EditorSceneManager.OpenScene(ScenePath, OpenSceneMode.Single);- var map = Object.FindFirstObjectByType<MapScene>(); map.Build();+ var map = RequireMapScene(); map.Build();+ return map;+ }++ /// <summary>The open scene's MapScene; throws naming the scene and the fix when there is none.</summary>+ public static MapScene RequireMapScene()+ {+ var map = Object.FindFirstObjectByType<MapScene>();+ if (map == null)+ throw new System.InvalidOperationException($"{ScenePath} has no MapScene component. Delete {ScenePath} so the next " ++ "capture recreates it, or run MapCapture.MakeScene.");return map;}diff --git a/unity/Assets/Scripts/Map/SettlementPlacer.cs b/unity/Assets/Scripts/Map/SettlementPlacer.csindex b3a5e0360..16c4758bb 100644--- a/unity/Assets/Scripts/Map/SettlementPlacer.cs+++ b/unity/Assets/Scripts/Map/SettlementPlacer.cs@@ -37,11 +37,15 @@ namespace Statecraft.Game.Map// instead of centring on the marker.static readonly Dictionary<string, TextAnchor> LabelAnchor = new Dictionary<string, TextAnchor>{- ["jaffa"] = TextAnchor.LowerRight, ["rishon_lezion"] = TextAnchor.LowerRight, ["ramla"] = TextAnchor.LowerRight,+ ["jaffa"] = TextAnchor.LowerRight, ["rishon_lezion"] = TextAnchor.LowerRight,["lod"] = TextAnchor.LowerLeft, ["petah_tikva"] = TextAnchor.LowerLeft,["safed"] = TextAnchor.LowerRight, ["rosh_pinna"] = TextAnchor.LowerLeft,};+ // East offset (m) of a label from its marker. Ramla sits between Rishon LeZion (west) and Lod (north-east): centred+ // and nudged west, its label stays over its own marker and clear of both neighbours' boxes.+ static readonly Dictionary<string, float> LabelOffsetEastM = new Dictionary<string, float> { ["ramla"] = -1500f };+public const int LabelFontSize = 64; // glyph raster size; characterSize scales it to world metrespublic const float CapHeightPerUnit = 4.5f; // cap height (m) per unit of characterSize at LabelFontSizepublic const float LabelLift = 0.75f; // label base above the marker top, in box edges: clears the box's far top edge at the rig pitch@@ -111,7 +115,9 @@ namespace Statecraft.Game.Mapvar anchor = LabelAnchor.TryGetValue(s.Id, out var a) ? a : TextAnchor.LowerCenter;var label = MakeText(s.Id + "_label", s.Name, font, cap, anchor, LabelColour);- label.transform.SetPositionAndRotation(p + Vector3.up * h * (1f + LabelLift), Quaternion.Euler(CameraRig.Pitch, 0, 0));+ var east = LabelOffsetEastM.TryGetValue(s.Id, out var dx) ? dx : 0f;+ label.transform.SetPositionAndRotation(p + Vector3.up * h * (1f + LabelLift) + Vector3.right * east,+ Quaternion.Euler(CameraRig.Pitch, 0, 0));label.transform.SetParent(parent, true);var shadow = MakeText("shadow", s.Name, font, cap, anchor, ShadowColour);shadow.transform.SetParent(label.transform, false);diff --git a/unity/Assets/Tests/EditMode/MapTests.cs b/unity/Assets/Tests/EditMode/MapTests.csindex ddee3a900..d02268090 100644--- a/unity/Assets/Tests/EditMode/MapTests.cs+++ b/unity/Assets/Tests/EditMode/MapTests.cs@@ -139,6 +139,16 @@ public class MapTestsfinally { Object.DestroyImmediate(go); }}+ // k/7 and k/13 share no interior point with the builder's t/16 sampling grid, so the test does not mirror it.+ static readonly float[] SegmentProbes = Probes();+ static float[] Probes()+ {+ var l = new System.Collections.Generic.List<float>();+ for (int k = 1; k < 7; k++) l.Add(k / 7f);+ for (int k = 1; k < 13; k++) l.Add(k / 13f);+ return l.ToArray();+ }+[Test]public void EveryPointAlongEveryOverlaySegmentLiesAboveTheTerrain(){@@ -152,9 +162,9 @@ public class MapTestsvar verts = mesh.vertices; var idx = mesh.GetIndices(0);int hidden = 0; float worst = 0f;for (int i = 0; i < idx.Length; i += 2)- for (int k = 1; k < 8; k++)+ foreach (var t in SegmentProbes){- var p = Vector3.Lerp(verts[idx[i]], verts[idx[i + 1]], k / 8f);+ var p = Vector3.Lerp(verts[idx[i]], verts[idx[i + 1]], t);float deficit = data.GetInterpolatedHeight(p.x / data.size.x, p.z / data.size.z) - p.y;if (deficit >= 0f) hidden++;worst = Mathf.Max(worst, deficit);diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs b/unity/Assets/Tests/EditMode/SettlementTests.csindex 59906004c..333e5bcde 100644--- a/unity/Assets/Tests/EditMode/SettlementTests.cs+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs@@ -235,4 +235,61 @@ public class MapSceneTestsAssert.Greater(Vector3.Dot(shadow.position - label.position, cam.forward), 0f, s.Id + " shadow behind the label");}}++ [Test]+ public void CaptureOfASceneWithoutMapSceneNamesTheSceneAndTheFix()+ {+ // MapCapture lives in the predefined editor assembly, which an asmdef cannot reference, so reach it by reflection.+ var capture = System.Type.GetType("MapCapture, Assembly-CSharp-Editor");+ Assert.IsNotNull(capture, "MapCapture type");+ var require = capture.GetMethod("RequireMapScene"); Assert.IsNotNull(require, "MapCapture.RequireMapScene");+ var ex = Assert.Throws<System.Reflection.TargetInvocationException>(() => require.Invoke(null, null));+ Assert.IsInstanceOf<System.InvalidOperationException>(ex.InnerException);+ StringAssert.Contains("Assets/Map.unity", ex.InnerException.Message);+ StringAssert.Contains("MakeScene", ex.InnerException.Message);+ }++ static readonly string[] TelAvivCluster = { "tel_aviv", "jaffa", "petah_tikva", "rishon_lezion", "lod", "ramla", "rehovot" };++ static Rect ScreenRect(Camera cam, Bounds b)+ {+ float x0 = float.MaxValue, y0 = float.MaxValue, x1 = float.MinValue, y1 = float.MinValue;+ for (int i = 0; i < 8; i++)+ {+ var c = b.center + Vector3.Scale(b.extents, new Vector3((i & 1) == 0 ? -1 : 1, (i & 2) == 0 ? -1 : 1, (i & 4) == 0 ? -1 : 1));+ var p = cam.WorldToScreenPoint(c);+ x0 = Mathf.Min(x0, p.x); y0 = Mathf.Min(y0, p.y); x1 = Mathf.Max(x1, p.x); y1 = Mathf.Max(y1, p.y);+ }+ return Rect.MinMaxRect(x0, y0, x1, y1);+ }++ static float Gap(Rect a, Rect b) =>+ new Vector2(Mathf.Max(0, Mathf.Max(a.xMin - b.xMax, b.xMin - a.xMax)), Mathf.Max(0, Mathf.Max(a.yMin - b.yMax, b.yMin - a.yMax))).magnitude;++ [Test]+ public void EveryTelAvivClusterLabelIsUnambiguouslyClosestToItsOwnMarker()+ {+ // At flythrough frame 120 (1080p), each label's screen box must be at most half as far from its own marker as from+ // any other marker of the cluster, so no label reads as a neighbour's.+ var map = NewMap(); map.Build();+ var cam = Camera.main; var rig = cam.GetComponent<CameraRig>();+ var rt = new RenderTexture(1920, 1080, 24); cam.targetTexture = rt;+ try+ {+ rig.LookAt = map.Frame.ToWorld(34.95, 31.3 + (32.9 - 31.3) * 120 / 239.0, 0); rig.Distance = 90000f; rig.Apply();+ var root = GameObject.Find("Settlements").transform;+ foreach (var id in TelAvivCluster)+ {+ var label = ScreenRect(cam, root.Find(id + "_label").GetComponent<MeshRenderer>().bounds);+ float own = Gap(label, ScreenRect(cam, root.Find(id).GetComponent<MeshRenderer>().bounds));+ foreach (var other in TelAvivCluster)+ {+ if (other == id) continue;+ float gap = Gap(label, ScreenRect(cam, root.Find(other).GetComponent<MeshRenderer>().bounds));+ Assert.Greater(gap, 2f * own + 4f, $"{id} label is {own:F0} px from its marker but {gap:F0} px from {other}'s");+ }+ }+ }+ finally { cam.targetTexture = null; Object.DestroyImmediate(rt); }+ }}