Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

feat(map): 1948 settlements, diorama camera, geography check, flythrough

eyalgolan919a411418af
diff --git a/.gitignore b/.gitignore
index 5b7927e9d..443dfcb0c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,4 @@ unity/*.csproj
unity/*.slnx
unity-*.xml
unity-*.log
+captures/
diff --git a/docs/m2-geography-check.md b/docs/m2-geography-check.md
new file mode 100644
index 000000000..5bc93a12c
--- /dev/null
+++ b/docs/m2-geography-check.md
@@ -0,0 +1,14 @@
+# M2 geography check (captures/topdown.png vs promo/ref/geo-reference.png)
+
+Checked on 2026-10-10 against `captures/topdown.png` (749×2000, `MapCapture.TopDown`, batch mode with graphics), `promo/ref/geo-reference.png` (a schematic, not to scale) and `tools/preview_map.py`'s image. Flythrough frames 0, 120 and 239 were also checked.
+
+- [x] Coast on the west; Carmel ridge reaching the coast at Haifa — PASS. The sea fills the west edge. The Haifa marker sits on the headland, with Haifa Bay and Acre to its north. The Carmel relief runs south-east from it (clearest in flythrough frame 239).
+- [x] Sea of Galilee north-east; Jordan valley running south to the Dead Sea — PASS. The Galilee lake is at about 35.6E 32.8N. A low valley runs south from it to the Dead Sea along the east side of the land.
+- [x] Dead Sea's north tip level with Jerusalem; Jerusalem south-east of Tel Aviv — PASS. In the top-down image the Dead Sea's north tip is at row ≈ 400/1000 and Jerusalem's marker at ≈ 402/1000. Jerusalem is east and south of Tel Aviv.
+- [x] Negev widening to the south; Beersheba inland, south of the coastal plain — PASS, with a note. The coast turns west and leaves the frame near Rafah (31.3N), so the land widens south of it. Beersheba sits inland, just south of where the green coastal plain ends. The Negev's triangle shape is not drawn, because the frame includes Sinai and Jordan with no borders. Known data issue, being fixed elsewhere: this branch's hexes.json still uses the old biome rule, which draws a straight desert edge near 31.25N.
+- [x] Every 1948 settlement marker sits on its correct place (spot-check Tel Aviv, Jaffa, Haifa, Jerusalem, Beersheba, Tiberias) — PASS. The edit-mode test `EveryMarkerSitsOnItsSourcedPositionWithTheMarkerMaterial` checks all 25 markers against `GeoFrame.ToWorld` (within 1 m). By eye: Tel Aviv and Jaffa are on the coast, Jaffa just south; Haifa is at the Carmel tip; Jerusalem is in the hills; Beersheba is inland in the northern Negev; Tiberias is on the Sea of Galilee's west shore. The DEM elevation is above sea or lake level at all 25 points.
+- [x] No settlement in the sea; no hex outline over open sea — PASS. Outlines are drawn only for land hexes. Coastal hexes overhang the shoreline by part of a hex, but none sits over open sea. No marker is on water.
+
+Unity's render and `tools/preview_map.py`'s preview agree on the coastline, the lakes, the Jordan valley and every settlement position. They differ only in biome palette.
+
+Result: PASS (geography). Presentation notes, not blocking: the labels (TextMesh with characterSize 400, per the brief) cannot be read in the top-down image (about 2 px). In the 1920×1080 flythrough they can be read but are small and low in contrast, and the Tel Aviv label is partly hidden by its own box. In the hills, terrain hides parts of some hex outlines (an overlay drape issue from Task 24).
diff --git a/unity/Assets/Editor/MapCapture.cs b/unity/Assets/Editor/MapCapture.cs
new file mode 100644
index 000000000..953405321
--- /dev/null
+++ b/unity/Assets/Editor/MapCapture.cs
@@ -0,0 +1,71 @@
+using System.IO;
+using Statecraft.Game;
+using Statecraft.Game.EditorTools;
+using Statecraft.Game.Map;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+
+/// <summary>Editor capture tools. Run headless (with graphics, not -nographics):
+/// Unity -batchmode -quit -projectPath unity -executeMethod MapCapture.TopDown (or MapCapture.Flythrough).
+/// Captures go to captures/ at the repo root, which git ignores.</summary>
+public static class MapCapture
+{
+ const string ScenePath = "Assets/Map.unity";
+
+ static string CaptureDir => Path.Combine(Paths.RepoRoot, "captures");
+
+ /// <summary>Creates and saves Assets/Map.unity: default camera and light plus a MapScene wired to the material assets.</summary>
+ public static void MakeScene()
+ {
+ MapMaterials.Create();
+ var scene = EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single);
+ new GameObject("MapScene").AddComponent<MapScene>().Configure(
+ Load(MapMaterials.TerrainPath), Load(MapMaterials.OverlayPath), Load(MapMaterials.MarkerPath));
+ EditorSceneManager.SaveScene(scene, ScenePath);
+ }
+
+ static Material Load(string path)
+ {
+ var m = AssetDatabase.LoadAssetAtPath<Material>(path);
+ if (m == null) throw new FileNotFoundException("material asset missing", path);
+ return m;
+ }
+
+ /// <summary>Orthographic straight-down render of the whole map, for comparison with promo/ref/geo-reference.png.</summary>
+ public static void TopDown()
+ {
+ MakeScene();
+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
+ var cam = new GameObject("TopCam").AddComponent<Camera>();
+ var size = map.Terrain.terrainData.size;
+ cam.orthographic = true; cam.orthographicSize = size.z / 2; cam.aspect = size.x / size.z;
+ cam.transform.position = new Vector3(size.x / 2, 100000, size.z / 2); cam.transform.rotation = Quaternion.Euler(90, 0, 0);
+ cam.farClipPlane = 300000;
+ Save(cam, Mathf.RoundToInt(2000 * size.x / size.z), 2000, Path.Combine(CaptureDir, "topdown.png"));
+ }
+
+ /// <summary>240 frames flying north along the coast at diorama pitch; encode with ffmpeg.</summary>
+ public static void Flythrough()
+ {
+ MakeScene();
+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build();
+ var rig = Camera.main.GetComponent<CameraRig>();
+ var dir = Path.Combine(CaptureDir, "fly"); Directory.CreateDirectory(dir);
+ for (int i = 0; i < 240; i++)
+ {
+ double lat = 31.3 + (32.9 - 31.3) * i / 239.0; // from the northern Negev to the Carmel
+ rig.LookAt = map.Frame.ToWorld(34.95, lat, 0); rig.Distance = 90000f; rig.Apply();
+ Save(Camera.main, 1920, 1080, Path.Combine(dir, $"{i:D4}.png"));
+ }
+ }
+
+ static void Save(Camera cam, int w, int h, string path)
+ {
+ var rt = new RenderTexture(w, h, 24); cam.targetTexture = rt; cam.Render();
+ RenderTexture.active = rt; var tex = new Texture2D(w, h, TextureFormat.RGB24, false);
+ tex.ReadPixels(new Rect(0, 0, w, h), 0, 0); tex.Apply();
+ Directory.CreateDirectory(Path.GetDirectoryName(path)); File.WriteAllBytes(path, tex.EncodeToPNG());
+ cam.targetTexture = null; RenderTexture.active = null; Object.DestroyImmediate(rt); Object.DestroyImmediate(tex);
+ }
+}
diff --git a/unity/Assets/Editor/MapCapture.cs.meta b/unity/Assets/Editor/MapCapture.cs.meta
new file mode 100644
index 000000000..b06e62ee6
--- /dev/null
+++ b/unity/Assets/Editor/MapCapture.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c07f41a533c8b43a388c986da7e56834
\ No newline at end of file
diff --git a/unity/Assets/Editor/MapMaterials.cs b/unity/Assets/Editor/MapMaterials.cs
index 1278ef59e..89ff6b03e 100644
--- a/unity/Assets/Editor/MapMaterials.cs
+++ b/unity/Assets/Editor/MapMaterials.cs
@@ -11,6 +11,7 @@ namespace Statecraft.Game.EditorTools
public const string Folder = "Assets/Materials";
public const string TerrainPath = Folder + "/Terrain.mat";
public const string OverlayPath = Folder + "/HexOverlay.mat";
+ public const string MarkerPath = Folder + "/SettlementMarker.mat";
public static void Create()
{
@@ -21,6 +22,10 @@ namespace Statecraft.Game.EditorTools
for (int i = 0; i < 4; i++) { terrain.SetFloat("_Smoothness" + i, 0f); terrain.SetFloat("_Metallic" + i, 0f); }
EditorUtility.SetDirty(terrain);
Make(OverlayPath, "Universal Render Pipeline/Unlit", new Color(0.15f, 0.12f, 0.08f, 1f));
+ // Settlement boxes: matte URP Lit; SettlementPlacer sets the per-type _BaseColor through a MaterialPropertyBlock.
+ var marker = Make(MarkerPath, "Universal Render Pipeline/Lit", Color.white);
+ marker.SetFloat("_Smoothness", 0f); marker.SetFloat("_Metallic", 0f);
+ EditorUtility.SetDirty(marker);
AssetDatabase.SaveAssets();
}
diff --git a/unity/Assets/Map.unity b/unity/Assets/Map.unity
new file mode 100644
index 000000000..231c97bba
--- /dev/null
+++ b/unity/Assets/Map.unity
@@ -0,0 +1,364 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!29 &1
+OcclusionCullingSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 2
+ m_OcclusionBakeSettings:
+ smallestOccluder: 5
+ smallestHole: 0.25
+ backfaceThreshold: 100
+ m_SceneGUID: 00000000000000000000000000000000
+ m_OcclusionCullingData: {fileID: 0}
+--- !u!104 &2
+RenderSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 10
+ m_Fog: 0
+ m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
+ m_FogMode: 3
+ m_FogDensity: 0.01
+ m_LinearFogStart: 0
+ m_LinearFogEnd: 300
+ m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
+ m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
+ m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
+ m_AmbientIntensity: 1
+ m_AmbientMode: 0
+ m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
+ m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
+ m_HaloStrength: 0.5
+ m_FlareStrength: 1
+ m_FlareFadeSpeed: 3
+ m_HaloTexture: {fileID: 0}
+ m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
+ m_DefaultReflectionMode: 0
+ m_DefaultReflectionResolution: 128
+ m_ReflectionBounces: 1
+ m_ReflectionIntensity: 1
+ m_CustomReflection: {fileID: 0}
+ m_Sun: {fileID: 0}
+ m_UseRadianceAmbientProbe: 0
+--- !u!157 &3
+LightmapSettings:
+ m_ObjectHideFlags: 0
+ serializedVersion: 13
+ m_BakeOnSceneLoad: 0
+ m_GISettings:
+ serializedVersion: 2
+ m_BounceScale: 1
+ m_IndirectOutputScale: 1
+ m_AlbedoBoost: 1
+ m_EnvironmentLightingMode: 0
+ m_EnableBakedLightmaps: 1
+ m_EnableRealtimeLightmaps: 0
+ m_LightmapEditorSettings:
+ serializedVersion: 12
+ m_Resolution: 2
+ m_BakeResolution: 40
+ m_AtlasSize: 1024
+ m_AO: 0
+ m_AOMaxDistance: 1
+ m_CompAOExponent: 1
+ m_CompAOExponentDirect: 0
+ m_ExtractAmbientOcclusion: 0
+ m_Padding: 2
+ m_LightmapParameters: {fileID: 0}
+ m_LightmapsBakeMode: 1
+ m_TextureCompression: 1
+ m_ReflectionCompression: 2
+ m_MixedBakeMode: 2
+ m_BakeBackend: 2
+ m_PVRSampling: 1
+ m_PVRDirectSampleCount: 32
+ m_PVRSampleCount: 512
+ m_PVRBounces: 2
+ m_PVREnvironmentSampleCount: 256
+ m_PVREnvironmentReferencePointCount: 2048
+ m_PVRFilteringMode: 1
+ m_PVRDenoiserTypeDirect: 1
+ m_PVRDenoiserTypeIndirect: 1
+ m_PVRDenoiserTypeAO: 1
+ m_PVRFilterTypeDirect: 0
+ m_PVRFilterTypeIndirect: 0
+ m_PVRFilterTypeAO: 0
+ m_PVREnvironmentMIS: 1
+ m_PVRCulling: 1
+ m_PVRFilteringGaussRadiusDirect: 1
+ m_PVRFilteringGaussRadiusIndirect: 1
+ m_PVRFilteringGaussRadiusAO: 1
+ m_PVRFilteringAtrousPositionSigmaDirect: 0.5
+ m_PVRFilteringAtrousPositionSigmaIndirect: 2
+ m_PVRFilteringAtrousPositionSigmaAO: 1
+ m_ExportTrainingData: 0
+ m_TrainingDataDestination: TrainingData
+ m_LightProbeSampleCountMultiplier: 4
+ m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0}
+ m_LightingSettings: {fileID: 0}
+--- !u!196 &4
+NavMeshSettings:
+ serializedVersion: 2
+ m_ObjectHideFlags: 0
+ m_BuildSettings:
+ serializedVersion: 3
+ agentTypeID: 0
+ agentRadius: 0.5
+ agentHeight: 2
+ agentSlope: 45
+ agentClimb: 0.4
+ ledgeDropHeight: 0
+ maxJumpAcrossDistance: 0
+ minRegionArea: 2
+ manualCellSize: 0
+ cellSize: 0.16666667
+ manualTileSize: 0
+ tileSize: 256
+ buildHeightMesh: 0
+ maxJobWorkers: 0
+ preserveTilesOutsideBounds: 0
+ debug:
+ m_Flags: 0
+ m_NavMeshData: {fileID: 0}
+--- !u!1 &375413292
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 375413295}
+ - component: {fileID: 375413294}
+ - component: {fileID: 375413293}
+ m_Layer: 0
+ m_Name: Main Camera
+ m_TagString: MainCamera
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!81 &375413293
+AudioListener:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 375413292}
+ m_Enabled: 1
+--- !u!20 &375413294
+Camera:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 375413292}
+ m_Enabled: 1
+ serializedVersion: 2
+ m_ClearFlags: 1
+ m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
+ m_projectionMatrixMode: 1
+ m_GateFitMode: 2
+ m_FOVAxisMode: 0
+ m_Iso: 200
+ m_ShutterSpeed: 0.005
+ m_Aperture: 16
+ m_FocusDistance: 10
+ m_FocalLength: 50
+ m_BladeCount: 5
+ m_Curvature: {x: 2, y: 11}
+ m_BarrelClipping: 0.25
+ m_Anamorphism: 0
+ m_SensorSize: {x: 36, y: 24}
+ m_LensShift: {x: 0, y: 0}
+ m_NormalizedViewPortRect:
+ serializedVersion: 2
+ x: 0
+ y: 0
+ width: 1
+ height: 1
+ near clip plane: 0.3
+ far clip plane: 1000
+ field of view: 60
+ orthographic: 0
+ orthographic size: 5
+ m_Depth: -1
+ m_CullingMask:
+ serializedVersion: 2
+ m_Bits: 4294967295
+ m_RenderingPath: -1
+ m_TargetTexture: {fileID: 0}
+ m_TargetDisplay: 0
+ m_TargetEye: 3
+ m_HDR: 1
+ m_AllowMSAA: 1
+ m_AllowDynamicResolution: 0
+ m_ForceIntoRT: 0
+ m_OcclusionCulling: 1
+ m_StereoConvergence: 10
+ m_StereoSeparation: 0.022
+--- !u!4 &375413295
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 375413292}
+ serializedVersion: 2
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 1, z: -10}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &632313118
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 632313120}
+ - component: {fileID: 632313119}
+ m_Layer: 0
+ m_Name: MapScene
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!114 &632313119
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 632313118}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: f7b27c26d62c5400c99c12b492a87a6d, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Statecraft.Game::Statecraft.Game.Map.MapScene
+ terrainMaterial: {fileID: 2100000, guid: fc63b910005e64adaaa42ba488bcc248, type: 2}
+ overlayMaterial: {fileID: 2100000, guid: 29dd83b7b3b1f4a4aa5a710be0078164, type: 2}
+ markerMaterial: {fileID: 2100000, guid: 7c65bbd4355344f1990495c458323a4e, type: 2}
+--- !u!4 &632313120
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 632313118}
+ serializedVersion: 2
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!1 &1720501430
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 1720501432}
+ - component: {fileID: 1720501431}
+ m_Layer: 0
+ m_Name: Directional Light
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!108 &1720501431
+Light:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1720501430}
+ m_Enabled: 1
+ serializedVersion: 12
+ m_Type: 1
+ m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
+ m_Intensity: 1
+ m_Range: 10
+ m_SpotAngle: 30
+ m_InnerSpotAngle: 21.80208
+ m_CookieSize2D: {x: 0.5, y: 0.5}
+ m_Shadows:
+ m_Type: 2
+ m_Resolution: -1
+ m_CustomResolution: -1
+ m_Strength: 1
+ m_Bias: 0.05
+ m_NormalBias: 0.4
+ m_NearPlane: 0.2
+ m_CullingMatrixOverride:
+ e00: 1
+ e01: 0
+ e02: 0
+ e03: 0
+ e10: 0
+ e11: 1
+ e12: 0
+ e13: 0
+ e20: 0
+ e21: 0
+ e22: 1
+ e23: 0
+ e30: 0
+ e31: 0
+ e32: 0
+ e33: 1
+ m_UseCullingMatrixOverride: 0
+ m_Cookie: {fileID: 0}
+ m_DrawHalo: 0
+ m_Flare: {fileID: 0}
+ m_RenderMode: 0
+ m_CullingMask:
+ serializedVersion: 2
+ m_Bits: 4294967295
+ m_RenderingLayerMask: 1
+ m_Lightmapping: 4
+ m_LightShadowCasterMode: 0
+ m_AreaSize: {x: 1, y: 1}
+ m_BounceIntensity: 1
+ m_ColorTemperature: 6570
+ m_UseColorTemperature: 0
+ m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
+ m_UseBoundingSphereOverride: 0
+ m_UseViewFrustumForShadowCasterCull: 1
+ m_ForceVisible: 0
+ m_ShadowRadius: 0
+ m_ShadowAngle: 0
+ m_LightUnit: 1
+ m_LuxAtDistance: 1
+ m_EnableSpotReflector: 1
+--- !u!4 &1720501432
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1720501430}
+ serializedVersion: 2
+ m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
+ m_LocalPosition: {x: 0, y: 3, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 0}
+ m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
+--- !u!1660057539 &9223372036854775807
+SceneRoots:
+ m_ObjectHideFlags: 0
+ m_Roots:
+ - {fileID: 375413295}
+ - {fileID: 1720501432}
+ - {fileID: 632313120}
diff --git a/unity/Assets/Map.unity.meta b/unity/Assets/Map.unity.meta
new file mode 100644
index 000000000..bde2772fc
--- /dev/null
+++ b/unity/Assets/Map.unity.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ba558e75af959491ead0de8db10586c1
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Materials/SettlementMarker.mat b/unity/Assets/Materials/SettlementMarker.mat
new file mode 100644
index 000000000..753c4a65f
--- /dev/null
+++ b/unity/Assets/Materials/SettlementMarker.mat
@@ -0,0 +1,137 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &-1123459299496594576
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: SettlementMarker
+ m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords: []
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 1
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap:
+ RenderType: Opaque
+ disabledShaderPasses:
+ - MOTIONVECTORS
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _BaseMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _BumpMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailAlbedoMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailMask:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailNormalMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _EmissionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MetallicGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _OcclusionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _ParallaxMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _SpecGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_Lightmaps:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_LightmapsInd:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_ShadowMasks:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _AddPrecomputedVelocity: 0
+ - _AlphaClip: 0
+ - _AlphaToMask: 0
+ - _Blend: 0
+ - _BlendModePreserveSpecular: 1
+ - _BumpScale: 1
+ - _ClearCoatMask: 0
+ - _ClearCoatSmoothness: 0
+ - _Cull: 2
+ - _Cutoff: 0.5
+ - _DetailAlbedoMapScale: 1
+ - _DetailNormalMapScale: 1
+ - _DstBlend: 0
+ - _DstBlendAlpha: 0
+ - _EnvironmentReflections: 1
+ - _GlossMapScale: 0
+ - _Glossiness: 0
+ - _GlossyReflections: 0
+ - _Metallic: 0
+ - _OcclusionStrength: 1
+ - _Parallax: 0.005
+ - _QueueOffset: 0
+ - _ReceiveShadows: 1
+ - _Smoothness: 0
+ - _SmoothnessTextureChannel: 0
+ - _SpecularHighlights: 1
+ - _SrcBlend: 1
+ - _SrcBlendAlpha: 1
+ - _Surface: 0
+ - _WorkflowMode: 1
+ - _XRMotionVectorsPass: 1
+ - _ZWrite: 1
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ - _Color: {r: 1, g: 1, b: 1, a: 1}
+ - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+ - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
diff --git a/unity/Assets/Materials/SettlementMarker.mat.meta b/unity/Assets/Materials/SettlementMarker.mat.meta
new file mode 100644
index 000000000..11ea3986a
--- /dev/null
+++ b/unity/Assets/Materials/SettlementMarker.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7c65bbd4355344f1990495c458323a4e
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/CameraRig.cs b/unity/Assets/Scripts/Map/CameraRig.cs
new file mode 100644
index 000000000..5a2d5e06f
--- /dev/null
+++ b/unity/Assets/Scripts/Map/CameraRig.cs
@@ -0,0 +1,38 @@
+using UnityEngine;
+using UnityEngine.Rendering;
+using UnityEngine.Rendering.Universal;
+
+namespace Statecraft.Game.Map
+{
+ /// <summary>Diorama camera: fixed 50-degree pitch, 35-degree FOV, Gaussian far blur beyond the look-at point (tilt-shift look).
+ /// Gaussian, not Bokeh: physical Bokeh DoF keeps everything sharp at 100 km focus distances.</summary>
+ public sealed class CameraRig : MonoBehaviour
+ {
+ public const float Pitch = 50f, Fov = 35f;
+ public Vector3 LookAt; public float Distance = 120000f;
+ DepthOfField _dof;
+
+ /// <summary>The global post-processing volume Init creates. Its runtime VolumeProfile must be owned by the caller
+ /// (MapScene registers it with MapRuntimeAssets).</summary>
+ public Volume Volume { get; private set; }
+
+ public void Init()
+ {
+ var cam = GetComponent<Camera>(); cam.fieldOfView = Fov; cam.farClipPlane = 1_000_000f; cam.nearClipPlane = 50f;
+ cam.GetUniversalAdditionalCameraData().renderPostProcessing = true;
+ var vol = new GameObject("PostFX").AddComponent<Volume>(); vol.isGlobal = true;
+ vol.profile = ScriptableObject.CreateInstance<VolumeProfile>();
+ _dof = vol.profile.Add<DepthOfField>(true); _dof.mode.Override(DepthOfFieldMode.Gaussian);
+ _dof.gaussianMaxRadius.Override(1.5f);
+ Volume = vol;
+ Apply();
+ }
+
+ public void Apply()
+ {
+ transform.rotation = Quaternion.Euler(Pitch, 0, 0);
+ transform.position = LookAt - transform.forward * Distance;
+ if (_dof != null) { _dof.gaussianStart.Override(Distance * 1.05f); _dof.gaussianEnd.Override(Distance * 1.8f); }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/CameraRig.cs.meta b/unity/Assets/Scripts/Map/CameraRig.cs.meta
new file mode 100644
index 000000000..d2252c24e
--- /dev/null
+++ b/unity/Assets/Scripts/Map/CameraRig.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 301a816b1ac0344ff8b1506f93e21ed7
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/MapScene.cs b/unity/Assets/Scripts/Map/MapScene.cs
new file mode 100644
index 000000000..61cebac53
--- /dev/null
+++ b/unity/Assets/Scripts/Map/MapScene.cs
@@ -0,0 +1,56 @@
+using System;
+using System.IO;
+using UnityEngine;
+
+namespace Statecraft.Game.Map
+{
+ /// <summary>Builds the whole map at runtime: terrain, hexes, 1948 settlements, camera. Materials are editor-made assets
+ /// (M0 correction 1). Build is idempotent: it destroys what the previous Build made first.</summary>
+ public sealed class MapScene : MonoBehaviour
+ {
+ [SerializeField] Material terrainMaterial, overlayMaterial, markerMaterial;
+
+ public GeoFrame Frame { get; private set; }
+ public Terrain Terrain { get; private set; }
+ GameObject _settlements, _postFx;
+
+ void Awake() => Build();
+
+ public void Configure(Material terrain, Material overlay, Material marker)
+ { terrainMaterial = terrain; overlayMaterial = overlay; markerMaterial = marker; }
+
+ public void Build()
+ {
+ if (terrainMaterial == null) throw new InvalidOperationException("MapScene: terrainMaterial is not assigned");
+ if (overlayMaterial == null) throw new InvalidOperationException("MapScene: overlayMaterial is not assigned");
+ if (markerMaterial == null) throw new InvalidOperationException("MapScene: markerMaterial is not assigned");
+ var cam = Camera.main;
+ if (cam == null) throw new InvalidOperationException("MapScene needs a camera tagged MainCamera");
+
+ Clear();
+ var terrainGo = MapBuilder.Build(Paths.StreamingMap, Path.Combine(Paths.Content, "map", "hexes.json"), terrainMaterial, overlayMaterial);
+ terrainGo.transform.SetParent(transform, true);
+ Terrain = terrainGo.GetComponent<Terrain>();
+ var size = Terrain.terrainData.size;
+ var (meta, _) = HeightmapLoader.Load(Paths.StreamingMap);
+ Frame = new GeoFrame(meta.lon0, meta.lon1, meta.lat0, meta.lat1, size.x, size.z);
+ var list = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")),
+ (meta.lon0, meta.lon1, meta.lat0, meta.lat1));
+ _settlements = SettlementPlacer.Place(list, Frame, Terrain, markerMaterial);
+ _settlements.transform.SetParent(transform, true);
+
+ if (!cam.TryGetComponent(out CameraRig rig)) rig = cam.gameObject.AddComponent<CameraRig>();
+ rig.LookAt = Frame.ToWorld(34.95, 31.95, 0); rig.Init(); // central Israel: Tel Aviv–Jerusalem corridor
+ _postFx = rig.Volume.gameObject; _postFx.transform.SetParent(transform, true);
+ terrainGo.GetComponent<MapRuntimeAssets>().Own(rig.Volume.profile);
+ }
+
+ void Clear()
+ {
+ // The VolumeProfile is owned by the terrain's MapRuntimeAssets, so destroying the terrain destroys it.
+ foreach (var go in new[] { Terrain != null ? Terrain.gameObject : null, _settlements, _postFx })
+ if (go != null) { if (Application.isPlaying) Destroy(go); else DestroyImmediate(go); }
+ Terrain = null; _settlements = null; _postFx = null;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/MapScene.cs.meta b/unity/Assets/Scripts/Map/MapScene.cs.meta
new file mode 100644
index 000000000..8f90eb182
--- /dev/null
+++ b/unity/Assets/Scripts/Map/MapScene.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: f7b27c26d62c5400c99c12b492a87a6d
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/SettlementPlacer.cs b/unity/Assets/Scripts/Map/SettlementPlacer.cs
new file mode 100644
index 000000000..55cd8850f
--- /dev/null
+++ b/unity/Assets/Scripts/Map/SettlementPlacer.cs
@@ -0,0 +1,86 @@
+using System.Collections.Generic;
+using System.IO;
+using UnityEngine;
+using YamlDotNet.Serialization;
+using YamlDotNet.Serialization.NamingConventions;
+
+namespace Statecraft.Game.Map
+{
+ public sealed class SourceRef { public string Url { get; set; } = ""; public string Checked { get; set; } = ""; }
+
+ public sealed class Settlement
+ {
+ public string Id { get; set; } = ""; public string Name { get; set; } = ""; public string Type { get; set; } = "";
+ public double Lon { get; set; } public double Lat { get; set; }
+ public int? Founded { get; set; } // null for pre-modern cities (no verifiable founding year)
+ public bool PreModern { get; set; }
+ public List<SourceRef> Sources { get; set; } = new List<SourceRef>();
+ }
+
+ public sealed class SettlementFile { public List<Settlement> Settlements { get; set; } = new List<Settlement>(); }
+
+ public static class SettlementPlacer
+ {
+ static readonly Dictionary<string, (Color c, float h)> Marker = new Dictionary<string, (Color, float)>
+ {
+ ["city"] = (new Color(0.93f, 0.92f, 0.88f), 1800f), ["town"] = (new Color(0.88f, 0.84f, 0.76f), 1100f),
+ ["kibbutz"] = (new Color(0.80f, 0.35f, 0.25f), 600f), ["moshav"] = (new Color(0.78f, 0.45f, 0.30f), 600f),
+ ["arab_town"] = (new Color(0.82f, 0.74f, 0.58f), 1100f), ["village"] = (new Color(0.76f, 0.68f, 0.52f), 600f),
+ };
+
+ static readonly int BaseColor = Shader.PropertyToID("_BaseColor");
+
+ /// <summary>Parses settlements_1948.yaml. Content errors throw InvalidDataException naming the settlement id and the
+ /// field: unknown type, duplicate id, non-finite lon/lat (or outside <paramref name="bounds"/> when given), empty
+ /// sources, founded null without pre_modern: true.</summary>
+ public static List<Settlement> Parse(string yaml, (double lon0, double lon1, double lat0, double lat1)? bounds = null)
+ {
+ var list = new DeserializerBuilder().WithNamingConvention(UnderscoredNamingConvention.Instance).Build().Deserialize<SettlementFile>(yaml).Settlements;
+ var ids = new HashSet<string>();
+ foreach (var s in list)
+ {
+ if (!Marker.ContainsKey(s.Type)) throw new InvalidDataException($"settlements: '{s.Id}' has unknown type '{s.Type}'");
+ if (!ids.Add(s.Id)) throw new InvalidDataException($"settlements: '{s.Id}' duplicate id");
+ CheckCoord(s.Id, "lon", s.Lon, bounds?.lon0, bounds?.lon1);
+ CheckCoord(s.Id, "lat", s.Lat, bounds?.lat0, bounds?.lat1);
+ if (s.Sources == null || s.Sources.Count == 0) throw new InvalidDataException($"settlements: '{s.Id}' sources is empty");
+ if (s.Founded == null && !s.PreModern) throw new InvalidDataException($"settlements: '{s.Id}' founded is null without pre_modern: true");
+ }
+ return list;
+ }
+
+ static void CheckCoord(string id, string field, double v, double? min, double? max)
+ {
+ if (double.IsNaN(v) || double.IsInfinity(v)) throw new InvalidDataException($"settlements: '{id}' {field} {v} is not finite");
+ if (min.HasValue && (v < min.Value || v > max.Value))
+ throw new InvalidDataException($"settlements: '{id}' {field} {v} outside the heightmap bounds {min.Value}..{max.Value}");
+ }
+
+ /// <summary>Placeholder markers (real per-era prefabs come in M3/M4): a box sized by type plus a name label, under a
+ /// returned "Settlements" root. The box uses the editor-made <paramref name="markerMaterial"/> (no runtime
+ /// Shader.Find, M0 correction 1); the per-type colour goes through a MaterialPropertyBlock.</summary>
+ public static GameObject Place(List<Settlement> list, GeoFrame frame, Terrain terrain, Material markerMaterial)
+ {
+ var root = new GameObject("Settlements"); var parent = root.transform;
+ var font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
+ var block = new MaterialPropertyBlock();
+ foreach (var s in list)
+ {
+ var p = frame.ToWorld(s.Lon, s.Lat, 0); p.y = terrain.SampleHeight(p) + terrain.transform.position.y;
+ var (c, h) = Marker[s.Type];
+ var box = GameObject.CreatePrimitive(PrimitiveType.Cube); box.name = s.Id; box.transform.SetParent(parent);
+ box.transform.position = p + Vector3.up * h / 2; box.transform.localScale = new Vector3(h, h, h);
+ var r = box.GetComponent<Renderer>(); r.sharedMaterial = markerMaterial;
+ block.SetColor(BaseColor, c); r.SetPropertyBlock(block);
+
+ var labelGo = new GameObject(s.Id + "_label");
+ labelGo.AddComponent<MeshRenderer>().sharedMaterial = font.material;
+ var label = labelGo.AddComponent<TextMesh>();
+ label.font = font; label.text = s.Name; label.characterSize = 400; label.anchor = TextAnchor.LowerCenter; label.color = Color.black;
+ labelGo.transform.position = p + Vector3.up * (h + 400); labelGo.transform.rotation = Quaternion.Euler(50, 0, 0);
+ labelGo.transform.SetParent(parent);
+ }
+ return root;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/SettlementPlacer.cs.meta b/unity/Assets/Scripts/Map/SettlementPlacer.cs.meta
new file mode 100644
index 000000000..53001af3c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/SettlementPlacer.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 8c5236cf30d1f450abf8e06b89222f69
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs b/unity/Assets/Tests/EditMode/SettlementTests.cs
new file mode 100644
index 000000000..20eb67281
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs
@@ -0,0 +1,158 @@
+using System.IO;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Rendering;
+
+public class SettlementTests
+{
+ static readonly (double, double, double, double) Bounds = (34.20, 35.90, 29.45, 33.35); // heightmap.json lon0, lon1, lat0, lat1
+
+ static string Entry(string id, string extra = "lon: 35, lat: 32, type: town, founded: 1900, sources: [{url: u, checked: x}]") =>
+ $"- {{id: {id}, name: N, {extra}}}\n";
+
+ static InvalidDataException Rejects(string yaml) =>
+ Assert.Throws<InvalidDataException>(() => SettlementPlacer.Parse("settlements:\n" + yaml, Bounds));
+
+ [Test]
+ public void ParsesYamlAndRejectsUnknownType()
+ {
+ var ok = SettlementPlacer.Parse("settlements:\n- {id: jlm, name: Jerusalem, lon: 35.2256, lat: 31.7789, type: city, founded: null, pre_modern: true, sources: [{url: u, checked: '2026-10-09'}]}\n");
+ Assert.AreEqual("Jerusalem", ok[0].Name); Assert.IsNull(ok[0].Founded); Assert.IsTrue(ok[0].PreModern);
+ Assert.Throws<InvalidDataException>(() => SettlementPlacer.Parse("settlements:\n- {id: q, name: Q, lon: 35, lat: 32, type: castle, founded: 1900, sources: [{url: u, checked: x}]}\n"));
+ }
+
+ [Test]
+ public void UnknownTypeNamesIdAndField()
+ {
+ var ex = Rejects(Entry("q", "lon: 35, lat: 32, type: castle, founded: 1900, sources: [{url: u, checked: x}]"));
+ StringAssert.Contains("'q'", ex.Message); StringAssert.Contains("type", ex.Message);
+ }
+
+ [Test]
+ public void DuplicateIdIsRejected()
+ {
+ var ex = Rejects(Entry("a") + Entry("a"));
+ StringAssert.Contains("'a'", ex.Message); StringAssert.Contains("id", ex.Message);
+ }
+
+ [Test]
+ public void NonFiniteCoordinateIsRejected()
+ {
+ var ex = Rejects(Entry("n", "lon: .nan, lat: 32, type: town, founded: 1900, sources: [{url: u, checked: x}]"));
+ StringAssert.Contains("'n'", ex.Message); StringAssert.Contains("lon", ex.Message);
+ }
+
+ [Test]
+ public void CoordinateOutsideHeightmapBoundsIsRejected()
+ {
+ var ex = Rejects(Entry("cy", "lon: 33.36, lat: 35.17, type: town, founded: 1900, sources: [{url: u, checked: x}]")); // Nicosia
+ StringAssert.Contains("'cy'", ex.Message); StringAssert.Contains("lon", ex.Message);
+ ex = Rejects(Entry("s", "lon: 35, lat: 29.40, type: town, founded: 1900, sources: [{url: u, checked: x}]"));
+ StringAssert.Contains("'s'", ex.Message); StringAssert.Contains("lat", ex.Message);
+ }
+
+ [Test]
+ public void EmptySourcesIsRejected()
+ {
+ var ex = Rejects(Entry("e", "lon: 35, lat: 32, type: town, founded: 1900, sources: []"));
+ StringAssert.Contains("'e'", ex.Message); StringAssert.Contains("sources", ex.Message);
+ }
+
+ [Test]
+ public void NullFoundedNeedsPreModern()
+ {
+ var ex = Rejects(Entry("f", "lon: 35, lat: 32, type: town, founded: null, sources: [{url: u, checked: x}]"));
+ StringAssert.Contains("'f'", ex.Message); StringAssert.Contains("founded", ex.Message);
+ }
+
+ [Test]
+ public void RealSettlementFileParses()
+ {
+ var list = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")), Bounds);
+ Assert.AreEqual(25, list.Count);
+ }
+
+ // --- MapScene (built in edit mode with the editor-made material assets) ---
+
+ const string TerrainMatPath = "Assets/Materials/Terrain.mat", OverlayMatPath = "Assets/Materials/HexOverlay.mat",
+ MarkerMatPath = "Assets/Materials/SettlementMarker.mat";
+
+ static Material Load(string path) { var m = AssetDatabase.LoadAssetAtPath<Material>(path); Assert.IsNotNull(m, path); return m; }
+
+ static (MapScene map, GameObject cam) NewMap()
+ {
+ var cam = new GameObject("TestMainCamera") { tag = "MainCamera" }; cam.AddComponent<Camera>();
+ var map = new GameObject("MapScene").AddComponent<MapScene>();
+ map.Configure(Load(TerrainMatPath), Load(OverlayMatPath), Load(MarkerMatPath));
+ return (map, cam);
+ }
+
+ // Camera.main may be a camera of the test runner's scene rather than ours, so remove every rig Build added.
+ static void Cleanup(MapScene map, GameObject cam)
+ {
+ Object.DestroyImmediate(map.gameObject);
+ foreach (var rig in Object.FindObjectsByType<CameraRig>(FindObjectsSortMode.None)) Object.DestroyImmediate(rig);
+ Object.DestroyImmediate(cam);
+ }
+
+ [Test]
+ public void BuildWithoutMaterialsNamesTheMissingField()
+ {
+ var map = new GameObject("MapScene").AddComponent<MapScene>();
+ try
+ {
+ map.Configure(Load(TerrainMatPath), Load(OverlayMatPath), null);
+ var ex = Assert.Throws<System.InvalidOperationException>(() => map.Build());
+ StringAssert.Contains("markerMaterial", ex.Message);
+ }
+ finally { Object.DestroyImmediate(map.gameObject); }
+ }
+
+ [Test]
+ public void BuildTwiceLeavesOneTerrainOneSettlementsRootAndOneVolume()
+ {
+ var (map, cam) = NewMap();
+ try
+ {
+ map.Build(); map.Build();
+ Assert.AreEqual(1, Object.FindObjectsByType<Terrain>(FindObjectsSortMode.None).Length, "terrains");
+ Assert.AreEqual(1, Object.FindObjectsByType<Volume>(FindObjectsSortMode.None).Length, "volumes");
+ int roots = 0;
+ foreach (var t in Object.FindObjectsByType<Transform>(FindObjectsSortMode.None)) if (t.name == "Settlements") roots++;
+ Assert.AreEqual(1, roots, "Settlements roots");
+ Assert.AreEqual(1, Object.FindObjectsByType<CameraRig>(FindObjectsSortMode.None).Length, "camera rigs"); // on Camera.main
+ }
+ finally { Cleanup(map, cam); }
+ }
+
+ [Test]
+ public void EveryMarkerSitsOnItsSourcedPositionWithTheMarkerMaterial()
+ {
+ var (map, cam) = NewMap();
+ try
+ {
+ map.Build();
+ var marker = Load(MarkerMatPath);
+ Assert.AreEqual("Universal Render Pipeline/Lit", marker.shader.name);
+ Assert.AreEqual(0f, marker.GetFloat("_Smoothness"), "matte marker");
+ var root = GameObject.Find("Settlements").transform;
+ var list = SettlementPlacer.Parse(File.ReadAllText(Path.Combine(Paths.Content, "map", "settlements_1948.yaml")), Bounds);
+ foreach (var s in list)
+ {
+ var box = root.Find(s.Id); Assert.IsNotNull(box, s.Id);
+ var want = map.Frame.ToWorld(s.Lon, s.Lat, 0);
+ Assert.AreEqual(want.x, box.position.x, 1f, s.Id + " x"); Assert.AreEqual(want.z, box.position.z, 1f, s.Id + " z");
+ float baseY = box.position.y - box.lossyScale.y / 2;
+ Assert.AreEqual(map.Terrain.SampleHeight(box.position), baseY, 1f, s.Id + " base y");
+ Assert.AreSame(marker, box.GetComponent<Renderer>().sharedMaterial, s.Id + " material");
+ }
+ var telAviv = root.Find("tel_aviv").position; var jerusalem = root.Find("jerusalem").position; var haifa = root.Find("haifa").position;
+ Assert.Less(telAviv.x, jerusalem.x, "Tel Aviv west of Jerusalem");
+ Assert.Greater(haifa.z, telAviv.z, "Haifa north of Tel Aviv"); Assert.Greater(haifa.z, jerusalem.z, "Haifa north of Jerusalem");
+ }
+ finally { Cleanup(map, cam); }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/SettlementTests.cs.meta b/unity/Assets/Tests/EditMode/SettlementTests.cs.meta
new file mode 100644
index 000000000..98a4e6828
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SettlementTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 14d18a37df210407ab3318f80005ec11
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef b/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef
index 8a611ac1d..ef4c6c8fe 100644
--- a/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef
+++ b/unity/Assets/Tests/EditMode/Statecraft.Tests.EditMode.asmdef
@@ -1 +1 @@
-{ "name": "Statecraft.Tests.EditMode", "references": ["Statecraft.Game", "UnityEngine.TestRunner", "UnityEditor.TestRunner"], "includePlatforms": ["Editor"], "overrideReferences": true, "precompiledReferences": ["nunit.framework.dll", "Statecraft.Sim.dll", "YamlDotNet.dll"], "defineConstraints": ["UNITY_INCLUDE_TESTS"] }
+{ "name": "Statecraft.Tests.EditMode", "references": ["Statecraft.Game", "Unity.RenderPipelines.Core.Runtime", "UnityEngine.TestRunner", "UnityEditor.TestRunner"], "includePlatforms": ["Editor"], "overrideReferences": true, "precompiledReferences": ["nunit.framework.dll", "Statecraft.Sim.dll", "YamlDotNet.dll"], "defineConstraints": ["UNITY_INCLUDE_TESTS"] }
diff --git a/unity/Assets/link.xml b/unity/Assets/link.xml
index e7a19b2e0..9f22a0673 100644
--- a/unity/Assets/link.xml
+++ b/unity/Assets/link.xml
@@ -1,4 +1,5 @@
<linker>
<assembly fullname="YamlDotNet" preserve="all" />
<assembly fullname="Statecraft.Sim" preserve="all" />
+ <assembly fullname="Statecraft.Game"><type fullname="Statecraft.Game.Map.*" preserve="all"/></assembly>
</linker>