A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Towns: Tel Aviv, Jerusalem, Haifa and Jaffa drawn from their small buildings at every zoom (Refs #2007) (#2267)
Eyal Golan2b63d186cdfb
diff --git a/changelog.d/big-cities-small-buildings.md b/changelog.d/big-cities-small-buildings.mdnew file mode 100644index 000000000..d85cfcea0--- /dev/null+++ b/changelog.d/big-cities-small-buildings.md@@ -0,0 +1,7 @@+### Changed++- Tel Aviv, Jerusalem, Haifa and Jaffa are drawn from Tal Heuberger's single-building models at every zoom, not only+ under 40 km (owner, 2 November 2026: "Yes, small buildings at every zoom"; Refs #2007). Far off they no longer show a+ whole-town model, and beyond the close switch (40 km zooming in, 45 km zooming out) their buildings cast no shadows+ (owner: "Shadows off far, then measure"). Tel Aviv's, Jerusalem's and Haifa's whole-town models stay in the repository, unused on the map.+ Every other town keeps its whole-town model far off and its buildings up close.diff --git a/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs b/unity/Assets/Scripts/Map/Collection/TownLandmarks.csindex 2a543d00c..cbabb6b87 100644--- a/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs+++ b/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs@@ -15,6 +15,10 @@ namespace Statecraft.Game.Map.Collection/// (BuildingPreview at 3ef0a7a5): White City at Tel Aviv, the stone city at Jerusalem, the port city at Haifa, the/// moshava town at the six moshavot, Nahalal at the moshav, the compound at every kibbutz, the stone village at every/// Arab town, the ma'abara at a transit camp and the shikun at a housing project.+ /// Owner ruling of 2 November 2026, "Yes, small buildings at every zoom": Tel Aviv, Jerusalem, Haifa and Jaffa have no+ /// whole-town model; their building models draw at every zoom instead (<see cref="Kits.TownModels.AtEveryZoom"/>). Tel+ /// Aviv's, Jerusalem's and Haifa's whole-town models stay in the repository and the streamed catalogue, unused on the map;+ /// the stone village still stands at the other Arab towns but Ramla (its own town, see <see cref="ById"/>)./// Owner ruling of 18 October 2026 (recorded on #917, #663, #659 and #700): the towns are Tal Heuberger's models, "Whole model/// far, buildings near". Far off, a mapped town's whole-town model stands ON its town, on its core (<see cref="CoreOf"/>:/// where most of its building models stand, inside its kit footprint, clear of the next town and of the sea), as wide as@@ -55,16 +59,17 @@ namespace Statecraft.Game.Map.CollectionTiberias = CollectionCatalog.TiberiasTown, Safed = CollectionCatalog.SafedTown, Netanya = CollectionCatalog.NetanyaTown,Ramla = CollectionCatalog.RamlaTown;- /// <summary>By settlement id first (#507's mapping). Jerusalem stands as #336's second take of the stone city- /// (<see cref="Jerusalem3D"/>, Tal Heuberger, #886) for the whole game: the owner, 21 October 2026, on #708- /// (issuecomment-6323524970), "it is Jerusalem's only far-zoom model for the whole game. The first model stays in the- /// repository, unused on the map. No date switch". #507's <see cref="Jerusalem"/> is therefore not placed.+ /// <summary>By settlement id first (#507's mapping). Tel Aviv, Jerusalem and Haifa have no row: the owner, 2 November+ /// 2026, "Yes, small buildings at every zoom" (<see cref="Kits.TownModels.AtEveryZoom"/>). That replaces #507's+ /// White City at Tel Aviv and port city at Haifa, and the owner's ruling of 21 October 2026 on #708+ /// (issuecomment-6323524970) that #336's second stone city (<see cref="Jerusalem3D"/>, Tal Heuberger, #886) "is+ /// Jerusalem's only far-zoom model for the whole game". <see cref="TelAviv"/>, <see cref="Haifa"/>,+ /// <see cref="Jerusalem3D"/> and #507's <see cref="Jerusalem"/> stay in the repository, unused on the map./// Tiberias, Safed and Netanya stand as Tal Heuberger's own whole-town models (#2085), the three towns #1288 found with/// none. Ramla, an Arab town, stands as Tal's own town instead of the stone village (<see cref="ByType"/>): the owner,/// 2 November 2026, "Yes, Tal's Ramla (Recommended)" ("Ramla draws Tal's town instead of the stone village").</summary>public static readonly IReadOnlyDictionary<string, string> ById = new Dictionary<string, string>(StringComparer.Ordinal){- ["tel_aviv"] = TelAviv, ["jerusalem"] = Jerusalem3D, ["haifa"] = Haifa,["petah_tikva"] = Moshava, ["rishon_lezion"] = Moshava, ["zikhron_yaakov"] = Moshava,["rosh_pinna"] = Moshava, ["rehovot"] = Moshava, ["hadera"] = Moshava,["tiberias"] = Tiberias, ["safed"] = Safed, ["netanya"] = Netanya, ["ramla"] = Ramla,@@ -96,9 +101,10 @@ namespace Statecraft.Game.Map.Collectioninternal static Action<string, CollectionDetail, Action<GameObject?>> Request = DefaultRequest;internal static Func<string, CollectionDetail, Action<GameObject?>, IDisposable> Acquire = CollectionStream.Acquire;- /// <summary>The model for settlement <paramref name="s"/>, or null for none.</summary>- public static string? ModelFor(Settlement s) =>- ById.TryGetValue(s.Id, out var m) ? m : ByType.TryGetValue(s.Type, out var t) ? t : null;+ /// <summary>The model for settlement <paramref name="s"/>, or null for none: none for the cities drawn from their+ /// building models at every zoom (Jaffa, an Arab town, would otherwise take <see cref="ByType"/>'s stone village).</summary>+ public static string? ModelFor(Settlement s) => Kits.TownModels.AtEveryZoom(s.Id) ? null+ : ById.TryGetValue(s.Id, out var m) ? m : ByType.TryGetValue(s.Type, out var t) ? t : null;/// <summary>The model for a placement of <paramref name="action"/> as at <paramref name="date"/>, or null: none for that/// action, before its sourced date, or no sourced date at all.</summary>diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.csindex ec9d7285b..f9ce06dc1 100644--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs@@ -11,7 +11,8 @@ namespace Statecraft.Game.Map.Kits/// standing on the plot's ground level with a stone plinth below it where the ground falls away. Far off the kit's/// own buildings draw, exactly as before; up close (TownModelLayer.CloseEnterM) the models draw instead, with each/// town's close mesh (KitMesh.ToCloseMesh: its palms without the kit buildings, plus the plinths and, issue #1032, its- /// landmarks at the world scale, KitMesh.CloseCopy). The+ /// landmarks at the world scale, KitMesh.CloseCopy). Tel Aviv, Jerusalem, Haifa and Jaffa draw their models at every+ /// zoom (owner, 2 November 2026, "Yes, small buildings at every zoom": TownModels.AtEveryZoom). The/// layout, the lots and the census do not change.</summary>public static partial class SettlementKits{diff --git a/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs b/unity/Assets/Scripts/Map/Kits/TownModelLayer.csindex 30ec30050..8e5fa01f6 100644--- a/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs+++ b/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs@@ -6,7 +6,9 @@ using UnityEngine.Rendering;namespace Statecraft.Game.Map.Kits{/// <summary>Original building meshes for admitted towns and villages, instanced per model/tile. At overview zoom- /// TownLandmarks owns the whole-town representation; close cameras own individual buildings. Under the production policy+ /// TownLandmarks owns the whole-town representation; close cameras own individual buildings. Tel Aviv, Jerusalem, Haifa+ /// and Jaffa are the exception: their buildings are admitted at every zoom, by view as below (owner ruling, 2 November+ /// 2026, "Yes, small buildings at every zoom": <see cref="TownModels.AtEveryZoom"/>). Under the production policy/// (owner ruling, 31 Oct 2026, "Load all in view (Recommended)") a close camera admits every town and every merged village/// tile in its view (+<see cref="ViewMarginM"/>), nearest first, and they unload above <see cref="CloseExitM"/>. Each camera/// swaps only complete towns and complete village tiles; loading and failed places retain code-built fallback. Source@@ -111,7 +113,7 @@ namespace Statecraft.Game.Map.Kitspublic readonly List<string> inView = new List<string>();public readonly HashSet<string> viewed = new HashSet<string>(System.StringComparer.Ordinal);public Matrix4x4 viewMatrix;- public bool viewValid;+ public bool viewValid, viewClose;}sealed class Model{@@ -125,6 +127,7 @@ namespace Statecraft.Game.Map.Kitsreadonly Dictionary<TownModel, Model> models = new Dictionary<TownModel, Model>();readonly Dictionary<string, TownModel[]> required = new Dictionary<string, TownModel[]>(System.StringComparer.Ordinal);readonly List<int> deadCameras = new List<int>();+ readonly HashSet<TownModel> warnedKinds = new HashSet<TownModel>();readonly List<System.IDisposable> retiring = new List<System.IDisposable>();readonly List<(Renderer renderer, bool off)> previousRenderers = new List<(Renderer, bool)>();bool reconcileDirty;@@ -254,12 +257,14 @@ namespace Statecraft.Game.Map.Kits}}public int Count { get; private set; }- /// <summary>For the last camera: whether it drew the models (else the kits), and the instances, triangles, draws and- /// shadow casters it submitted (test and profiling aids).</summary>+ /// <summary>For the last camera: whether it was below the close switch and drew the models (else the kits), and the+ /// instances, triangles and draws it submitted, the cities drawn at every zoom included (test and profiling aids).</summary>public bool LastClose { get; private set; }public int LastDrawn { get; private set; }public long LastTriangles { get; private set; }public int LastDraws { get; private set; }+ /// <summary>For the last camera: the instances it submitted with shadow casting on (a test and profiling aid).</summary>+ public int LastShadowCasters { get; private set; }/// <summary>Explicit town ids and renderer identities distinguish individual towns from mixed locality tiles/// (<paramref name="rendererTileIds"/>: each tile renderer's villages). A complete editor model set is optional in a@@ -434,16 +439,8 @@ namespace Statecraft.Game.Map.Kitsif (Collection.CollectionResidencyView.TryGroundFocus(cam, out var focus)){next = choice.hadFocus && focus == choice.focus && EdgeAllowance == null ? choice.selected : FocusedTownsWithFootprints(- places, admissionFootprintsById, townFootprints, focus, choice.primary, EdgeAllowance == null ? null : (local, edge) =>- {- var admitted = new List<string>();- foreach (var c in OrderedChoices()) if (c.primary != null && !admitted.Contains(c.primary)) admitted.Add(c.primary);- foreach (string id in local) if (!admitted.Contains(id)) admitted.Add(id);- // Include other retained edges so the allowance sees existing residency as well as all primaries.- foreach (var c in OrderedChoices()) if (c != choice)- foreach (string id in c.selected) if (!admitted.Contains(id)) admitted.Add(id);- return EdgeAllowance!(admitted, edge);- }, admittedEnterM, admittedExitM, admittedEdgeM, admittedEdges);+ places, admissionFootprintsById, townFootprints, focus, choice.primary, AllowanceFor(choice),+ admittedEnterM, admittedExitM, admittedEdgeM, admittedEdges);choice.focus = focus; choice.hadFocus = true;}else choice.hadFocus = false;@@ -478,26 +475,42 @@ namespace Statecraft.Game.Map.Kits}}+ /// <summary>The edge allowance for <paramref name="owner"/>'s focus selection, or null without one. A method of its own,+ /// so PrepareCameraCore holds no closure: a closure there was allocated on every call, far off too, where the four+ /// cities now draw.</summary>+ System.Func<IReadOnlyList<string>, string, bool>? AllowanceFor(Choice owner) => EdgeAllowance == null ? null : (local, edge) =>+ {+ var admitted = new List<string>();+ foreach (var c in OrderedChoices()) if (c.primary != null && !admitted.Contains(c.primary)) admitted.Add(c.primary);+ foreach (string id in local) if (!admitted.Contains(id)) admitted.Add(id);+ // Include other retained edges so the allowance sees existing residency as well as all primaries.+ foreach (var c in OrderedChoices()) if (c != owner)+ foreach (string id in c.selected) if (!admitted.Contains(id)) admitted.Add(id);+ return EdgeAllowance!(admitted, edge);+ };+/// <summary>Owner ruling, 31 Oct 2026, "Load all in view (Recommended)": under the production policy a close camera/// admits every town and village tile in its view (<see cref="ViewMarginM"/>, kept to <see cref="ViewKeepM"/>), nearest- /// its ground focus first. Returns whether the admitted set changed.</summary>+ /// its ground focus first; a far camera only the cities drawn at every zoom (<see cref="AtZoom"/>). Returns whether the+ /// admitted set changed.</summary>bool AdmitInView(Choice choice, Camera cam){- if (!viewAdmission || !SpatialPolicyConfigured || !choice.close)+ if (!viewAdmission || !SpatialPolicyConfigured){choice.viewValid = false;if (choice.inView.Count == 0) return false;choice.inView.Clear(); choice.viewed.Clear(); return true;}var viewProjection = cam.projectionMatrix * cam.worldToCameraMatrix;- if (choice.viewValid && viewProjection == choice.viewMatrix) return false;- choice.viewMatrix = viewProjection; choice.viewValid = true;+ if (choice.viewValid && viewProjection == choice.viewMatrix && choice.viewClose == choice.close) return false;+ choice.viewMatrix = viewProjection; choice.viewValid = true; choice.viewClose = choice.close;GeometryUtility.CalculateFrustumPlanes(viewProjection, frustum);var from = choice.hadFocus ? choice.focus : cam.transform.position;viewScratch.Clear();for (int i = 0; i < viewPlaces.Count; i++){var (ids, bounds) = viewPlaces[i];+ if (!AtZoom(choice, ids[0])) continue; // a village tile's first village: never one of the four citiesfloat margin = choice.viewed.Contains(ids[0]) ? ViewKeepM : ViewMarginM;var wide = bounds; wide.Expand(new Vector3(2f * margin, 0f, 2f * margin));if (GeometryUtility.TestPlanesAABB(frustum, wide)) viewScratch.Add((i, GroundDistance(bounds, from), ids[0]));@@ -533,11 +546,14 @@ namespace Statecraft.Game.Map.KitspreviousRenderers.Clear();}- /// <summary>Whether the camera-focus selection holds this town at close zoom (the focused town and its edges).</summary>- internal bool WantsTown(string id, Camera cam) => choices.TryGetValue(cam.GetInstanceID(), out var c) && c.close && c.towns.Contains(id);+ /// <summary>Whether a camera's zoom admits a place's building models: every place below the close switch, beyond it+ /// only the cities drawn at every zoom (owner ruling, 2 November 2026, "Yes, small buildings at every zoom").</summary>+ static bool AtZoom(Choice c, string id) => c.close || TownModels.AtEveryZoom(id);+ /// <summary>Whether the camera-focus selection holds this town at its zoom (the focused town and its edges).</summary>+ internal bool WantsTown(string id, Camera cam) => choices.TryGetValue(cam.GetInstanceID(), out var c) && AtZoom(c, id) && c.towns.Contains(id);/// <summary>Whether this camera admits the place's building models: the focus selection, or (production) its view.</summary>internal bool AdmitsTown(string id, Camera cam) =>- choices.TryGetValue(cam.GetInstanceID(), out var c) && c.close && (c.towns.Contains(id) || c.viewed.Contains(id));+ choices.TryGetValue(cam.GetInstanceID(), out var c) && AtZoom(c, id) && (c.towns.Contains(id) || c.viewed.Contains(id));internal bool ReadyForTown(string id, Camera cam){if (!Draw || !AdmitsTown(id, cam) || !required.TryGetValue(id, out var kinds) || kinds.Length == 0) return false;@@ -671,11 +687,13 @@ namespace Statecraft.Game.Map.Kits{if (required.TryGetValue(id, out var kinds)) foreach (var kind in kinds) if (needed.Add(kind)) ordered.Add(kind);}- // A focused town loads before any edge town, even when its model's enum value is larger.- foreach (var c in OrderedChoices()) if (c.close && c.primary != null) AddTown(c.primary);- foreach (var c in OrderedChoices()) if (c.close) foreach (string id in c.selected) if (id != c.primary) AddTown(id);- // Then every town and village in view, nearest first (owner ruling, 31 Oct 2026, "Load all in view").- foreach (var c in OrderedChoices()) if (c.close) foreach (string id in c.inView) AddTown(id);+ // A focused town loads before any edge town, even when its model's enum value is larger; each only at a zoom that+ // admits it (AtZoom).+ foreach (var c in OrderedChoices()) if (c.primary != null && AtZoom(c, c.primary)) AddTown(c.primary);+ foreach (var c in OrderedChoices()) foreach (string id in c.selected) if (id != c.primary && AtZoom(c, id)) AddTown(id);+ // Then every town and village in view, nearest first (owner ruling, 31 Oct 2026, "Load all in view"); AdmitInView+ // has already left out what this zoom does not admit.+ foreach (var c in OrderedChoices()) foreach (string id in c.inView) AddTown(id);var obsolete = new List<TownModel>();foreach (var pair in models) if (!needed.Contains(pair.Key)) obsolete.Add(pair.Key);foreach (var id in obsolete)@@ -704,7 +722,13 @@ namespace Statecraft.Game.Map.Kitsmodel.answered = true; Collection.CollectionResidencyMetrics.MarkDirty();var filter = prefab == null ? null : prefab.GetComponentInChildren<MeshFilter>(true);var renderer = prefab == null ? null : prefab.GetComponentInChildren<MeshRenderer>(true);- if (filter == null || renderer == null || filter.sharedMesh == null || renderer.sharedMaterial == null) return;+ if (filter == null || renderer == null || filter.sharedMesh == null || renderer.sharedMaterial == null)+ {+ // Once per kind for this layer: its places keep their code-built kits (Tel Aviv, Jerusalem, Haifa and+ // Jaffa at every zoom: they have no whole-town model to fall back to).+ if (warnedKinds.Add(id)) Debug.LogWarning($"TOWN MODELS: {TownModels.Ids[(int)id]} did not stream; the places built from it keep their kits.");+ return;+ }model.mesh = filter.sharedMesh; model.material = renderer.sharedMaterial; Collection.CollectionResidencyMetrics.MarkDirty();});if (isActiveAndEnabled && generation == lifetimeGeneration && models.TryGetValue(id, out var live) && live == model) model.lease = lease;@@ -770,10 +794,15 @@ namespace Statecraft.Game.Map.KitsPrepareCameraCore(cam, inRender: true);bool close = choices.TryGetValue(cam.GetInstanceID(), out var choice) && choice.close;LastClose = close;- int drawn = 0, draws = 0; long tris = 0;- if (close && Draw)+ int drawn = 0, draws = 0, casters = 0; long tris = 0;+ // Owner ruling on #2267, 2 November 2026, "Shadows off far, then measure (Recommended)": beyond the close switch the+ // cities drawn at every zoom cast no shadows; below it every building casts.+ var shadows = close ? ShadowCastingMode.On : ShadowCastingMode.Off;+ // Far off too: ReadyForTown admits the cities drawn at every zoom there (AtZoom), and nothing else.+ if (Draw){- var planes = GeometryUtility.CalculateFrustumPlanes(cam);+ // Into the scratch array (no Plane[6] per camera per frame: this runs far off too, the common view).+ GeometryUtility.CalculateFrustumPlanes(cam.projectionMatrix * cam.worldToCameraMatrix, frustum);foreach (var t in tiles){if (!ReadyForTown(t.town, cam)) continue;@@ -781,19 +810,20 @@ namespace Statecraft.Game.Map.Kitsif (villageTiles.TryGetValue(t.town, out var villages) && !VillagesReady(villages, cam)) continue;// The shadow pass sees casters outside the view too: cull on a widened box (as the trees).var wide = t.bounds; wide.Expand(new Vector3(3000f, 0f, 3000f));- if (!GeometryUtility.TestPlanesAABB(planes, wide)) continue;+ if (!GeometryUtility.TestPlanesAABB(frustum, wide)) continue;var mesh = set != null ? set.Mesh(t.model) : models[t.model].mesh!; // always the original meshvar rp = new RenderParams(set != null ? set.Material(t.model) : models[t.model].material!){- worldBounds = t.bounds, camera = cam, shadowCastingMode = ShadowCastingMode.On, receiveShadows = true,+ worldBounds = t.bounds, camera = cam, shadowCastingMode = shadows, receiveShadows = true,layer = gameObject.layer,};Graphics.RenderMeshInstanced(rp, mesh, 0, t.m);draws++; drawn += t.m.Length; tris += (long)t.m.Length * mesh.GetIndexCount(0) / 3;+ if (shadows != ShadowCastingMode.Off) casters += t.m.Length;}}LastClose = close && drawn > 0;- LastDrawn = drawn; LastTriangles = tris; LastDraws = draws;+ LastDrawn = drawn; LastTriangles = tris; LastDraws = draws; LastShadowCasters = casters;}}}diff --git a/unity/Assets/Scripts/Map/Kits/TownModels.cs b/unity/Assets/Scripts/Map/Kits/TownModels.csindex 20597571f..c47f6fd4f 100644--- a/unity/Assets/Scripts/Map/Kits/TownModels.cs+++ b/unity/Assets/Scripts/Map/Kits/TownModels.cs@@ -90,6 +90,13 @@ namespace Statecraft.Game.Map.Kits/// <summary>Haifa's German Colony: the Templers' stone houses with red roofs.</summary>internal static readonly TownModel[] Templer = { TownModel.B05aMoshavaHouse };+ /// <summary>The cities drawn from their building models at every zoom, with no whole-town model (owner ruling, 2 November+ /// 2026: "we had tal's smaller buildings alreaedy for tel aviv, jerusalem and haifa and jaffa - instead of the huge+ /// buildings", confirmed as "Yes, small buildings at every zoom"). This replaces the 18 October 2026 "Whole model far,+ /// buildings near" for these four: Collection.TownLandmarks.ModelFor gives them no whole-town model, and TownModelLayer+ /// admits their buildings beyond its close switch too.</summary>+ public static bool AtEveryZoom(string id) => id == "tel_aviv" || id == "jerusalem" || id == "haifa" || id == "jaffa";+/// <summary>The wine moshavot (the Carmel wineries of Rishon LeZion, 1890, and Zikhron Ya'akov, 1892): their first/// house nearest the heart is the winery.</summary>public static bool WineMoshava(string id) => id == "rishon_lezion" || id == "zikhron_yaakov";diff --git a/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs b/unity/Assets/Tests/EditMode/CivilianPeopleTests.csindex c8520a154..70e30fbb8 100644--- a/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs+++ b/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs@@ -259,7 +259,7 @@ public sealed class CivilianPeopleTestsvar arabTowns = map.Settlements.Where(s => s.Type == "arab_town").Select(s => s.Id).ToList();CollectionAssert.AreEquivalent(new[] { "jaffa", "acre", "nazareth", "lod", "ramla", "gaza", "beersheba" }, arabTowns,- "the seven Arab towns: the stone village (TownLandmarks.ByType), Ramla its own town (ById, owner 2 November 2026)");+ "the seven Arab towns: the stone village (TownLandmarks.ByType) but Ramla, its own town (ById, owner 2 November 2026), and Jaffa, which draws its buildings at every zoom");var villages = CivilianPeople.Served(rural, RuralLife.Sheep, RuralLife.Donkey).Select(w => w.Key).ToList();Assert.That(villages.Count, Is.InRange(RuralLife.MaxAnchorsPerModel, 2 * RuralLife.MaxAnchorsPerModel));Assert.IsTrue(villages.All(v => types[v] == "village"), "the flocks' villages");@@ -491,11 +491,12 @@ public sealed class CivilianPeopleTests}/// <summary>The owner on #336: "we must make sure all of his models are in and fully used". Every model the catalog- /// streams is in some layer's placement table, but two, each by an owner ruling: b21, the artisan workshop, which waits- /// for a sourced location (owner: wait), and #507's first Jerusalem, which "stays in the repository, unused on the map"- /// now that #336's second Jerusalem is the city's only far-zoom model (owner, 21 October 2026, #708).</summary>+ /// streams is in some layer's placement table, but five, each by an owner ruling: b21, the artisan workshop, which waits+ /// for a sourced location (owner: wait); #507's first Jerusalem, which "stays in the repository, unused on the map"+ /// (owner, 21 October 2026, #708); and the whole towns of Tel Aviv, Jerusalem (#336's second) and Haifa, whose cities+ /// draw their building models at every zoom instead (owner, 2 November 2026, "Yes, small buildings at every zoom").</summary>[Test]- public void EveryCatalogModelIsPlacedButTheTwoTheOwnerHeldBack()+ public void EveryCatalogModelIsPlacedButThoseTheOwnerHeldBack(){var placed = new HashSet<string>(StringComparer.Ordinal);placed.UnionWith(CivilianPeople.Models);@@ -517,8 +518,11 @@ public sealed class CivilianPeopleTestsplaced.UnionWith(Statecraft.Game.Map.Units.UnitWeapons.ByFigure.Values); // #2083: held by the token figuresplaced.Add(Statecraft.Game.Map.Units.UnitFigurePointFire.PoseFor(Statecraft.Game.Map.Units.UnitFigures.YoungRecruit)!); // #2084placed.UnionWith(Statecraft.Game.Map.Kits.TownModels.Ids); // #1273: 18 originals and five generated houses are catalogued and requested by TownModelLayer- CollectionAssert.AreEquivalent(new[] { SpecialBuildingModels.Workshop, TownLandmarks.Jerusalem }, CollectionCatalog.Ids.Where(id => !placed.Contains(id)).ToList(),- "every catalogued model has a place but b21 and the first Jerusalem, each held back by an owner ruling");+ // Tel Aviv's, Jerusalem's and Haifa's whole towns stay catalogued but unused: the four cities draw their buildings at+ // every zoom (owner, 2 November 2026, "Yes, small buildings at every zoom").+ CollectionAssert.AreEquivalent(new[] { SpecialBuildingModels.Workshop, TownLandmarks.Jerusalem, TownLandmarks.TelAviv, TownLandmarks.Jerusalem3D, TownLandmarks.Haifa },+ CollectionCatalog.Ids.Where(id => !placed.Contains(id)).ToList(),+ "every catalogued model has a place but b21, the first Jerusalem and the three cities' whole towns, each held back by an owner ruling");CollectionAssert.IsSubsetOf(placed.ToList(), CollectionCatalog.Ids.ToList(), "every placed id is a catalogued model");}diff --git a/unity/Assets/Tests/EditMode/TalModelsShots.cs b/unity/Assets/Tests/EditMode/TalModelsShots.csindex f16706663..3215bd590 100644--- a/unity/Assets/Tests/EditMode/TalModelsShots.cs+++ b/unity/Assets/Tests/EditMode/TalModelsShots.cs@@ -30,7 +30,7 @@ public class TalModelsShotsRenderTexture? rt; PanelSettings? ps;GameRoot root = null!;Action<string, CollectionDetail, Action<GameObject?>>? savedRural, savedPeople, savedSpecial, savedUnits, savedLandmark;- Func<string, CollectionDetail, Action<GameObject?>, IDisposable>? savedTown;+ Func<string, CollectionDetail, Action<GameObject?>, IDisposable>? savedTown, savedWhole;[SetUp]public void Prepare()@@ -39,6 +39,7 @@ public class TalModelsShotsDirectory.CreateDirectory(ShotDir); Directory.CreateDirectory(CivMovementShots.ShotDir);savedRural = RuralLife.Request; savedPeople = CivilianPeople.Request; savedSpecial = SpecialBuildingModels.Request;savedUnits = UnitFigures.Source; savedTown = TownModelLayer.ModelAcquire; savedLandmark = TownLandmarks.Request;+ savedWhole = TownLandmarks.Acquire;}[TearDown]@@ -46,6 +47,7 @@ public class TalModelsShots{RuralLife.Request = savedRural!; CivilianPeople.Request = savedPeople!; SpecialBuildingModels.Request = savedSpecial!;UnitFigures.Source = savedUnits; TownModelLayer.ModelAcquire = savedTown!; TownLandmarks.Request = savedLandmark!;+ TownLandmarks.Acquire = savedWhole!;EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);if (ps != null) Object.DestroyImmediate(ps);if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }@@ -195,6 +197,95 @@ public class TalModelsShotsDebug.Log($"SHOT houses {town} at {at} from {CameraController.MinDistance:F0} m: {models}");}+ /// <summary>The median time (ms) of <paramref name="n"/> renders of the map camera at the shots' size, each waited for+ /// on the GPU by a one-pixel read back, after two unmeasured renders. An editor (Metal) figure, for before and after on+ /// the same machine, not a WebGL frame time.</summary>+ static float RenderMs(int n)+ {+ var cam = Camera.main;+ var frame = new RenderTexture(CivMovementShots.Width, CivMovementShots.Height, 24, RenderTextureFormat.ARGB32);+ var pixel = new Texture2D(1, 1, TextureFormat.RGBA32, false);+ var before = cam.targetTexture; var ms = new List<float>();+ try+ {+ cam.targetTexture = frame;+ for (int i = 0; i < n + 2; i++)+ {+ var clock = System.Diagnostics.Stopwatch.StartNew();+ cam.Render();+ RenderTexture.active = frame; pixel.ReadPixels(new Rect(0, 0, 1, 1), 0, 0); pixel.Apply(); RenderTexture.active = null;+ if (i >= 2) ms.Add((float)clock.Elapsed.TotalMilliseconds);+ }+ }+ finally+ {+ cam.targetTexture = before; RenderTexture.active = null;+ frame.Release(); Object.DestroyImmediate(frame); Object.DestroyImmediate(pixel);+ }+ ms.Sort();+ return ms[ms.Count / 2];+ }++ /// <summary>Owner ruling, 2 November 2026, "Yes, small buildings at every zoom": Tel Aviv, Jerusalem, Haifa and Jaffa from+ /// the opening view (the game's own camera, 90 km), the widest zoom (diorama02, 250 km), and each city at 90 km and+ /// 30 km, with the town layers' requests (whole towns and buildings) answered with the editor's prefabs, as the player's+ /// stream would answer them. Each frame logs its draw cost: the building models' instances, triangles and instanced+ /// draws (TownModelLayer), the whole-town models in view and their triangles (TownLandmarks), and the median render time.+ /// Run on main and on this branch for the before and after.</summary>+ IEnumerator BigCities(bool hebrew)+ {+ Directory.CreateDirectory(Path.Combine(CivMovementShots.ShotDir, "..", "big-cities-shots"));+ yield return Boot(hebrew);+ string lang = hebrew ? "he" : "en";+ var map = Object.FindFirstObjectByType<MapScene>();+ TownModelLayer.ModelAcquire = (id, detail, done) => { done(Prefab(id, detail)); return new NoLease(); };+ TownLandmarks.Acquire = (id, detail, done) => { done(Prefab(id, detail)); return new NoLease(); };+ Drop(map, TownLandmarks.Name);+ var landmarks = TownLandmarks.ShowAt(map, root.Bridge!.State.Date, Array.Empty<Placement>(), root.Bridge.Content)!;+ var layer = Object.FindFirstObjectByType<TownModelLayer>();+ Assert.IsNotNull(layer, "the town layer");+ for (int i = 0; i < 3; i++) { Camera.main.Render(); yield return null; }+ IEnumerator Frame(string name)+ {+ for (int i = 0; i < 3; i++) { Camera.main.Render(); yield return null; }+ CivMovementShots.Shot(rt!, Path.Combine("..", "big-cities-shots", $"{name}-{lang}"));+ int drawn = layer.LastDrawn, draws = layer.LastDraws; long tris = layer.LastTriangles;+ var cam = Camera.main;+ landmarks.Choose(default, cam);+ var planes = GeometryUtility.CalculateFrustumPlanes(cam);+ int wholes = 0; long wholeTris = 0;+ foreach (var r in landmarks.GetComponentsInChildren<MeshRenderer>(true))+ {+ if (r.forceRenderingOff || !r.enabled || !r.gameObject.activeInHierarchy || !GeometryUtility.TestPlanesAABB(planes, r.bounds)) continue;+ var mesh = r.GetComponent<MeshFilter>()?.sharedMesh;+ if (mesh == null) continue;+ wholes++; for (int k = 0; k < mesh.subMeshCount; k++) wholeTris += mesh.GetIndexCount(k) / 3;+ }+ float ms = RenderMs(10);+ Debug.Log(FormattableString.Invariant(+ $"COST {name}-{lang} distance={TownModelLayer.ViewDistance(cam):F0} buildings={drawn} building_tris={tris} building_draws={draws} whole_towns={wholes} whole_tris={wholeTris} render_ms={ms:F2}"));+ }+ // The game's own opening view first, untouched.+ yield return Frame("opening");+ PromoPose.Diorama02.Apply(Camera.main.GetComponent<CameraRig>(), map.Frame);+ yield return Frame("widest");+ foreach (var id in new[] { "tel_aviv", "jerusalem", "haifa", "jaffa" })+ {+ var c = map.KitFootprints.First(f => f.id == id).centre;+ var at = new Vector3(c.x, 0f, c.y);+ at.y = map.Terrain.SampleHeight(at) + map.Terrain.transform.position.y;+ foreach (var km in new[] { 90, 30 })+ {+ Look(at, km * 1000f);+ yield return Frame($"{id.Replace('_', '-')}-{km}km");+ }+ }+ Debug.Log("LANDMARKS placed: " + string.Join(", ", landmarks.Placed.Select(p => p.Key + "=" + p.Model)));+ }++ [UnityTest] public IEnumerator BigCitiesEnglish() { yield return BigCities(false); }+ [UnityTest] public IEnumerator BigCitiesHebrew() { yield return BigCities(true); }+/// <summary>#2085: a town from the far zoom (50 km, inside the 40 km+ band where whole-town models stand), the camera on the/// centre of the town's kit footprint, 15 May 1948. The landmarks' requests are answered with the editor's prefabs, as the/// player's stream would answer them. "Before" withholds Tal's four whole towns (main's map: Tiberias, Safed and Netanyadiff --git a/unity/Assets/Tests/EditMode/TownLandmarksTests.cs b/unity/Assets/Tests/EditMode/TownLandmarksTests.csindex 273262049..3a38460d5 100644--- a/unity/Assets/Tests/EditMode/TownLandmarksTests.cs+++ b/unity/Assets/Tests/EditMode/TownLandmarksTests.cs@@ -48,6 +48,10 @@ public class TownLandmarksTests"tiberias-town-v1", "safed-town-v1", "netanya-town-v1", "ramla-town-v1",};+ /// <summary>The four cities drawn from their building models at every zoom, with no whole-town model (owner, 2 November+ /// 2026, "Yes, small buildings at every zoom").</summary>+ internal static readonly string[] BigCities = { "tel_aviv", "jerusalem", "haifa", "jaffa" };+static MapScene OpenMap(){EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);@@ -95,14 +99,19 @@ public class TownLandmarksTestsforeach (var (id, _, done) in pending) done(Far(id));}+ /// <summary>Tel Aviv's, Jerusalem's and Haifa's whole-town models stay in the repository and the streamed catalogue, unused+ /// on the map (owner, 2 November 2026, "Yes, small buildings at every zoom": Tel Aviv, Jerusalem, Haifa and Jaffa draw+ /// their building models instead; Jaffa never had a whole town of its own, only the stone village). The other six are+ /// placed as #507 mapped them, with #2085's four generated towns.</summary>[Test]public void EveryTownModelIsUsedAndEachIsInTheStreamedTownsBundle(){var used = TownLandmarks.ById.Values.Concat(TownLandmarks.ByType.Values).Concat(TownLandmarks.ByAction.Values.Select(v => v.Model)).Distinct();- CollectionAssert.AreEquivalent(Towns, used, "all nine, as #507 mapped them, with #336's second Jerusalem for #507's (owner, 21 October 2026, #708), and #2085's generated towns");- foreach (var id in Towns) Assert.AreEqual("collection-" + id, CollectionCatalog.BundleOf(id), id);- Assert.AreEqual(TownLandmarks.TelAviv, TownLandmarks.ById["tel_aviv"]);+ var unused = new[] { TownLandmarks.TelAviv, TownLandmarks.Jerusalem3D, TownLandmarks.Haifa };+ CollectionAssert.AreEquivalent(Towns.Except(unused), used, "#507's mapping without Tel Aviv's, Jerusalem's and Haifa's whole towns (owner, 2 November 2026; Jaffa never had one), and #2085's generated towns");+ foreach (var id in Towns) Assert.AreEqual("collection-" + id, CollectionCatalog.BundleOf(id), id + " stays in the streamed catalogue");Assert.AreEqual(TownLandmarks.Kibbutz, TownLandmarks.ByType["kibbutz"]);+ Assert.AreEqual(TownLandmarks.StoneVillage, TownLandmarks.ByType["arab_town"], "the other Arab towns keep the stone village");}[Test]@@ -120,26 +129,35 @@ public class TownLandmarksTestsAssert.IsNull(TownLandmarks.ModelFor("no_such_action", new DateTime(1951, 1, 1)));}- /// <summary>The owner, 21 October 2026, on #708 (issuecomment-6323524970): #336's second Jerusalem (#886) "is Jerusalem's- /// only far-zoom model for the whole game. The first model stays in the repository, unused on the map. No date switch".- /// It streams from the towns bundle and stands on Jerusalem's core on every date; #507's first Jerusalem is never asked for.</summary>+ /// <summary>Owner ruling, 2 November 2026: "we had tal's smaller buildings alreaedy for tel aviv, jerusalem and haifa and+ /// jaffa - instead of the huge buildings", confirmed as "Yes, small buildings at every zoom". This replaces the 18 October+ /// "Whole model far, buildings near" for these four, and the 21 October ruling on #708 that #336's second Jerusalem is+ /// Jerusalem's far-zoom model. On every date none of the four has a whole-town model, none is placed, and neither+ /// Jerusalem, nor Tel Aviv's or Haifa's whole town, is asked for. Jaffa's stone village still stands at the other Arab+ /// towns.</summary>[Test]- public void JerusalemIsTheSecondStoneCityOnEveryDate()+ public void TheFourCitiesHaveNoWholeTownModelOnAnyDate(){- Assert.AreEqual("collection-" + TownLandmarks.Jerusalem3D, CollectionCatalog.BundleOf(TownLandmarks.Jerusalem3D));- Assert.AreEqual(TownLandmarks.Jerusalem3D, TownLandmarks.ById["jerusalem"]);- CollectionAssert.DoesNotContain(TownLandmarks.ById.Values.Concat(TownLandmarks.ByType.Values).ToList(), TownLandmarks.Jerusalem,- "#507's first Jerusalem stays in the repository, unused on the map");var content = ContentLoader.Load(Statecraft.Game.Paths.Content);var map = OpenMap();+ foreach (var id in BigCities)+ Assert.IsNull(TownLandmarks.ModelFor(map.Settlements.Single(s => s.Id == id)), id + ": no whole-town model");+ Assert.IsNotNull(TownLandmarks.ModelFor(map.Settlements.Single(s => s.Id == "petah_tikva")), "the other towns keep theirs");+ var models = new List<string>();foreach (var date in new[] { content.Rules.Start, new DateTime(1949, 4, 15), new DateTime(1951, 12, 15) }){var t = TownLandmarks.ShowAt(map, date, Array.Empty<Placement>(), content)!;- CollectionAssert.DoesNotContain(asked.Select(a => a.id).ToList(), TownLandmarks.Jerusalem, "the first Jerusalem is never asked for");+ models.AddRange(asked.Select(a => a.id));+ foreach (var unused in new[] { TownLandmarks.TelAviv, TownLandmarks.Jerusalem, TownLandmarks.Jerusalem3D, TownLandmarks.Haifa })+ CollectionAssert.DoesNotContain(models, unused, $"{date:d MMM yyyy}: {unused} is never asked for");AnswerAll();- Assert.AreEqual(TownLandmarks.Jerusalem3D, t.Placed.Single(p => p.Key == "jerusalem").Model, $"{date:d MMM yyyy}");- Assert.IsTrue(t.Seats.ContainsKey("jerusalem"), "on its core");+ foreach (var id in BigCities)+ {+ Assert.IsFalse(t.Wanted.Any(w => w.Key == id), $"{date:d MMM yyyy}: {id} wants no landmark");+ Assert.IsFalse(t.Seats.ContainsKey(id), $"{date:d MMM yyyy}: {id} has no seat");+ }}+ CollectionAssert.Contains(models, TownLandmarks.StoneVillage, "the other Arab towns keep the stone village");}/// <summary>#1288: "An EditMode test that each of the three towns resolves to its model." Each of Tiberias, Safed and Netanya@@ -224,7 +242,7 @@ public class TownLandmarksTestsvar footprint = new Dictionary<string, (Vector2 centre, float radius)>();foreach (var (centre, radius, id) in map.KitFootprints) if (!footprint.ContainsKey(id)) footprint[id] = (centre, radius);var mapped = Mapped(map);- Assert.Greater(mapped.Count, 20);+ Assert.AreEqual(21, mapped.Count, "all 25 since #2085 and Ramla, less the four cities (owner, 2 November 2026)");foreach (var s in mapped){var child = t.transform.Find(s.Id);@@ -328,7 +346,8 @@ public class TownLandmarksTests[Test]public void OnlyTheCurrentCamerasReadyTownsSuppressProceduralHouses(){- // Since #2085 every game town has a whole-town model, so the test unmaps one (Netanya) for its run: it stands in for an+ // Since #2085 every game settlement but the four cities (drawn from their building models at every zoom, owner,+ // 2 November 2026) has a whole-town model, so the test unmaps one town (Netanya) for its run: it stands in for an// unrelated plain town, and its kit must keep the fallback.var byId = (Dictionary<string, string>)TownLandmarks.ById;string unmapped = "netanya", row = byId[unmapped];@@ -339,7 +358,8 @@ public class TownLandmarksTestsvar t = ShowAll(map);var root = map.transform.Find(KitLayer.RootName);var mapped = Mapped(map);- var plain = map.Settlements.First(s => TownLandmarks.ModelFor(s) == null);+ var plain = map.Settlements.Single(s => s.Id == unmapped);+ Assert.IsNull(TownLandmarks.ModelFor(plain), unmapped + " is unmapped for the run");var plainKit = root.Find(plain.Id).GetComponent<MeshRenderer>();foreach (var (d, close) in new[] { (120000f, false), (60000f, false), (TownModelLayer.CloseEnterM - 1000f, true), (CameraController.MinDistance, true) }){@@ -358,6 +378,9 @@ public class TownLandmarksTestsvar buildingLayer = root.GetComponentInChildren<TownModelLayer>();bool plainReady = (bool)ResidencyCall(buildingLayer, typeof(TownModelLayer), "ReadyForTown", plain.Id, Camera.main)!;Assert.AreEqual(plainReady, plainKit.forceRenderingOff, "an unrelated plain town keeps fallback");+ // Above the close switch only the four cities' building models are admitted (TownModelLayer.AtZoom), so the+ // plain town is never ready there and its kit must draw.+ if (!close) Assert.IsFalse(plainReady, $"{d:F0} m: the plain town's building models are not admitted");}}finally { byId[unmapped] = row; }@@ -379,10 +402,11 @@ public class TownLandmarksTestsvar t = ShowAll(map);var root = map.transform.Find(KitLayer.RootName);Assert.IsFalse(root.GetComponentInChildren<TownModelLayer>().HasModels);- RenderAt(map, map.KitFootprints.First(f => f.id == "tel_aviv").centre, CameraController.MinDistance);- Assert.IsFalse(t.transform.Find("tel_aviv").GetComponentsInChildren<Renderer>(true).All(r => r.forceRenderingOff),+ // Petah Tikva: Tel Aviv has no whole-town model since the owner's ruling of 2 November 2026.+ RenderAt(map, map.KitFootprints.First(f => f.id == "petah_tikva").centre, CameraController.MinDistance);+ Assert.IsFalse(t.transform.Find("petah_tikva").GetComponentsInChildren<Renderer>(true).All(r => r.forceRenderingOff),"the admitted whole town remains visible when individual buildings are unavailable");- Assert.IsTrue(root.Find("tel_aviv").GetComponent<MeshRenderer>().forceRenderingOff, "Tel Aviv's kit houses still never draw");+ Assert.IsTrue(root.Find("petah_tikva").GetComponent<MeshRenderer>().forceRenderingOff, "Petah Tikva's kit houses still never draw");}/// <summary>Owner, 18 October 2026: the models "seem to be on their side on the map". Every Collection Far prefab's root@@ -520,12 +544,14 @@ public class TownLandmarksTestsCollectionAssert.IsEmpty(t.Missing, "every wanted landmark found a spot");Assert.AreEqual(t.Wanted.Count, t.Placed.Count);- Assert.AreEqual(1, t.Placed.Count(p => p.Key == "tel_aviv" && p.Model == TownLandmarks.TelAviv));+ CollectionAssert.IsEmpty(t.Placed.Where(p => BigCities.Contains(p.Key)), "the four cities draw their buildings instead");+ Assert.AreEqual(1, t.Placed.Count(p => p.Key == "petah_tikva" && p.Model == TownLandmarks.Moshava));Assert.AreEqual(map.Settlements.Count(s => s.Type == "kibbutz"), t.Placed.Count(p => p.Model == TownLandmarks.Kibbutz));// Owner on #917 (17 October 2026): "Keep at all seven" arab_town rows; on 2 November 2026 Ramla took Tal's own town- // ("Yes, Tal's Ramla (Recommended)"), so the stone village stands at the other six.+ // ("Yes, Tal's Ramla (Recommended)") and Jaffa draws its buildings instead ("Yes, small buildings at every zoom"), so the+ // stone village stands at the other five.Assert.AreEqual(7, map.Settlements.Count(s => s.Type == "arab_town"));- Assert.AreEqual(6, t.Placed.Count(p => p.Model == TownLandmarks.StoneVillage), "the stone village at the six Arab towns but Ramla");+ Assert.AreEqual(5, t.Placed.Count(p => p.Model == TownLandmarks.StoneVillage), "the stone village at the five Arab towns but Ramla and Jaffa");Assert.AreEqual(1, t.Placed.Count(p => p.Key == "ramla" && p.Model == TownLandmarks.Ramla), "Ramla stands as its own town");}@@ -573,14 +599,15 @@ public class TownLandmarksTestsvar c = ContentLoader.Load(Statecraft.Game.Paths.Content);var t = TownLandmarks.ShowAt(map, new DateTime(1949, 1, 1), Array.Empty<Placement>(), c)!;AdmitGeometryTowns(map, t);- var tel = asked.Single(a => a.id == TownLandmarks.TelAviv);- LogAssert.Expect(LogType.Warning, new Regex("^LANDMARKS: the town model tel-aviv-white-city-v1 did not stream"));- tel.done(null);+ // The moshava town (Tel Aviv's White City until the owner's ruling of 2 November 2026).+ var moshava = asked.Single(a => a.id == TownLandmarks.Moshava);+ LogAssert.Expect(LogType.Warning, new Regex("^LANDMARKS: the town model moshava-town-v1 did not stream"));+ moshava.done(null);Assert.AreEqual(0, t.transform.childCount);- foreach (var (id, _, done) in asked.Where(a => a.id != TownLandmarks.TelAviv).ToList()) done(Far(id));+ foreach (var (id, _, done) in asked.Where(a => a.id != TownLandmarks.Moshava).ToList()) done(Far(id));Assert.Greater(t.Placed.Count, 0, "the others are drawn");- CollectionAssert.DoesNotContain(t.Placed.Select(p => p.Key), "tel_aviv");- CollectionAssert.Contains(t.Missing, "tel_aviv");+ CollectionAssert.DoesNotContain(t.Placed.Select(p => p.Key), "petah_tikva");+ CollectionAssert.Contains(t.Missing, "petah_tikva");}/// <summary>#2099, as #2046 for the camp tents: the edit-mode render callback (the beginCameraRendering handler itself)diff --git a/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs b/unity/Assets/Tests/EditMode/TownModelResidencyTests.csindex ed86f3110..b25bb199d 100644--- a/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs+++ b/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs@@ -7,6 +7,7 @@ using NUnit.Framework;using UnityEditor.SceneManagement;using UnityEngine;using UnityEngine.TestTools;+using UnityEngine.TestTools.Constraints;using Statecraft.Game.Map;using Statecraft.Game.Map.Kits;using Statecraft.Game.Map.Collection;@@ -868,6 +869,15 @@ public class TownModelResidencyTests}public void Submit(Camera camera) =>typeof(TownModelLayer).GetMethod("Submit", Flags)!.Invoke(layer, new object[] { default(UnityEngine.Rendering.ScriptableRenderContext), camera });+ /// <summary>As <see cref="Settle"/>, but the request for <paramref name="failed"/> is answered with nothing (its bundle+ /// did not load).</summary>+ public void SettleFailing(Camera camera, string failed)+ {+ layer.PrepareCamera(camera);+ foreach (var pair in answers.ToList()) pair.Value(pair.Key == failed ? null : prefab);+ answers.Clear();+ layer.PrepareCamera(camera);+ }/// <summary>The merged locality tile renderer (and its close mesh) that holds a place's ground point.</summary>public (MeshRenderer kit, MeshRenderer close) Tile(Vector2 at){@@ -952,6 +962,137 @@ public class TownModelResidencyTestsAssert.IsTrue(s.layer.ReadyForTown("tel_aviv", camera), "Tel Aviv beside Jaffa at 12 km");}+ /// <summary>Owner ruling, 2 November 2026: "we had tal's smaller buildings alreaedy for tel aviv, jerusalem and haifa and+ /// jaffa - instead of the huge buildings", confirmed as "Yes, small buildings at every zoom". In the player's streaming+ /// path and the production policy, each of the four cities in view is drawn from its building models at the widest zoom+ /// (250 km), the opening zoom (90 km), the gameplay view (60 km), 30 km and the closest zoom: they are asked for, the+ /// kit gives way and the models draw. Another town in view far off keeps its kit and asks for nothing.</summary>+ [Test]+ public void TheFourCitiesDrawTheirBuildingModelsAtEveryZoom()+ {+ using var s = new StreamedMap();+ // First, a fresh camera over Petah Tikva (beside Tel Aviv and Jaffa) at the opening zoom: it keeps its kit (and its+ // whole-town model), and only the four cities' kinds are asked for.+ var cityKinds = TownLandmarksTests.BigCities.SelectMany(id => s.layer.InstancesOf(id)).Select(m => TownModels.Ids[(int)m.Model])+ .ToHashSet(StringComparer.Ordinal);+ var petah = s.Footprint("petah_tikva");+ var far = s.Camera(petah.centre, 90_000f);+ s.Settle(far);+ Assert.IsFalse(s.layer.ReadyForTown("petah_tikva", far), "Petah Tikva at 90 km: no building models");+ Assert.IsFalse(s.kits.Find("petah_tikva").GetComponent<MeshRenderer>().forceRenderingOff, "Petah Tikva's kit draws at 90 km");+ Assert.IsTrue(s.layer.ReadyForTown("tel_aviv", far), "Tel Aviv in the same view: its building models");+ CollectionAssert.IsNotEmpty(s.RequestOrder);+ CollectionAssert.IsSubsetOf(s.RequestOrder.Distinct().ToList(), cityKinds.ToList(), "far off only the four cities' kinds are asked for");+ // A merged village tile never holds one of the four cities (AdmitInView decides a place by its first id).+ var viewPlaces = (System.Collections.IEnumerable)typeof(TownModelLayer).GetField("viewPlaces", Flags)!.GetValue(s.layer)!;+ foreach (var (ids, _) in viewPlaces.Cast<(string[] ids, Bounds bounds)>())+ if (ids.Length > 1) CollectionAssert.IsEmpty(ids.Intersect(TownLandmarksTests.BigCities).ToList(), string.Join(",", ids));+ foreach (var id in TownLandmarksTests.BigCities)+ {+ var at = s.Footprint(id).centre;+ Assert.Greater(s.layer.CountFor(id), 0, id + " has building models");+ var kit = s.kits.Find(id).GetComponent<MeshRenderer>();+ foreach (float d in new[] { CameraController.MaxDistance, 90_000f, GameplayM, ThirtyKmM, CameraController.MinDistance })+ {+ var camera = s.Camera(at, d);+ string where = FormattableString.Invariant($"{id} at {d / 1000f} km");+ s.Settle(camera);+ Assert.IsTrue(s.layer.ReadyForTown(id, camera), where + ": building models admitted and ready");+ Assert.IsTrue(kit.forceRenderingOff, where + ": the kit gives way");+ s.Submit(camera);+ Assert.Greater(s.layer.LastDrawn, 0, where + ": the building models draw");+ TestContext.WriteLine($"{where}: {s.layer.LastDrawn} instances in {s.layer.LastDraws} draws");+ }+ }+ }++ /// <summary>Owner ruling on #2267, 2 November 2026: "Shadows off far, then measure (Recommended)" ("Turn off these+ /// buildings' shadows beyond 40 km now"). Beyond the close switch the four cities' buildings draw without casting shadows+ /// (250 km and 90 km); below it every building casts as before (30 km and the closest zoom).</summary>+ [Test]+ public void TheFourCitiesBuildingsCastNoShadowsFarOff()+ {+ using var s = new StreamedMap();+ foreach (var id in TownLandmarksTests.BigCities)+ {+ var at = s.Footprint(id).centre;+ foreach (var (d, cast) in new[] { (CameraController.MaxDistance, false), (90_000f, false), (ThirtyKmM, true), (CameraController.MinDistance, true) })+ {+ var camera = s.Camera(at, d);+ string where = FormattableString.Invariant($"{id} at {d / 1000f} km");+ s.Settle(camera);+ s.Submit(camera);+ Assert.Greater(s.layer.LastDrawn, 0, where + ": the building models draw");+ Assert.AreEqual(cast ? s.layer.LastDrawn : 0, s.layer.LastShadowCasters, where + (cast ? ": every building casts" : ": no building casts"));+ }+ }+ }++ /// <summary>The shadows follow the close switch with its hysteresis (TownModelLayer.CloseAt: in below CloseEnterM, 40 km,+ /// out above CloseExitM, 45 km). Over Tel Aviv, coming in: none at 90 km and at 42 km (inside the band, still far), all+ /// at 39 km; going out: all at 43 km (inside the band, still close), none at 46 km.</summary>+ [Test]+ public void TheFourCitiesShadowsFollowTheCloseSwitchBothWays()+ {+ using var s = new StreamedMap();+ var at = s.Footprint("tel_aviv").centre;+ var camera = s.Camera(at, 90_000f);+ foreach (var (d, cast) in new[] { (90_000f, false), (42_000f, false), (39_000f, true), (43_000f, true), (46_000f, false) })+ {+ s.Pose(camera, at, d); s.Settle(camera); s.Submit(camera);+ string where = FormattableString.Invariant($"Tel Aviv at {d / 1000f} km");+ Assert.Greater(s.layer.LastDrawn, 0, where + ": the building models draw");+ Assert.AreEqual(cast ? s.layer.LastDrawn : 0, s.layer.LastShadowCasters, where + (cast ? ": every building casts" : ": no building casts"));+ }+ }++ /// <summary>The far view is the common one now that the four cities draw there: once settled, a far camera's draw+ /// submission allocates nothing (no frustum array per camera per frame).</summary>+ [Test]+ public void AFarViewSubmitsWithoutAllocating()+ {+ using var s = new StreamedMap();+ var camera = s.Camera(s.Footprint("tel_aviv").centre, CameraController.MaxDistance);+ s.Settle(camera);+ var submit = (Action<UnityEngine.Rendering.ScriptableRenderContext, Camera>)Delegate.CreateDelegate(+ typeof(Action<UnityEngine.Rendering.ScriptableRenderContext, Camera>), s.layer, typeof(TownModelLayer).GetMethod("Submit", Flags)!);+ for (int i = 0; i < 3; i++) submit(default, camera); // warm: list capacities, the instancing path+ Assert.Greater(s.layer.LastDrawn, 0, "the four cities draw at 250 km");+ // The recorder must see an allocation of the size in question, so a pass is not vacuous.+ Assert.That(() => { var planes = new Plane[6]; GC.KeepAlive(planes); }, new UnityEngine.TestTools.Constraints.AllocatingGCMemoryConstraint());+ Assert.That(() => submit(default, camera), UnityEngine.TestTools.Constraints.Is.Not.AllocatingGCMemory(), "one far submission");+ }++ /// <summary>A failed building bundle in one of the four cities (Tel Aviv's b01): the city keeps its code-built kit at 90 km+ /// and at 2 km (it has no whole-town model to fall back to), the map draws on, the kind is asked for once, and the layer+ /// warns once.</summary>+ [Test]+ public void ACityWhoseBuildingBundleFailsKeepsItsKit()+ {+ using var s = new StreamedMap();+ const string failed = "b01-white-city-v2";+ int warnings = 0;+ void Count(string message, string _, LogType type) { if (type == LogType.Warning && message.Contains(failed)) warnings++; }+ Application.logMessageReceived += Count;+ try+ {+ var at = s.Footprint("tel_aviv").centre;+ var kit = s.kits.Find("tel_aviv").GetComponent<MeshRenderer>();+ var camera = s.Camera(at, 90_000f);+ foreach (float d in new[] { 90_000f, 2_000f, 90_000f })+ {+ s.Pose(camera, at, d); s.SettleFailing(camera, failed);+ string where = FormattableString.Invariant($"Tel Aviv at {d / 1000f} km");+ Assert.IsFalse(s.layer.ReadyForTown("tel_aviv", camera), where + ": not ready without b01");+ Assert.IsFalse(kit.forceRenderingOff, where + ": the kit draws");+ Assert.DoesNotThrow(() => s.Submit(camera), where);+ }+ Assert.AreEqual(1, s.RequestOrder.Count(id => id == failed), "b01 is asked for once");+ Assert.AreEqual(1, warnings, "one warning for the failed kind");+ }+ finally { Application.logMessageReceived -= Count; }+ }+/// <summary>The 1.5 GB guard: zooming out to the 60 km gameplay view releases every building-model lease and the kits/// draw again.</summary>[Test]@@ -966,7 +1107,14 @@ public class TownModelResidencyTestsAssert.IsNotEmpty(s.RequestOrder);s.Pose(camera, imwas.centre, GameplayM);s.layer.PrepareCamera(camera); s.layer.RetireReleasedModels();- Assert.AreEqual(s.RequestOrder.Count, s.Released, "every building-model lease is released at 60 km");+ // The four cities' buildings in view stay at every zoom (owner, 2 November 2026). From 60 km over Imwas the view holds+ // Jerusalem, Tel Aviv and Jaffa, not Haifa: a fixed expectation, and only those three cities' kinds stay.+ var inView = new[] { "jaffa", "jerusalem", "tel_aviv" };+ CollectionAssert.AreEquivalent(inView, TownLandmarksTests.BigCities.Where(id => s.layer.AdmitsTown(id, camera)).ToList(),+ "the cities admitted at 60 km over Imwas");+ var kept = inView.SelectMany(id => s.layer.InstancesOf(id)).Select(m => TownModels.Ids[(int)m.Model]).ToHashSet(StringComparer.Ordinal);+ Assert.AreEqual(s.RequestOrder.Count(id => !kept.Contains(id)), s.Released,+ "every building-model lease is released at 60 km but the kinds of the four cities in view: " + string.Join(", ", kept));Assert.IsFalse(s.layer.ReadyForTown("imwas", camera), "no building models at 60 km");Assert.IsFalse(kit.forceRenderingOff, "the kit tile draws again at 60 km");}diff --git a/unity/Assets/Tests/EditMode/TownModelTests.cs b/unity/Assets/Tests/EditMode/TownModelTests.csindex 24be8d0e0..17dca1967 100644--- a/unity/Assets/Tests/EditMode/TownModelTests.cs+++ b/unity/Assets/Tests/EditMode/TownModelTests.cs@@ -190,8 +190,10 @@ public class TownModelTests{var map = OpenMap();var built = Build(map, out var placed);- var mapped = map.Settlements.Where(s => Statecraft.Game.Map.Collection.TownLandmarks.ModelFor(s) != null).ToList();- TestContext.WriteLine($"{mapped.Count} towns with a whole-town model: {string.Join(", ", mapped.Select(s => s.Id))}");+ // With the four cities drawn from their building models at every zoom (owner, 2 November 2026), which have no whole-town model.+ var mapped = map.Settlements.Where(s => Statecraft.Game.Map.Collection.TownLandmarks.ModelFor(s) != null+ || TownLandmarksTests.BigCities.Contains(s.Id)).ToList();+ TestContext.WriteLine($"{mapped.Count} towns with a whole-town model or buildings at every zoom: {string.Join(", ", mapped.Select(s => s.Id))}");var ids = mapped.Select(s => s.Id).ToHashSet();CollectionAssert.IsSubsetOf(new[] { "tel_aviv", "jerusalem", "haifa", "rishon_lezion", "degania_alef", "nahalal", "nazareth" }, ids);Assert.AreEqual(new[] { "arab_town", "city", "kibbutz", "moshav", "town" }, mapped.Select(s => s.Type).Distinct().OrderBy(t => t).ToArray());@@ -471,10 +473,11 @@ public class TownModelTests}/// <summary>Owner ruling on #700, "Models up close only": at gameplay03 and diorama02 every kit mesh draws (main's- /// towns) and no model does; at the close views (tel_aviv30, jaffa12) the models draw (well over a hundred), every kit- /// individual-town mesh gives way to its close mesh (mixed locality tiles keep fallback), and the models stay within- /// the fixture's complete original-geometry work; zooming back out restores- /// the kits. The "kits" toggle stops the models too.</summary>+ /// towns) and no model does, but for Tel Aviv, Jerusalem, Haifa and Jaffa, whose building models draw at every zoom+ /// (owner, 2 November 2026, "Yes, small buildings at every zoom"); at the close views (tel_aviv30, jaffa12) the models+ /// draw (well over a hundred), every kit individual-town mesh gives way to its close mesh (mixed locality tiles keep+ /// fallback), and the models stay within the fixture's complete original-geometry work; zooming back out restores+ /// the kits. The "kits" toggle stops the models too. The log line is the draw cost at each pose.</summary>[UnityTest]public IEnumerator TheKitsDrawFarAndTheModelsUpClose(){@@ -509,31 +512,49 @@ public class TownModelTests// rendering more than every fixture instance once is a duplicate-submission regression.long maxGeometryWork = layer.Instances().Sum(i => (long)originals.meshes[(int)i.model].triangles.Length / 3);var results = new List<string>();+ var big = TownLandmarksTests.BigCities;+ int bigInstances = big.Sum(id => layer.CountFor(id));void Check(PromoPose pose, bool close){+ // Up close every detailed town; far off only the four cities, and in this fixture only within its focus admission+ // (OriginalModelDistance.EnterM, 120 km: gameplay03 at 60 km, not diorama02 at 250 km). This fixture has no view+ // admission; TheFourCitiesDrawTheirBuildingModelsAtEveryZoom checks production's at 250 km.+ bool farFocus = pose.Distance < Statecraft.Game.Map.Collection.OriginalModelDistance.EnterM;+ bool Ready(string town) => layer.CountFor(town) > 0 && (close || (big.Contains(town) && farFocus));+ foreach (var s in map.Settlements)+ if (!close && !big.Contains(s.Id)) Assert.IsFalse(layer.ReadyForTown(s.Id, cam), pose.Name + ": " + s.Id + " has no building model far off");Assert.AreEqual(close, layer.LastClose, pose.Name);foreach (var renderer in kitRs){- bool ready = close && identity.TryGetValue(renderer, out var town) && layer.CountFor(town) > 0;+ bool ready = identity.TryGetValue(renderer, out var town) && Ready(town);Assert.AreEqual(ready, renderer.forceRenderingOff, pose.Name + ": " + renderer.name + " fallback");}foreach (var renderer in closeRs){var kitName = renderer.name.Substring(0, renderer.name.Length - KitLayer.CloseSuffix.Length);var kit = root.Find(kitName).GetComponent<MeshRenderer>();- bool ready = close && identity.TryGetValue(kit, out var town) && layer.CountFor(town) > 0;+ bool ready = identity.TryGetValue(kit, out var town) && Ready(town);Assert.AreEqual(!ready, renderer.forceRenderingOff, pose.Name + ": " + renderer.name + " close mesh");}Assert.IsTrue(kitRs.Any(r => !identity.ContainsKey(r)), "mixed locality tiles stay fallback at every zoom");results.Add($"{pose.Name}: close={close} {layer.LastDrawn} models, {layer.LastTriangles} triangles, {layer.LastDraws} draws");- if (!close) { Assert.AreEqual(0, layer.LastDrawn, pose.Name + ": no model"); return; }+ if (!close)+ {+ // Far off, only the four cities' buildings, never more than all of theirs: some at gameplay03 (Tel Aviv and+ // Jaffa in view), none at diorama02 (outside this fixture's focus admission).+ Assert.LessOrEqual(layer.LastDrawn, bigInstances, pose.Name + ": no other town's building model");+ if (farFocus) Assert.Greater(layer.LastDrawn, 0, pose.Name + ": the four cities' buildings in view");+ else Assert.AreEqual(0, layer.LastDrawn, pose.Name + ": nothing outside the fixture's focus admission");+ return;+ }Assert.Greater(layer.LastDrawn, 100, pose.Name + ": models drawn");Assert.LessOrEqual(layer.LastTriangles, maxGeometryWork, pose.Name + ": no more than all original instances once");}foreach (var pose in PromoPose.All) { pose.Apply(rig, map.Frame); RenderSample.Render(cam, 1920, 1080); layer.PrepareCamera(cam); Check(pose, false); }foreach (var pose in PromoPose.CloseUps) { pose.Apply(rig, map.Frame); RenderSample.Render(cam, 1920, 1080); layer.PrepareCamera(cam); Check(pose, true); }PromoPose.Gameplay03.Apply(rig, map.Frame); RenderSample.Render(cam, 1920, 1080); layer.PrepareCamera(cam); Check(PromoPose.Gameplay03, false);- TestContext.WriteLine($"{layer.Count} models; " + string.Join("; ", results));+ TestContext.WriteLine($"{layer.Count} models ({bigInstances} in the four cities: " ++ string.Join(", ", big.Select(id => $"{id} {layer.CountFor(id)}")) + "); " + string.Join("; ", results));PromoPose.CloseUps[0].Apply(rig, map.Frame);VisualToggles.Set("kits", false); RenderSample.Render(cam, 320, 180);Assert.IsFalse(layer.Draw, "the kits toggle hides the models");