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.

Map: Tel Aviv, Jerusalem, Haifa and Jaffa draw their kit blocks from 40 km out and Tal's building models below the close switch (Refs #2007) (#2876)

Eyal Golan0afbaa1ef499
diff --git a/changelog.d/major-cities-kit-every-zoom.md b/changelog.d/major-cities-kit-every-zoom.md
new file mode 100644
index 000000000..73754a04f
--- /dev/null
+++ b/changelog.d/major-cities-kit-every-zoom.md
@@ -0,0 +1,25 @@
+### Changed
+
+- Tel Aviv, Jerusalem, Haifa and Jaffa keep their big code-built blocks, with their landmarks, from 40 km out: there
+ they no longer draw Tal Heuberger's far-off building copies (owner, 6 November 2026: "Big blocks, every zoom", "Just
+ the four (Recommended)"). Closer than 40 km they show Tal Heuberger's building models, as before (owner, 7 November
+ 2026: "Tal's models close (Recommended)", which replaces "Big blocks, every zoom" below 40 km), switching back to
+ the blocks past 45 km, as every other town does. This replaces the 2 November 2026 ruling ("Yes, small buildings at
+ every zoom"). A city is one of these when its 1945 population is at least 60,000. The game no longer streams these
+ four cities' far-off building copies; the files still ship.
+- An arms workshop built in one of these four cities stands at the edge of the city (owner, 6 November 2026: "make the
+ workshop at the edge of the city"), just past the city's outermost blocks, on its hex where it can be and otherwise on
+ the land beside the city, with the camera's side (the south) tried first, so the map's camera can see it past the big
+ blocks: no block between it and the camera rises above it, and no tree in front of it is drawn. It stands on ground the
+ map shows Israeli-held on the day it was built, and keeps that spot as the front moves. It keeps off the sea and the
+ beach, the routes, the units, the names and the other buildings (the big blocks and Tal Heuberger's building models both), and stands nearer its own city's blocks than any other
+ city's. Where no such spot is left, the workshop is not drawn and the game logs a warning naming the city, rather than
+ standing it hidden behind the blocks.
+- Tel Aviv's three port sheds are shorter along the shore, so they read as three sheds up close rather than one long
+ strip.
+- Every built arms workshop's building is drawn 2.5 times bigger, 720 m long on the map instead of 288 m (owner,
+ 6 November 2026: "the workshop should be bigger as it's barely visible"). It keeps a wider ring of ground clear
+ around it to match, so in a crowded town its spot may move.
+- An arms workshop in any other town whose spot on its own hex would be on the beach stands at the town's edge instead,
+ where it can with no tree in front of it (owner, 7 November 2026, on Hadera: "Move the workshop (Recommended)":
+ Hadera's workshop moves to a clear spot at the town's edge, and the palms stay). On today's map that is Hadera alone.
diff --git a/docs/generated-buildings-props.md b/docs/generated-buildings-props.md
index 6079e0725..4824fa714 100644
--- a/docs/generated-buildings-props.md
+++ b/docs/generated-buildings-props.md
@@ -22,7 +22,7 @@ Mesh and animation import compression are Off. Every source clip is kept; all el
## Loading and placement dependency
-Update, 27 October 2026: the tent (06) now streams after the first frame in its own bundle from `Assets/Art/Collection/`, placed by `RuralLife` at the Bedouin camp areas. The five houses (01 to 05) stream after the first frame, each in its own bundle from `Assets/Art/Settlements/Prototype/Models/`, asked for by `TownModelLayer` for the towns below its close switch, and in the far band for the towns that take the far-off copies (`TownModelLayer.AtZoom`), where the `-far` copy is requested; Tel Aviv, Jerusalem, Haifa and Jaffa are admitted at every zoom (`TownModels.AtEveryZoom`). Where the houses are placed: 01 to 03 in Netanya only, 04 on Tiberias's plots, 05 on the stone-village plots of the Arab towns and villages, Safed and Jerusalem's village plots. Since 2 November 2026 (owner: "we need everything to be in the new generation") these houses stand alone there: #507's b13a two-storey house no longer stands in Netanya, and #507's b17 courtyard house no longer stands beside 05. The Tiberias hex board draws the lighter level of 04 in the editor (`HexModels.HouseLevels`, #1901); a player keeps the board's basalt stand-ins, since the houses' bundles carry only their full `-stream` prefabs. No player scene and no Resources asset depends on the tent or the houses (`CollectionImportTests.PlacedGeneratedModelsReachThePlayerOnlyThroughTheirOwnBundles`). The khaki tent (08) streams after the first frame in its own bundle from `Assets/Art/Collection/`, owned by `CampTentModels` only while a camera is close to a transit camp, in place of that camp's khaki ridge tents. The four props (09 to 12) stream after the first frame, each in its own bundle from `Assets/Art/Collection/`, asked for by `SpecialBuildingModels` only while a camera is close to where one stands (the special-building residency's enter and exit distances) and released when it leaves, on its dates (the owner's 2 November 2026 rulings, "Place all four now (Recommended)" and, on #2274, "Near-only for these props (Recommended)"). Every other special building keeps its map-wide request (owner ruling 29, 30 October 2026, "Far models map-wide"), and the Dakota streams map-wide as the other craft do. The rest of this section describes them as delivered.
+Update, 27 October 2026: the tent (06) now streams after the first frame in its own bundle from `Assets/Art/Collection/`, placed by `RuralLife` at the Bedouin camp areas. The five houses (01 to 05) stream after the first frame, each in its own bundle from `Assets/Art/Settlements/Prototype/Models/`, asked for by `TownModelLayer` for the towns below its close switch, and in the far band for the towns that take the far-off copies (`TownModelLayer.AtZoom`), where the `-far` copy is requested; Tel Aviv, Jerusalem, Haifa and Jaffa were admitted at every zoom under the owner's ruling of 2 November 2026 ("Yes, small buildings at every zoom", superseded), since the owner's ruling of 6 November 2026 ("Big blocks, every zoom") draw their kits from 40 km out, and since the owner's ruling of 7 November 2026 ("Tal's models close (Recommended)", which supersedes "Big blocks, every zoom" below the switch) are admitted below the close switch as every other town (`TownModels.IsMajorCity`). Where the houses are placed: 01 to 03 in Netanya only, 04 on Tiberias's plots, 05 on the stone-village plots of the Arab towns and villages, Safed and Jerusalem's village plots. Since 2 November 2026 (owner: "we need everything to be in the new generation") these houses stand alone there: #507's b13a two-storey house no longer stands in Netanya, and #507's b17 courtyard house no longer stands beside 05. The Tiberias hex board draws the lighter level of 04 in the editor (`HexModels.HouseLevels`, #1901); a player keeps the board's basalt stand-ins, since the houses' bundles carry only their full `-stream` prefabs. No player scene and no Resources asset depends on the tent or the houses (`CollectionImportTests.PlacedGeneratedModelsReachThePlayerOnlyThroughTheirOwnBundles`). The khaki tent (08) streams after the first frame in its own bundle from `Assets/Art/Collection/`, owned by `CampTentModels` only while a camera is close to a transit camp, in place of that camp's khaki ridge tents. The four props (09 to 12) stream after the first frame, each in its own bundle from `Assets/Art/Collection/`, asked for by `SpecialBuildingModels` only while a camera is close to where one stands (the special-building residency's enter and exit distances) and released when it leaves, on its dates (the owner's 2 November 2026 rulings, "Place all four now (Recommended)" and, on #2274, "Near-only for these props (Recommended)"). Every other special building keeps its map-wide request (owner ruling 29, 30 October 2026, "Far models map-wide"), and the Dakota streams map-wide as the other craft do. The rest of this section describes them as delivered.
As delivered on #1379 (24 October 2026), before #1273's town-building streaming: Eyal's [23 October rulings](https://github.com/eyalgolan/statecraft-israel/pull/1379#issuecomment-6358297184) require own streamed bundles after the first frame, or the houses may use #1273's town-building streaming once it lands. Current main `703d87cf` has no compatible town-stream interface. This branch does not build that system: it removes its new campaign/catalog references, leaves existing towns/camps unchanged and records only [prepared mappings](generated-buildings-props-mapping.json) outside runtime code. Nothing new enters Resources, the 1948 Collection or the initial player art dependency graph. No WebGL download measurement is claimed.
diff --git a/docs/map-model-residency.md b/docs/map-model-residency.md
index d58c2c671..48a2e1476 100644
--- a/docs/map-model-residency.md
+++ b/docs/map-model-residency.md
@@ -9,6 +9,8 @@ Each `MapScene` owns `ProductionResidency.Approved()` and passes its immutable p
The sea/air craft are not under residency (**owner ruling, 26 Oct 2026, #1273: "Craft visible at 60 km (Recommended)"**): as before, they are asked once a camera is in view, show at the 60 km gameplay view and are not unloaded on leave.
+Town buildings: the building models of Tel Aviv, Jerusalem, Haifa and Jaffa, the major cities (`TownModels.IsMajorCity`), are requested below the close switch as every other town's, the originals (**owner ruling, 7 Nov 2026: "Tal's models close (Recommended)"**), and never from 40 km out, where these cities draw their kit blocks (**owner ruling, 6 Nov 2026: "Big blocks, every zoom"**, which "Tal's models close (Recommended)" supersedes below the switch; it superseded the 2 Nov 2026 ruling that drew them at every zoom). A kind that only those four cities place streams as an original below the switch and never as a far-off copy; its far-off copy's bundle still ships.
+
The shared-road policy records the same approved category values, but the **sandwich convoy stays pinned** in this first slice, an explicitly approved alternative. Road bus, citrus truck and canvas lorry Near pins, train locomotive Far, wildlife ibex/hyena Near and hex-board lifetime ownership remain. Unit leases are independent. Near and Far share the same original bundle; another live owner or pin blocks unload.
Consumers restore fallback, invalidate late replies and clear generated instances/cache references before releasing their last lease. Retirement waits for deferred destruction and stream settlement before replacement admission. Invisible spatial unit demand preserves source ownership through token rebuilds and the rule that an Arab-force token waits for its own figure. Owned towns use their approved per-camera policy rather than a conflicting prefab cap. Camera-space ray calculation avoids kilometre-scale ground-focus errors from subtracting near/far world points at large coordinates.
diff --git a/unity/Assets/Scripts/Map/Collection/SpecialBuildingModels.cs b/unity/Assets/Scripts/Map/Collection/SpecialBuildingModels.cs
index 4baf2160c..d8fed1baf 100644
--- a/unity/Assets/Scripts/Map/Collection/SpecialBuildingModels.cs
+++ b/unity/Assets/Scripts/Map/Collection/SpecialBuildingModels.cs
@@ -31,7 +31,8 @@ namespace Statecraft.Game.Map.Collection
/// <summary>Design values, not sourced measurements: the real long side (m) each model stands for, so that at
/// <see cref="WorldScale"/> the fort, the barracks, the factory and the shikun block are each a few locomotive cars
- /// long and shorter than the whole train, and the workshop is a little over one.</summary>
+ /// long and shorter than the whole train, and the workshop is a little over one (drawn at <see cref="WorkshopScale"/>, 2.5 times
+ /// that, #2876: about 3.5, still shorter than the train).</summary>
public static float RealLengthM(string model) => model switch
{
Tegart => 30f, Barracks => 25f, Factory => 30f, Shikun => 30f, Workshop => 12f,
@@ -52,6 +53,7 @@ namespace Statecraft.Game.Map.Collection
/// <summary>The scale over <see cref="WorldScale"/> of <paramref name="model"/>'s rows (1 for a model with none).</summary>
public static float ScaleOf(string model)
{
+ if (model == Workshop) return WorkshopScale; // its rows are built per city project (ArmsWorkshops), not in All
foreach (var w in All) if (w.Model == model) return w.Scale;
return 1f;
}
@@ -61,6 +63,14 @@ namespace Statecraft.Game.Map.Collection
/// props over <see cref="WorldScale"/>. At the world scale alone they were about 10 px at the closest zoom.</summary>
public const float PropScale = 3f;
+ /// <summary>#2876, the owner, 6 November 2026 (verbatim): "the workshop should be bigger as it's barely visible"; the owner
+ /// then chose 2.5x on the coordinator's recommendation ("do it"). The b21's scale over <see cref="WorldScale"/>, one for
+ /// every built arms workshop, in a major city and in an ordinary town: 12 m x 24 x 2.5 = 720 m long (288 m at the world
+ /// scale alone), its clearance (<see cref="ClearanceOf(Want)"/>) about 511 m (204.5 m before). Both
+ /// <see cref="ArmsWorkshops"/>' rows and <see cref="ScaleOf"/>(<see cref="Workshop"/>) read it, so its size by model name
+ /// and by row agree.</summary>
+ public const float WorkshopScale = 2.5f;
+
/// <summary>The farthest (m) a town-edge prop may stand from its sourced point (owner on #2274: "right by the sourced
/// spot"): a spot farther out is not drawn, with a warning.</summary>
public const float MaxPropOffsetM = 1500f;
@@ -102,7 +112,8 @@ namespace Statecraft.Game.Map.Collection
/// <summary>The first day it is no longer drawn, or null: drawn from <see cref="From"/> on.</summary>
public readonly DateTime? To;
public readonly Siting Site;
- /// <summary>The row's own scale over <see cref="WorldScale"/> (1, or <see cref="PropScale"/> for the four props), and
+ /// <summary>The row's own scale over <see cref="WorldScale"/> (1, <see cref="PropScale"/> for the four props, or
+ /// <see cref="WorkshopScale"/> for a b21, #2876), and
/// whether it may stand at a town's edge, inside its kit footprint, clear of the town's building models, the tokens in
/// the towns and the name points instead (the four props; owner on #2274: "Bigger, closer").</summary>
public readonly float Scale; public readonly bool TownEdge;
@@ -113,11 +124,14 @@ namespace Statecraft.Game.Map.Collection
public readonly bool NearOnly;
/// <summary>The SeaCraft coast's place (<see cref="Siting.Shore"/>) or the route's id (<see cref="Siting.Road"/>).</summary>
public readonly string Along;
+ /// <summary>A workshop's city (CityProject.City; <see cref="ArmsWorkshops"/>), "" for every other row: in a major city
+ /// it stands at the city's edge (<see cref="EdgeSpot"/>).</summary>
+ public readonly string City;
public Want(string key, string model, DateTime from, double lon, double lat, string source)
: this(key, model, from, null, lon, lat, source, Siting.Seeded, "") { }
public Want(string key, string model, DateTime from, DateTime? to, double lon, double lat, string source, Siting site, string along,
- float scale = 1f, bool townEdge = false, bool nearOnly = false)
- { Key = key; Model = model; From = from; To = to; Lon = lon; Lat = lat; Source = source; Site = site; Along = along; Scale = scale; TownEdge = townEdge; NearOnly = nearOnly; }
+ float scale = 1f, bool townEdge = false, bool nearOnly = false, string city = "")
+ { Key = key; Model = model; From = from; To = to; Lon = lon; Lat = lat; Source = source; Site = site; Along = along; Scale = scale; TownEdge = townEdge; NearOnly = nearOnly; City = city; }
public bool Covers(DateTime date) => date >= From && (To == null || date < To.Value);
}
@@ -306,8 +320,8 @@ namespace Statecraft.Game.Map.Collection
if (p.Kind != Statecraft.Sim.Workshops.ArmsWorkshop || !(p.BuiltOn is DateTime on)) continue;
var hex = content.HexAt(p.Q, p.R);
if (hex == null) continue;
- list.Add(new Want(WorkshopKey(p.Id), Workshop, on, hex.Lon, hex.Lat,
- FormattableString.Invariant($"city project {p.Id}: {p.City}'s arms workshop on hex {p.Q},{p.R}")));
+ list.Add(new Want(WorkshopKey(p.Id), Workshop, on, null, hex.Lon, hex.Lat,
+ FormattableString.Invariant($"city project {p.Id}: {p.City}'s arms workshop on hex {p.Q},{p.R}"), Siting.Seeded, "", WorkshopScale, city: p.City));
}
return list;
}
@@ -619,7 +633,10 @@ namespace Statecraft.Game.Map.Collection
/// <summary>Where the buildings stand: each want in order at its route-facing (Degania), beach (<see cref="Siting.Shore"/>),
/// roadside (<see cref="Siting.Road"/>) or seeded spot, clear of the towns, the routes, the tokens of <paramref name="date"/>,
- /// the civilians, the wildlife and each other (a workshop also of its hex's edge and the farm scenes' plan; one of Tal's
+ /// the civilians, the wildlife and each other (a workshop also of its hex's edge and the farm scenes' plan, and on a hex
+ /// a major city's kit blocks reach, in the camera's sight past them, <see cref="InSight"/>; a major city's workshop at
+ /// the edge of the city's kit blocks instead, <see cref="EdgeSpot"/>, and another town's, where its hex has no spot, at
+ /// the edge of its drawn buildings, <see cref="TownEdgeSpot"/>; one of Tal's
/// four props, <see cref="Want.TownEdge"/>, at a town's edge, within <see cref="MaxPropOffset"/> of its point); the list
/// keeps those whose model <paramref name="available"/> holds. A row with no spot (no clear ground, or past the cap) is left
/// out whatever <paramref name="available"/> says, so no layer keeps clear of a prop that is not drawn. It reads only the
@@ -633,7 +650,18 @@ namespace Statecraft.Game.Map.Collection
/// model to lie along the road; only rows that got a spot have one.</summary>
internal static List<(Want want, Vector2 at)> PlanWithRoutes(MapScene map, DateTime date, IReadOnlyList<Want> wants, Func<string, bool> available, bool log,
IReadOnlyList<(RuralLife.Want want, Vector2 spot)>? ruralPlan, out IReadOnlyDictionary<string, Vector2> along)
+ => PlanWithRoutes(map, date, wants, available, log, ruralPlan, out along, out _);
+
+ /// <summary>Whether a town's workshop with no spot on its hex falls back to the town's edge (<see cref="TownEdgeSpot"/>):
+ /// always, but for a test that plans without it to show the fallback moves no other spot.</summary>
+ internal static bool TownEdgeFallback = true;
+
+ /// <summary>As the PlanWithRoutes above, also giving the keys of the workshops that stand at their town's edge because their hex had no spot
+ /// (<see cref="TownEdgeSpot"/>), in plan order.</summary>
+ internal static List<(Want want, Vector2 at)> PlanWithRoutes(MapScene map, DateTime date, IReadOnlyList<Want> wants, Func<string, bool> available, bool log,
+ IReadOnlyList<(RuralLife.Want want, Vector2 spot)>? ruralPlan, out IReadOnlyDictionary<string, Vector2> along, out IReadOnlyList<string> atTownEdge)
{
+ var edged = new List<string>(); atTownEdge = edged;
var roads = new Dictionary<string, Vector2>(StringComparer.Ordinal); along = roads;
var ground = PlacementLayer.CampGround(map);
var footprints = map.KitFootprints.Select(f => (f.centre, f.radius)).ToList();
@@ -655,26 +683,44 @@ namespace Statecraft.Game.Map.Collection
&& !ground.Water(p.x, p.y) && !ground.OnRoute(p, r) && !ground.OnToken(p, r, on);
bool Free(Vector2 p, float r) => FreeOn(p, r, date);
// The four props stand at a town's edge (owner on #2274: "Bigger, closer"): inside a footprint if need be, clear of the
- // towns' building models, of the tokens standing in towns and of every settlement's and locality's name point instead,
- // and of the farm scenes' plan, as the workshops (coordinator, 2 November 2026, on #2274: Q3).
+ // towns' drawn buildings (every town's building models, a major city's included, which it draws below the close
+ // switch: the owner, 7 November 2026, "Tal's models close (Recommended)"; and a major city's kit blocks, which it
+ // draws from 40 km out, #2876), of the tokens
+ // standing in towns and of every settlement's and locality's name point instead, and of the farm scenes' plan, as the
+ // workshops (coordinator, 2 November 2026, on #2274: Q3).
List<(Vector2, float)>? buildings = null, clearings = null; List<Vector2>? names = null;
+ List<(Vector2 c, float yaw, float w, float d)>? blocks = null;
bool FreeAtEdge(Vector2 p, float r)
{
if (buildings == null)
{
var towns = map.GetComponentInChildren<Kits.TownModelLayer>(true);
buildings = towns == null ? new List<(Vector2, float)>()
- : map.KitFootprints.SelectMany(f => towns.InstancesOf(f.id)).Select(i => (i.C, 0.5f * new Vector2(i.W, i.D).magnitude)).ToList();
+ : map.KitFootprints.SelectMany(f => towns.InstancesOf(f.id))
+ .Select(i => (i.C, 0.5f * new Vector2(i.W, i.D).magnitude)).ToList();
+ blocks = map.MajorCityBlocks.Select(b => (b.C, b.Yaw, b.W, b.D)).ToList();
clearings = map.UnitClearings.ToList();
names = map.Settlements.Concat(map.Localities.Select(l => l.Settlement))
.Select(s => { var n = map.Frame.ToWorld(s.Lon, s.Lat, 0); return new Vector2(n.x, n.z); }).ToList();
}
foreach (var n in names!) if ((n - p).sqrMagnitude <= r * r) return false;
- return TownLandmarks.Clear(p, r, taken) && TownLandmarks.Clear(p, r, buildings) && TownLandmarks.Clear(p, r, clearings!)
- && TownLandmarks.Clear(p, r, farms)
+ return TownLandmarks.Clear(p, r, taken) && TownLandmarks.Clear(p, r, buildings) && ClearOfBoxes(p, r, blocks!)
+ && TownLandmarks.Clear(p, r, clearings!) && TownLandmarks.Clear(p, r, farms)
&& ground.Inside(p.x - r, p.y - r) && ground.Inside(p.x + r, p.y + r)
&& !ground.Water(p.x, p.y) && !ground.OnRoute(p, r) && !ground.OnToken(p, r, date);
}
+ // #2876 (the owner, 7 November 2026, on Hadera: "Move the workshop (Recommended)": it moves to a clear spot at the
+ // town's edge, and the palms stay): an ordinary town's b21 whose hex spot is on the beach (OffBeach, as EdgeSpot's)
+ // stands at the town's edge instead, where it can with no kit tree in front of it (VegetationLayer.ClearInFront).
+ var veg = map.GetComponentInChildren<Kits.VegetationLayer>(true);
+ float sightTan = SightTan;
+ bool ClearOfTrees(Vector2 p, float r) => veg == null || veg.ClearInFront(p, r, ground.Y(p.x, p.y), sightTan);
+ List<(Vector2 centre, float reach)>? sand = null;
+ bool OffTheBeach(Vector2 p, float r)
+ {
+ sand ??= Kits.BeachBands.Reaches(map.Settlements.Concat(map.Localities.Select(l => l.Settlement)).ToList(), ground);
+ return OffBeach(map, ground, sand, p, r);
+ }
var plan = new List<(Want, Vector2)>();
var kits = map.transform.Find(Kits.KitLayer.RootName);
foreach (var w in wants)
@@ -704,25 +750,105 @@ namespace Statecraft.Game.Map.Collection
if (log && available(w.Model)) Debug.LogWarning($"BUILDINGS: no clear {(w.Site == Siting.Shore ? "beach" : "roadside")} spot for {w.Key}; its {w.Model} is not drawn.");
continue;
}
- if (at == null && w.Model == Workshop)
+ if (at == null && w.Model == Workshop && Kits.TownModels.IsMajorCity(w.City)
+ && map.KitFootprints.Any(f => f.id == w.City) && map.MajorCityBlocks.Any(b => b.Id == w.City))
+ {
+ // #2876, the owner, 6 November 2026 (verbatim): "make the workshop at the edge of the city". In a major city
+ // (its kit blocks drawn from 40 km out, its building models below: the owner, 7 November 2026, "Tal's models
+ // close (Recommended)") the b21 stands at the edge of the city's blocks, clear of every model instance, on the project's hex
+ // where it can, in the camera's sight (EdgeSpot), on ground the player's side holds (OnHeldGround), clear of
+ // the farm scenes, the other models, the routes and the tokens and figures, each of the day it was built (as
+ // below: the spot is fixed at the build and kept as the front moves). No spot: it is not drawn, and the
+ // warning names the city.
+ var built = w.From; var home = ground.Hex(anchor.x, anchor.y);
+ at = EdgeSpot(map, ground, w.City, w.Key, anchor, clearance, SizeOf(w), new[]
+ {
+ new SpotCheck("held", (p, r) => OnHeldGround(map, ground, p, r, built, home)),
+ new SpotCheck("farms", (p, r) => TownLandmarks.Clear(p, r, farms)),
+ new SpotCheck("taken", (p, r) => TownLandmarks.Clear(p, r, taken)),
+ new SpotCheck("routes", (p, r) => !ground.OnRoute(p, r)),
+ new SpotCheck("tokens", (p, r) => !ground.OnToken(p, r, built)),
+ new SpotCheck("figures", (p, r) => ClearOfFigures(map, p, r, built)),
+ }, out var tally);
+ if (at == null)
+ {
+ if (log && available(w.Model))
+ Debug.LogWarning($"BUILDINGS: no spot at the edge of {w.City} passes every test for {w.Key} ({tally}); its {w.Model} is not drawn.");
+ continue;
+ }
+ }
+ else if (at == null && w.Model == Workshop)
{
// On the project's own hex (its centre is the anchor), clear of the farm scenes, and as far out of a town's
// footprint as the civilian figures keep from its label (CivilianPeople.LabelClearanceM). The units' tokens and
// figures are those of the map's planned unit spots (MapScene.UnitClearings and UnitTokens, built with the map
// from units_1948, not the units' live places) on the day the workshop was built (w.From), so its spot does not
// move as the game's date passes a token's last day (review of #2281, S2).
- var built = w.From;
+ var built = w.From; var home = ground.Hex(anchor.x, anchor.y);
+ // #2876: clear of the major cities' kit blocks too, which reach past their footprints (out to
+ // SettlementKits.PlotReach of the radius), so a spot just outside one keeps off its outer blocks.
+ var hexBlocks = MajorCityBlocksNear(map, anchor);
+ // #2876: on a hex those blocks reach, also where the camera sees the b21's top past them (InSight: the blocks
+ // stand up to about 1.6 km at 60x, the b21's top about 400 m, at 24x times WorkshopScale). Every other hex: no test (sight stays null).
+ float side = SizeOf(w), tan = SightTan;
+ var sight = hexBlocks.Count == 0 ? null : MajorCitySightBlocks(map, ground, anchor, tan);
+ bool Seen(Vector2 p, float yawDeg) => sight == null || InSight(p, yawDeg, side, ground.Y(p.x, p.y) + WorkshopTopShare * side, sight, tan);
bool OnHex(Vector2 p, float r) => (p - anchor).magnitude + r <= HexInnerRadiusM && TownLandmarks.Clear(p, r, farms)
- && ClearOfFigures(map, p, r, built) && FreeOn(p, r, built);
+ && ClearOfBoxes(p, r, hexBlocks) && ClearOfFigures(map, p, r, built) && FreeOn(p, r, built) && Seen(p, 0f)
+ && OnHeldGround(map, ground, p, r, built, home);
float inside = Inside(anchor, footprints);
at = SeededSpot(w.Key, anchor, clearance, OnHex, inside > 0f ? inside + CivilianPeople.LabelClearanceM : 0f);
+ // #2876 (the owner, 7 November 2026, on Hadera: "Move the workshop (Recommended)": the b21 moves to a clear spot
+ // at the town's edge; the palms stay): a spot on the hex that is on the beach (OffBeach, as EdgeSpot's) is no
+ // spot, so the b21 stands at the town's edge (below).
+ if (at is Vector2 onHex && !OffTheBeach(onHex, clearance)) at = null;
// A town whose footprint covers the whole hex (Jerusalem, Tel Aviv): a gap between its drawn buildings (owner,
- // 2 November 2026: "Among the houses").
- if (at == null && inside > 0f) at = TownGap(map, w.Key, anchor, clearance, (p, r) =>
+ // 2 November 2026: "Among the houses"), or, between a major city's kit blocks, a street (#2876): the model then
+ // lies along it (dir), as a roadside model along its road.
+ if (at == null && inside > 0f) at = TownGap(map, w.Key, anchor, clearance, side, (p, r) =>
(p - anchor).magnitude + r <= HexInnerRadiusM && TownLandmarks.Clear(p, r, farms) && TownLandmarks.Clear(p, r, taken)
&& ClearOfFigures(map, p, r, built)
&& ground.Inside(p.x - r, p.y - r) && ground.Inside(p.x + r, p.y + r)
- && !ground.Water(p.x, p.y) && !ground.OnRoute(p, r) && !ground.OnToken(p, r, built));
+ && !ground.Water(p.x, p.y) && !ground.OnRoute(p, r) && !ground.OnToken(p, r, built)
+ && OnHeldGround(map, ground, p, r, built, home), Seen, out dir);
+ // #2876 (coordinator, 6 November 2026): at 2.5x a crowded town's hex can leave no spot (Petah Tikva's, by
+ // Tel Aviv's): only then, the b21 stands at the edge of the town's drawn buildings (TownEdgeSpot), as a
+ // major city's does at its blocks, on ground held the day it was built, in the camera's sight, clear of
+ // the names, blocks, landmarks, houses, beach, farms, models, routes, tokens and figures. It looks first
+ // for a spot with no kit tree in front of it (VegetationLayer.ClearInFront: the palms stay, owner, 7 November
+ // 2026, "Move the workshop (Recommended)"), then without that test. A spot found above is never searched
+ // again, so it stays where it was. No edge spot either: not drawn, and the warning names the town.
+ if (at == null && TownEdgeFallback && map.KitFootprints.Any(f => f.id == w.City))
+ {
+ var checks = new List<SpotCheck>
+ {
+ new SpotCheck("held", (p, r) => OnHeldGround(map, ground, p, r, built, home)),
+ new SpotCheck("farms", (p, r) => TownLandmarks.Clear(p, r, farms)),
+ new SpotCheck("taken", (p, r) => TownLandmarks.Clear(p, r, taken)),
+ new SpotCheck("routes", (p, r) => !ground.OnRoute(p, r)),
+ new SpotCheck("tokens", (p, r) => !ground.OnToken(p, r, built)),
+ new SpotCheck("figures", (p, r) => ClearOfFigures(map, p, r, built)),
+ };
+ at = TownEdgeSpot(map, ground, w.City, w.Key, anchor, clearance, side,
+ checks.Append(new SpotCheck("trees", ClearOfTrees)).ToList(), out _);
+ string tally = "";
+ if (at == null) at = TownEdgeSpot(map, ground, w.City, w.Key, anchor, clearance, side, checks, out tally);
+ if (at == null)
+ {
+ if (log && available(w.Model))
+ Debug.LogWarning($"BUILDINGS: no spot on the hex of {w.Key} passes every test, nor at the edge of {w.City} ({tally}); its {w.Model} is not drawn.");
+ continue;
+ }
+ if (available(w.Model)) edged.Add(w.Key);
+ }
+ // #2876 (coordinator, 6 November 2026: no quiet fallback to a hidden spot): where no spot on the hex passes
+ // every test, the camera's sight included, the b21 is not drawn, and the warning names the cities.
+ if (at == null && sight != null)
+ {
+ if (log && available(w.Model))
+ Debug.LogWarning($"BUILDINGS: no spot on the hex of {w.Key} passes every test, the camera's sight past the kit blocks of {string.Join(", ", sight.Select(b => b.Id).Distinct())} included; its {w.Model} is not drawn.");
+ continue;
+ }
}
else if (at == null)
{
@@ -790,6 +916,29 @@ namespace Statecraft.Game.Map.Collection
return true;
}
+ /// <summary>#2876 (coordinator, 6 November 2026: the Jerusalem b21 stood on the other side's ground): whether a disc of
+ /// <paramref name="r"/> at <paramref name="p"/> stands on ground the player's side holds on <paramref name="on"/>, as the
+ /// map draws it: its centre and 8 points round it each on <paramref name="home"/>, the project's own hex (a player city:
+ /// the sim builds there only for the player, and the wash's live overlay, MapRegions.LayerOn, paints a settlement the
+ /// player holds as the player's), or on a hex the control wash (MapScene.Control, control_hexes_1948_49.yaml, the
+ /// layer GameRoot draws through MapRegions) gives the Israeli side that day. The other side, contested ground, no-man's
+ /// land, a demilitarized zone, no colour and off the data are not held. A workshop reads it on the day it was built
+ /// (Want.From), so its spot stays as the front moves. A map without control data draws no wash: every disc passes.</summary>
+ internal static bool OnHeldGround(MapScene map, Kits.KitGround ground, Vector2 p, float r, DateTime on, (int, int) home)
+ {
+ var control = map.Control;
+ if (control == null) return true;
+ for (int i = 0; i < 9; i++)
+ {
+ float a = i * Mathf.PI / 4f;
+ var s = i == 8 ? p : p + r * new Vector2(Mathf.Cos(a), Mathf.Sin(a));
+ var hex = ground.Hex(s.x, s.y);
+ if (hex == home) continue;
+ if (control.At(hex.Item1, hex.Item2, on).side != Control1948.Side.Israel) return false;
+ }
+ return true;
+ }
+
/// <summary>Whether a disc of <paramref name="r"/> at <paramref name="p"/> is on the ground the figures of a unit spot at
/// <paramref name="c"/> (its disc <paramref name="radius"/>) hide: within the disc either side, from its south edge to
/// <see cref="FigureShadowM"/> past its north edge.</summary>
@@ -810,25 +959,28 @@ namespace Statecraft.Game.Map.Collection
/// <summary>Review of #2281: what else the kits drew on the hex about <paramref name="anchor"/>, which no house stands on by
/// design: the walls, platforms, landmarks, harbour works and street palms the kits placed and each landmark's close copy
/// (KitLayer.Stats.Landmarks), and the replaceable landmark parts' close boxes (KitLayer.Stats.LandmarkParts, #2266). All
- /// planned at map build.</summary>
- internal static List<(Vector2 c, float yaw, float w, float d)> TownLandmarkBoxes(MapScene map, Vector2 anchor)
+ /// planned at map build. Those within <paramref name="extent"/> of <paramref name="anchor"/> (the hex's inner radius, or
+ /// the ground a search covers, #2876) plus half their width and depth.</summary>
+ internal static List<(Vector2 c, float yaw, float w, float d)> TownLandmarkBoxes(MapScene map, Vector2 anchor, float extent = HexInnerRadiusM)
{
var boxes = new List<(Vector2 c, float yaw, float w, float d)>();
var stats = map.KitStats;
if (stats == null) return boxes;
foreach (var p in stats.Landmarks)
- if ((p.C - anchor).magnitude <= HexInnerRadiusM + 0.5f * (p.W + p.D)) boxes.Add((p.C, p.Yaw, p.W, p.D));
+ if ((p.C - anchor).magnitude <= extent + 0.5f * (p.W + p.D)) boxes.Add((p.C, p.Yaw, p.W, p.D));
foreach (var part in stats.LandmarkParts)
{
var c = new Vector2(part.Near.center.x, part.Near.center.z);
- if ((c - anchor).magnitude <= HexInnerRadiusM + 0.5f * (part.Near.size.x + part.Near.size.z)) boxes.Add((c, 0f, part.Near.size.x, part.Near.size.z));
+ if ((c - anchor).magnitude <= extent + 0.5f * (part.Near.size.x + part.Near.size.z)) boxes.Add((c, 0f, part.Near.size.x, part.Near.size.z));
}
return boxes;
}
/// <summary>The drawn buildings on the hex about <paramref name="anchor"/>: each town model instance the kit planned at
/// map build (TownModelLayer.InstancesOf; never what has streamed) for every footprint that reaches the hex, as a disc of
- /// its half diagonal; <paramref name="names"/>: those footprints (their names stand above them).</summary>
+ /// its half diagonal, a major city's (TownModels.IsMajorCity) included: it draws them below the close switch (the owner,
+ /// 7 November 2026, "Tal's models close (Recommended)") and its kit blocks from 40 km out (#2876:
+ /// <see cref="MajorCityBlocksNear"/>); <paramref name="names"/>: those footprints (their names stand above them).</summary>
internal static List<(Vector2 centre, float radius)> TownBuildings(MapScene map, Vector2 anchor, out List<(Vector2 centre, float radius)> names)
{
var discs = new List<(Vector2 centre, float radius)>(); names = new List<(Vector2 centre, float radius)>();
@@ -843,37 +995,473 @@ namespace Statecraft.Game.Map.Collection
return discs;
}
+ /// <summary>#2876: the major cities' kit blocks (MapScene.MajorCityBlocks: every "building" and "wing" their kits placed,
+ /// drawn from 40 km out) that may reach the hex about <paramref name="anchor"/>, as boxes (their yaw as KitMesh.Corners),
+ /// in placement order. A block's reach is taken as half its width plus half its depth (no less than its half diagonal).
+ /// <paramref name="extent"/>: the hex's inner radius, or the ground a search covers about <paramref name="anchor"/> (#2876).</summary>
+ internal static List<(Vector2 c, float yaw, float w, float d)> MajorCityBlocksNear(MapScene map, Vector2 anchor, float extent = HexInnerRadiusM)
+ {
+ var boxes = new List<(Vector2 c, float yaw, float w, float d)>();
+ foreach (var b in map.MajorCityBlocks)
+ if ((b.C - anchor).magnitude <= extent + 0.5f * (b.W + b.D)) boxes.Add((b.C, b.Yaw, b.W, b.D));
+ return boxes;
+ }
+
+ /// <summary>Whether a disc of <paramref name="r"/> at <paramref name="p"/> keeps clear of every box of
+ /// <paramref name="boxes"/> (<see cref="ClearOfBox"/>; a box whose centre is past r plus half its width and half its depth
+ /// cannot reach it and is skipped).</summary>
+ internal static bool ClearOfBoxes(Vector2 p, float r, List<(Vector2 c, float yaw, float w, float d)> boxes)
+ {
+ foreach (var (c, yaw, w, d) in boxes)
+ {
+ float reach = r + 0.5f * (w + d);
+ if ((p - c).sqrMagnitude > reach * reach) continue;
+ if (!ClearOfBox(p, r, c, yaw, w, d)) return false;
+ }
+ return true;
+ }
+
+ /// <summary>#2876: the tangent of the view's shallowest ray. CameraRig turns the camera Euler(Pitch, Yaw, 0) at every zoom
+ /// (CameraRig.Apply; no pitch curve), so on the screen's centre column a point on its centre row is seen at Pitch below
+ /// the horizon and one at its top edge at Pitch - Fov / 2, 32.5 degrees, the lowest (as <see cref="FigureShadowM"/>).
+ /// The top bar's inset (CameraRig.TopInset) only lowers the map area's top edge, so it never looks lower. Toward the
+ /// screen's top corners a ray looks lower still and turns off north; that is not modelled.</summary>
+ public static float SightTan => Mathf.Tan((CameraRig.Pitch - 0.5f * CameraRig.Fov) * Mathf.Deg2Rad);
+
+ /// <summary>#2876: the b21's top over its ground, as a share of its <see cref="SizeOf(Want)"/>. Its FBX's vertex extents are
+ /// 0.959 by 0.999 across and 0.549 high (b21-artisan-workshop-v2.fbx, read 6 November 2026) and Rebuild scales its wider
+ /// side to SizeOf, so its top is 0.55 of it; taken a little low, as a lower top hides behind more.</summary>
+ public const float WorkshopTopShare = 0.5f;
+
+ /// <summary>#2876: how far above its census wall height (Placed.H) a major city's block reaches (m). Tel Aviv's blocks
+ /// (SettlementKits.TelAvivBlock, its only lattice) at most a stair head, 2.8 real m over the wall top, and its water
+ /// tank, 1.6 real m on that, at KitScale.CityBlocks. Another major city's buildings are white, stone and old blocks and
+ /// houses at either scale (the most over a flat roof the same 4.4 real m) and Haifa's Templer houses, whose gable rises
+ /// 0.55 of the house's narrower side (SettlementKits.ModelHeight's Templer).</summary>
+ internal static float RoofRiseOf(string id, float w, float d) => id == "tel_aviv" ? 4.4f * Kits.KitScale.CityBlocks
+ : Mathf.Max(4.4f * Mathf.Max(Kits.KitScale.CityBlocks, Kits.KitScale.Houses), 0.55f * Mathf.Min(w, d));
+
+ /// <summary>#2876: a major city's kit block as <see cref="InSight"/> reads it: its box (as KitMesh.Corners) and its top,
+ /// world y.</summary>
+ internal readonly struct SightBlock
+ {
+ public readonly string Id; public readonly Vector2 C; public readonly float Yaw, W, D, Top;
+ public SightBlock(string id, Vector2 c, float yaw, float w, float d, float top) { Id = id; C = c; Yaw = yaw; W = w; D = d; Top = top; }
+ }
+
+ /// <summary>#2876: the major cities' kit blocks (MapScene.MajorCityBlocks) that may hide a model on the hex about
+ /// <paramref name="anchor"/> from the camera, in placement order. A block's top is the ground it stands on (the highest
+ /// of its corners and centre, as SettlementKits.GroundSpan stands it) plus its wall height and <see cref="RoofRiseOf"/>.
+ /// It can hide ground as far as its top over y = 0 (the terrain's lowest point: CameraController.MinClearanceShare)
+ /// over <paramref name="tanPitch"/> north of it. <paramref name="extent"/>: the hex's inner radius, or the ground a search
+ /// covers about <paramref name="anchor"/> (#2876).</summary>
+ internal static List<SightBlock> MajorCitySightBlocks(MapScene map, Kits.KitGround ground, Vector2 anchor, float tanPitch, float extent = HexInnerRadiusM)
+ {
+ var list = new List<SightBlock>();
+ foreach (var b in map.MajorCityBlocks)
+ {
+ float a = b.Yaw * Mathf.Deg2Rad, ca = Mathf.Cos(a), sa = Mathf.Sin(a), hi = float.MinValue;
+ for (int i = 0; i < 5; i++)
+ {
+ float u = i == 4 ? 0f : ((i & 1) == 0 ? -0.5f : 0.5f) * b.W, v = i == 4 ? 0f : ((i & 2) == 0 ? -0.5f : 0.5f) * b.D;
+ hi = Mathf.Max(hi, ground.Y(b.C.x + u * ca - v * sa, b.C.y + u * sa + v * ca));
+ }
+ float top = hi + b.H + RoofRiseOf(b.Id, b.W, b.D);
+ float reach = extent + 0.5f * (b.W + b.D) + Mathf.Max(0f, top) / tanPitch;
+ if ((b.C - anchor).sqrMagnitude <= reach * reach) list.Add(new SightBlock(b.Id, b.C, b.Yaw, b.W, b.D, top));
+ }
+ return list;
+ }
+
+ /// <summary>#2876 (coordinator, 6 November 2026: the b21 must be visible among the major cities' tall blocks): whether
+ /// the camera sees the whole top of a model at <paramref name="p"/>, its ground a square <paramref name="size"/> a side
+ /// turned <paramref name="yawDeg"/> (as KitMesh.Corners), its top at world y <paramref name="topY"/>, past every block of
+ /// <paramref name="blocks"/>. The camera looks north (CameraRig yaw 0: fixed north under gdd-0.3, the only ruleset with
+ /// workshops, CameraHeadingPolicy.IsFixedNorth), so it stands south of the model (x east, z north) and a ray from the
+ /// top toward it runs south (-z), rising <paramref name="tanPitch"/> a metre. A block whose top is
+ /// <c>rise</c> above the model's hides it when its box meets the square swept <c>rise / tanPitch</c> south: the hull of
+ /// the square and its copy that far south, tested against the box on their side axes and the sweep's own (x), with
+ /// touching as apart (as <see cref="BoxesClear"/>). A block no higher than the top hides nothing.</summary>
+ internal static bool InSight(Vector2 p, float yawDeg, float size, float topY, List<SightBlock> blocks, float tanPitch)
+ {
+ float a = yawDeg * Mathf.Deg2Rad, half = 0.5f * size;
+ var u = new Vector2(Mathf.Cos(a), Mathf.Sin(a)); var v = new Vector2(-u.y, u.x);
+ float ex = half * (Mathf.Abs(u.x) + Mathf.Abs(v.x)), ez = half * (Mathf.Abs(u.y) + Mathf.Abs(v.y));
+ foreach (var b in blocks)
+ {
+ float rise = b.Top - topY;
+ if (rise <= 0f) continue;
+ float run = rise / tanPitch, reach = 0.5f * (b.W + b.D);
+ // Its box's bounds (within reach of its centre) against the swept square's: apart, it cannot hide the model.
+ if (b.C.x - reach >= p.x + ex || b.C.x + reach <= p.x - ex || b.C.y - reach >= p.y + ez || b.C.y + reach <= p.y - ez - run) continue;
+ float ba = b.Yaw * Mathf.Deg2Rad;
+ var bu = new Vector2(Mathf.Cos(ba), Mathf.Sin(ba)); var bv = new Vector2(-bu.y, bu.x);
+ var t = b.C - p;
+ bool Apart(Vector2 n)
+ {
+ float r1 = half * (Mathf.Abs(Vector2.Dot(u, n)) + Mathf.Abs(Vector2.Dot(v, n)));
+ float back = -run * n.y; // the swept copy's centre, projected (the model's centre projects to 0)
+ float lo = Mathf.Min(0f, back) - r1, hi = Mathf.Max(0f, back) + r1;
+ float cb = Vector2.Dot(t, n), rb = 0.5f * b.W * Mathf.Abs(Vector2.Dot(bu, n)) + 0.5f * b.D * Mathf.Abs(Vector2.Dot(bv, n));
+ return hi <= cb - rb || lo >= cb + rb;
+ }
+ if (!(Apart(u) || Apart(v) || Apart(Vector2.right) || Apart(bu) || Apart(bv))) return false;
+ }
+ return true;
+ }
+
+ /// <summary>Whether two boxes, each centred at c, turned yaw degrees anticlockwise in x-z (KitMesh.Corners), w along its
+ /// turn and d across, are apart (touching counts as apart): one of their four side axes separates them.</summary>
+ public static bool BoxesClear(Vector2 c1, float yaw1, float w1, float d1, Vector2 c2, float yaw2, float w2, float d2)
+ {
+ float a1 = yaw1 * Mathf.Deg2Rad, a2 = yaw2 * Mathf.Deg2Rad;
+ var u1 = new Vector2(Mathf.Cos(a1), Mathf.Sin(a1)); var v1 = new Vector2(-u1.y, u1.x);
+ var u2 = new Vector2(Mathf.Cos(a2), Mathf.Sin(a2)); var v2 = new Vector2(-u2.y, u2.x);
+ var t = c2 - c1;
+ bool Apart(Vector2 n) => Mathf.Abs(Vector2.Dot(t, n)) >= 0.5f * w1 * Mathf.Abs(Vector2.Dot(u1, n)) + 0.5f * d1 * Mathf.Abs(Vector2.Dot(v1, n))
+ + 0.5f * w2 * Mathf.Abs(Vector2.Dot(u2, n)) + 0.5f * d2 * Mathf.Abs(Vector2.Dot(v2, n));
+ return Apart(u1) || Apart(v1) || Apart(u2) || Apart(v2);
+ }
+
+ /// <summary>DESIGN VALUES (#2876; the owner, 6 November 2026, verbatim: "make the workshop at the edge of the city"): how far
+ /// past the outermost kit block on its bearing a major city's b21 may stand (m, from the block's face to the b21's
+ /// clearance disc; about one plot of the major cities' kit lattices, which are 0.8 to 1.6 km a side at 60x), and how many
+ /// compass bearings round the city's centre its edge is walked on (3.75 degrees apart: about 460 m at Tel Aviv's 7 km
+ /// edge, under half the b21's disc, about 1.02 km wide at WorkshopScale 2.5; 410 m before it, #2876).</summary>
+ public const float EdgeGapM = 1000f;
+ public const int EdgeBearings = 96;
+
+ /// <summary>One named test of a candidate spot, given the spot and the clearance (<see cref="EdgeSpot"/> counts each).</summary>
+ internal readonly struct SpotCheck
+ {
+ public readonly string Name; public readonly Func<Vector2, float, bool> Test;
+ public SpotCheck(string name, Func<Vector2, float, bool> test) { Name = name; Test = test; }
+ }
+
+ /// <summary>#2876 (the owner, 6 November 2026, verbatim: "make the workshop at the edge of the city"): a spot for a b21 of
+ /// clearance <paramref name="clearance"/> (its square <paramref name="size"/> a side, drawn at yaw 0) at the edge of the
+ /// major city <paramref name="city"/>'s kit blocks (MapScene.MajorCityBlocks), or null, with <paramref name="tally"/>
+ /// saying how many points each test turned away first.
+ /// The points, a fixed walk: <see cref="EdgeBearings"/> compass bearings from the city's footprint centre, due south first
+ /// (the camera's side: it looks north under gdd-0.3, CameraHeadingPolicy, so the city's blocks stand behind a b21 south of
+ /// them, not between it and the camera), then 3.75 degrees either side of south in turn (east or west first by the parity
+ /// of the key's FNV-1a hash), out to due north last. On each bearing, the edge is the farthest reach along it of the
+ /// city's blocks in the band the disc sweeps (its clearance either side of the ray); the points stand from just past it
+ /// (the disc touching that face) out to <see cref="EdgeGapM"/> past it, every half clearance, nearest first. A bearing
+ /// with no block of the city in its band has no points.
+ /// Two passes over the points: first only those whose disc is wholly on the project's hex (about
+ /// <paramref name="anchor"/>, as every other workshop stands), then any (the edge of Tel Aviv and Jerusalem lies off
+ /// their hexes: their footprints cover them). A point passes, in this order: on the map and dry; within EdgeGapM plus
+ /// its clearance of a block of the city, and nearer the city's blocks than any other major city's (box distance); on the
+ /// city's ground (deeper in its footprint, distance over radius, than in any
+ /// other place's, the kits' partition, SettlementKits.OwnsFootprint; and clear of every other place's plot reach,
+ /// SettlementKits.PlotReach of its radius, where that place's buildings stand), so it reads as that city's; clear of
+ /// every place's name pill (<see cref="ClearOfName"/>), of every major city's kit block and of the kits' landmarks
+ /// (<see cref="TownLandmarkBoxes"/>); off the beach (no open sea, KitGround.SeaDistance, within the drawn full sand,
+ /// BeachBands.FullSandAt, plus its clearance); <paramref name="free"/> (the plan's held ground, farms, models, routes,
+ /// tokens and figures); and in the camera's sight past every major city's blocks (<see cref="InSight"/>). The points and
+ /// the tests read only the map, the key and the caller's lists, so the spot is the same whenever the plan is made.</summary>
+ internal static Vector2? EdgeSpot(MapScene map, Kits.KitGround ground, string city, string key, Vector2 anchor, float clearance, float size,
+ IReadOnlyList<SpotCheck> free, out string tally)
+ {
+ var blocks = new List<(Vector2 c, float yaw, float w, float d)>();
+ foreach (var b in map.MajorCityBlocks) if (b.Id == city) blocks.Add((b.C, b.Yaw, b.W, b.D));
+ // The owner, 7 November 2026, "Tal's models close (Recommended)": below the close switch the city draws Tal
+ // Heuberger's building models in place of its blocks, so the b21 keeps clear of them too (every place's, each a
+ // disc of its half diagonal, as TownBuildings), on both sides of the switch.
+ var home = map.KitFootprints.First(f => f.id == city);
+ float extent = home.radius * Kits.SettlementKits.PlotReach + EdgeGapM + 3f * clearance;
+ // In the camera's sight past them too, as past the kit blocks (InSight; each model its fitted box up to Ground + H,
+ // SettlementKits.ModelInstance).
+ var models = new List<(Vector2 centre, float radius)>();
+ var modelSight = new List<SightBlock>();
+ var layer = map.GetComponentInChildren<Kits.TownModelLayer>(true);
+ if (layer != null)
+ foreach (var f in map.KitFootprints)
+ {
+ if ((f.centre - home.centre).magnitude > extent + f.radius * Kits.SettlementKits.PlotReach) continue;
+ foreach (var b in layer.InstancesOf(f.id))
+ {
+ models.Add((b.C, 0.5f * Mathf.Sqrt(b.W * b.W + b.D * b.D)));
+ modelSight.Add(new SightBlock(f.id, b.C, b.Yaw, b.W, b.D, b.Ground + b.H));
+ }
+ }
+ float tan = SightTan;
+ return EdgeSpotOf(map, ground, city, key, anchor, clearance, size, blocks, 0f, "its kit blocks", new[]
+ {
+ new SpotCheck("models", (p, r) => TownLandmarks.Clear(p, r, models)),
+ new SpotCheck("model sight", (p, r) => InSight(p, 0f, size, ground.Y(p.x, p.y) + WorkshopTopShare * size, modelSight, tan)),
+ }, free, out tally);
+ }
+
+ /// <summary>#2876 (coordinator, 6 November 2026: at 2.5x a crowded town's own hex can leave the b21 no spot, Petah
+ /// Tikva's, and it is then not drawn): the spot of last resort for a town that is not a major city, when the searches
+ /// on its hex (<see cref="SeededSpot"/>, then <see cref="TownGap"/>) find none: <see cref="EdgeSpot"/>'s walk and tests
+ /// round the edge of what the town draws. That edge is its building models as the kit placed them at map build
+ /// (TownModelLayer.InstancesOf, never what has streamed, each as its fitted box, SettlementKits.ModelInstance.Corners):
+ /// the towns a player builds in draw them up close, where the b21 is drawn (and their far-off copies beyond, #2378), so
+ /// the outermost of them is the town's edge as the player sees it. A town with none (its kit drawn at every zoom: no
+ /// model list) takes the reach of its kit's plots, its footprint radius times SettlementKits.PlotReach, past which no
+ /// kit building stands. The "near" bound (<see cref="EdgeGapM"/>) is from that edge. Every other test is EdgeSpot's
+ /// (the town's ground and name pill, every major city's blocks and sight, the landmarks, the beach and
+ /// <paramref name="free"/>), and a spot also keeps clear of every town's drawn building models (each a disc of its half
+ /// diagonal, as <see cref="TownBuildings"/>).</summary>
+ internal static Vector2? TownEdgeSpot(MapScene map, Kits.KitGround ground, string town, string key, Vector2 anchor, float clearance, float size,
+ IReadOnlyList<SpotCheck> free, out string tally)
+ {
+ var home = map.KitFootprints.First(f => f.id == town);
+ var layer = map.GetComponentInChildren<Kits.TownModelLayer>(true);
+ var blocks = new List<(Vector2 c, float yaw, float w, float d)>();
+ if (layer != null) foreach (var b in layer.InstancesOf(town)) blocks.Add((b.C, b.Yaw, b.W, b.D));
+ float disc = blocks.Count == 0 ? home.radius * Kits.SettlementKits.PlotReach : 0f;
+ // Every town's drawn building models that a point's disc can meet: within the farthest a point stands from the
+ // town's centre (the edge, EdgeGapM and the clearance past it) plus the clearance and the model's half diagonal.
+ float edge = disc;
+ foreach (var (bc, _, bw, bd) in blocks) edge = Mathf.Max(edge, (bc - home.centre).magnitude + 0.5f * (bw + bd));
+ float extent = edge + EdgeGapM + 2f * clearance;
+ var houses = new List<(Vector2 centre, float radius)>();
+ if (layer != null)
+ foreach (var f in map.KitFootprints)
+ {
+ // A major city's too: it draws them below the close switch ("Tal's models close (Recommended)").
+ if ((f.centre - home.centre).magnitude > extent + f.radius * Kits.SettlementKits.PlotReach) continue;
+ foreach (var b in layer.InstancesOf(f.id))
+ {
+ float half = 0.5f * Mathf.Sqrt(b.W * b.W + b.D * b.D);
+ if ((b.C - home.centre).magnitude <= extent + half) houses.Add((b.C, half));
+ }
+ }
+ return EdgeSpotOf(map, ground, town, key, anchor, clearance, size, blocks, disc,
+ blocks.Count > 0 ? "its building models" : "its kit's plot reach",
+ new[] { new SpotCheck("houses", (p, r) => TownLandmarks.Clear(p, r, houses)) }, free, out tally);
+ }
+
+ /// <summary><see cref="EdgeSpot"/>'s walk and tests round the edge of place <paramref name="city"/>: its drawn
+ /// <paramref name="edgeBlocks"/> (centre, yaw as KitMesh.Corners, width, depth), or, with none, a disc of
+ /// <paramref name="disc"/> m about its footprint's centre; <paramref name="edgeName"/> names that edge in the tally, and
+ /// <paramref name="extra"/> are tests run after the kits' landmarks (none for a major city).</summary>
+ static Vector2? EdgeSpotOf(MapScene map, Kits.KitGround ground, string city, string key, Vector2 anchor, float clearance, float size,
+ List<(Vector2 c, float yaw, float w, float d)> edgeBlocks, float disc, string edgeName, IReadOnlyList<SpotCheck> extra,
+ IReadOnlyList<SpotCheck> free, out string tally)
+ {
+ var home = map.KitFootprints.First(f => f.id == city);
+ Vector2 c = home.centre;
+ // The place's blocks: each one's centre from its centre, its sides' directions (as KitMesh.Corners) and half sides.
+ var own = new List<(Vector2 q, Vector2 u, Vector2 v, float hw, float hd)>();
+ foreach (var b in edgeBlocks)
+ {
+ float a = b.yaw * Mathf.Deg2Rad; var bu = new Vector2(Mathf.Cos(a), Mathf.Sin(a));
+ own.Add((b.c - c, bu, new Vector2(-bu.y, bu.x), 0.5f * b.w, 0.5f * b.d));
+ }
+ // Every other major city's blocks, the same way (from the city's centre too).
+ var others = new List<(Vector2 q, Vector2 u, Vector2 v, float hw, float hd)>();
+ foreach (var b in map.MajorCityBlocks)
+ {
+ if (b.Id == city) continue;
+ float a = b.Yaw * Mathf.Deg2Rad; var bu = new Vector2(Mathf.Cos(a), Mathf.Sin(a));
+ others.Add((b.C - c, bu, new Vector2(-bu.y, bu.x), 0.5f * b.W, 0.5f * b.D));
+ }
+ uint h = 2166136261;
+ foreach (char ch in key) { h ^= ch; h *= 16777619; }
+ int first = (h & 1u) == 0u ? 1 : -1;
+ float step = 0.5f * clearance; int steps = Mathf.FloorToInt(EdgeGapM / step);
+ var points = new List<Vector2>();
+ for (int i = 0; i < EdgeBearings; i++)
+ {
+ int k = (i + 1) / 2 * (i % 2 == 1 ? first : -first); // 0, +1, -1, +2, -2 ... (in degrees, k x 3.75), 48 last
+ float bearing = (180f + k * (360f / EdgeBearings)) * Mathf.Deg2Rad;
+ var dir = new Vector2(Mathf.Sin(bearing), Mathf.Cos(bearing)); var across = new Vector2(-dir.y, dir.x);
+ float edge = float.NegativeInfinity;
+ foreach (var (q, u, v, hw, hd) in own)
+ {
+ float along = hw * Mathf.Abs(Vector2.Dot(u, dir)) + hd * Mathf.Abs(Vector2.Dot(v, dir));
+ float wide = hw * Mathf.Abs(Vector2.Dot(u, across)) + hd * Mathf.Abs(Vector2.Dot(v, across));
+ float reach = Vector2.Dot(q, dir) + along;
+ if (reach > 0f && Mathf.Abs(Vector2.Dot(q, across)) - wide < clearance) edge = Mathf.Max(edge, reach);
+ }
+ if (own.Count == 0 && disc > 0f) edge = disc; // no blocks: the disc's edge, on every bearing
+ if (float.IsNegativeInfinity(edge)) continue;
+ for (int j = 0; j <= steps; j++) points.Add(c + dir * (edge + clearance + j * step));
+ }
+ // The ground the points' discs cover about the city's centre, and what stands there.
+ float extent = 0f;
+ foreach (var p in points) extent = Mathf.Max(extent, (p - c).magnitude);
+ extent += clearance;
+ var blocks = MajorCityBlocksNear(map, c, extent);
+ var landmarks = TownLandmarkBoxes(map, c, extent);
+ float tan = SightTan;
+ var sight = MajorCitySightBlocks(map, ground, c, tan, extent);
+ // The places that can matter to a point: a footprint deeper in at one (it is then within extent times its radius
+ // over the city's), a name pill over one, or a plot reach under one.
+ var places = new List<(Vector2 centre, float radius, string id)>();
+ foreach (var f in map.KitFootprints)
+ {
+ if (f.id == city) continue;
+ float matters = Mathf.Max(extent * f.radius / home.radius, TownLabelHalfWidthM + TownLabelHeightM + f.radius + 2f * clearance,
+ f.radius * Kits.SettlementKits.PlotReach + clearance);
+ if ((f.centre - c).magnitude < extent + matters) places.Add(f);
+ }
+ // The box distance (m) from a point to the nearest of <boxes> (the place's own with no blocks: to its disc).
+ float Nearest(Vector2 p, List<(Vector2 q, Vector2 u, Vector2 v, float hw, float hd)> boxes)
+ {
+ if (boxes == own && own.Count == 0 && disc > 0f) return Mathf.Max(0f, (p - c).magnitude - disc);
+ float best = float.MaxValue;
+ foreach (var (q, u, v, hw, hd) in boxes)
+ {
+ var d = c + q - p;
+ float du = Mathf.Max(0f, Mathf.Abs(Vector2.Dot(d, u)) - hw), dv = Mathf.Max(0f, Mathf.Abs(Vector2.Dot(d, v)) - hd);
+ best = Mathf.Min(best, du * du + dv * dv);
+ }
+ return Mathf.Sqrt(best);
+ }
+ bool CitysGround(Vector2 p, float r)
+ {
+ float mine = (p - c).magnitude / home.radius;
+ foreach (var (fc, fr, _) in places)
+ {
+ float d = (p - fc).magnitude;
+ if (d / fr <= mine || d < fr * Kits.SettlementKits.PlotReach + r) return false;
+ }
+ return true;
+ }
+ bool Unnamed(Vector2 p, float r)
+ {
+ if (!ClearOfName(p, r, c, home.radius)) return false;
+ foreach (var (fc, fr, _) in places) if (!ClearOfName(p, r, fc, fr)) return false;
+ return true;
+ }
+ List<(Vector2 centre, float reach)>? sand = null;
+ bool OffTheBeach(Vector2 p, float r)
+ {
+ sand ??= Kits.BeachBands.Reaches(map.Settlements.Concat(map.Localities.Select(l => l.Settlement)).ToList(), ground);
+ return OffBeach(map, ground, sand, p, r);
+ }
+ var checks = new List<SpotCheck>
+ {
+ new SpotCheck("hex", (p, r) => (p - anchor).magnitude + r <= HexInnerRadiusM),
+ new SpotCheck("map", (p, r) => ground.Inside(p.x - r, p.y - r) && ground.Inside(p.x + r, p.y + r)),
+ new SpotCheck("water", (p, r) => !ground.Water(p.x, p.y)),
+ new SpotCheck("near", (p, r) => Nearest(p, own) <= EdgeGapM + clearance),
+ new SpotCheck("nearer", (p, r) => Nearest(p, own) < Nearest(p, others)),
+ new SpotCheck("ground", CitysGround),
+ new SpotCheck("names", Unnamed),
+ new SpotCheck("blocks", (p, r) => ClearOfBoxes(p, r, blocks)),
+ new SpotCheck("landmarks", (p, r) =>
+ {
+ foreach (var (bc, yaw, bw, bd) in landmarks) if (!ClearOfBox(p, r, bc, yaw, bw, bd)) return false;
+ return true;
+ }),
+ new SpotCheck("beach", OffTheBeach),
+ };
+ checks.AddRange(extra);
+ checks.AddRange(free);
+ checks.Add(new SpotCheck("sight", (p, r) => InSight(p, 0f, size, ground.Y(p.x, p.y) + WorkshopTopShare * size, sight, tan)));
+ // Per pass, how many points each test turned away first (the warning reports both passes).
+ var turned = new[] { new int[checks.Count], new int[checks.Count] };
+ // First on the project's hex (every test), then anywhere (every test but "hex", the first).
+ for (int pass = 0; pass < 2; pass++)
+ {
+ foreach (var p in points)
+ {
+ int failed = -1;
+ for (int i = pass; i < checks.Count && failed < 0; i++) if (!checks[i].Test(p, clearance)) failed = i;
+ if (failed < 0) { tally = ""; return p; }
+ turned[pass][failed]++;
+ }
+ }
+ string Tally(int pass) => string.Join(", ", checks.Select((x, i) => (x, i)).Where(t => t.i >= pass)
+ .Select(t => FormattableString.Invariant($"{t.x.Name} {turned[pass][t.i]}")));
+ tally = FormattableString.Invariant($"{points.Count} points past {edgeName}, none on or off its hex passing; turned away first, on its hex by ")
+ + Tally(0) + "; off it by " + Tally(1);
+ return null;
+ }
+
+ /// <summary>Whether a disc of <paramref name="r"/> at <paramref name="p"/> keeps off the beach: no open sea
+ /// (KitGround.SeaDistance) within the drawn full sand there (BeachBands.FullSandAt over <paramref name="sand"/>, the
+ /// plot reaches BeachBands.Reaches gives) plus <paramref name="r"/>.</summary>
+ internal static bool OffBeach(MapScene map, Kits.KitGround ground, List<(Vector2 centre, float reach)> sand, Vector2 p, float r) =>
+ ground.SeaDistance(p.x, p.y, Kits.BeachBands.FullSandAt(map.Frame, p.x, p.y, sand) + r) == float.MaxValue;
+
/// <summary>#1701 slice F, owner 2 November 2026 ("Among the houses"): a workshop on a hex a town's footprint covers stands
- /// in a gap between the drawn buildings on the hex (<see cref="TownBuildings"/>), off the kits' walls, platforms and
- /// landmarks (<see cref="TownLandmarkBoxes"/>), clear of every name there
- /// (<see cref="ClearOfName"/>) and <paramref name="free"/> (the hex, the routes, the tokens, the other models). A fixed search: rings
- /// half a clearance apart outward from the hex centre, each from an FNV-1a bearing of the key. Null when no gap is
- /// clear.</summary>
- internal static Vector2? TownGap(MapScene map, string key, Vector2 anchor, float clearance, Func<Vector2, float, bool> free)
+ /// in a gap between the drawn buildings on the hex (<see cref="TownBuildings"/>, and a major city's kit blocks,
+ /// <see cref="MajorCityBlocksNear"/>, #2876), off the kits' walls, platforms and landmarks (<see cref="TownLandmarkBoxes"/>),
+ /// clear of every name there (<see cref="ClearOfName"/>) and <paramref name="free"/> (the hex, the routes, the tokens, the
+ /// other models). A fixed search: rings half a clearance apart outward from the hex centre, each from an FNV-1a bearing of
+ /// the key. Where no gap is clear and major-city blocks reach the hex (their streets are narrower than the clearance disc:
+ /// Tel Aviv's 60x blocks stand 180 to 360 m apart, the b21's disc is about 1.02 km across at WorkshopScale 2.5), the same search for a street: the
+ /// model's ground taken as its square, <paramref name="size"/> a side (b21 is nearly square from above: vertex extents
+ /// 0.959 by 0.999 FBX units, read from b21-artisan-workshop-v2.fbx on 6 November 2026, centred, so its square holds it),
+ /// turned with the nearest block within reach, clear of every block and kit landmark as boxes, every other test
+ /// unchanged (the disc); <paramref name="along"/> is then that street's direction (world x, z, unit length), for the model
+ /// to lie along it. Both searches also take only a spot <paramref name="seen"/> passes, given the spot and the turn (degrees,
+ /// as KitMesh.Corners) the model is drawn at: 0 in a gap, the street's on a street (#2876: <see cref="InSight"/> on a hex
+ /// a major city's blocks reach, true elsewhere). Null when neither is clear.</summary>
+ internal static Vector2? TownGap(MapScene map, string key, Vector2 anchor, float clearance, float size, Func<Vector2, float, bool> free,
+ Func<Vector2, float, bool> seen, out Vector2? along)
{
+ along = null;
var houses = TownBuildings(map, anchor, out var names);
+ var blocks = MajorCityBlocksNear(map, anchor);
var landmarks = TownLandmarkBoxes(map, anchor);
uint h = 2166136261;
foreach (char c in key) { h ^= c; h *= 16777619; }
- float step = 0.5f * clearance;
- for (float radius = 0f; radius + clearance <= HexInnerRadiusM; radius += step)
+ Vector2? Search(Func<Vector2, bool> clear)
{
- int n = radius == 0f ? 1 : Mathf.Max(6, Mathf.CeilToInt(2f * Mathf.PI * radius / step));
- int start = (int)(h % (uint)n);
- for (int i = 0; i < n; i++)
+ float step = 0.5f * clearance;
+ for (float radius = 0f; radius + clearance <= HexInnerRadiusM; radius += step)
{
- float angle = 2f * Mathf.PI * ((start + i) % n) / n;
- var p = anchor + new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius;
- bool named = false;
- foreach (var (c, fr) in names) if (!ClearOfName(p, clearance, c, fr)) { named = true; break; }
- if (named || !TownLandmarks.Clear(p, clearance, houses)) continue;
- bool onLandmark = false;
- foreach (var (bc, yaw, bw, bd) in landmarks) if (!ClearOfBox(p, clearance, bc, yaw, bw, bd)) { onLandmark = true; break; }
- if (onLandmark || !free(p, clearance)) continue;
- return p;
+ int n = radius == 0f ? 1 : Mathf.Max(6, Mathf.CeilToInt(2f * Mathf.PI * radius / step));
+ int start = (int)(h % (uint)n);
+ for (int i = 0; i < n; i++)
+ {
+ float angle = 2f * Mathf.PI * ((start + i) % n) / n;
+ var p = anchor + new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)) * radius;
+ if (clear(p)) return p;
+ }
}
+ return null;
}
- return null;
+ bool Named(Vector2 p)
+ {
+ foreach (var (c, fr) in names) if (!ClearOfName(p, clearance, c, fr)) return true;
+ return false;
+ }
+ var gap = Search(p =>
+ {
+ if (Named(p) || !TownLandmarks.Clear(p, clearance, houses) || !ClearOfBoxes(p, clearance, blocks)) return false;
+ foreach (var (bc, yaw, bw, bd) in landmarks) if (!ClearOfBox(p, clearance, bc, yaw, bw, bd)) return false;
+ return free(p, clearance) && seen(p, 0f);
+ });
+ if (gap != null || blocks.Count == 0) return gap;
+ float streetYaw = 0f;
+ var street = Search(p =>
+ {
+ if (Named(p) || !TownLandmarks.Clear(p, clearance, houses)) return false;
+ // The street's turn: the nearest block's (a street runs square to its blocks); with no block within reach of
+ // the square, the disc search above has already judged the spot.
+ float best = float.MaxValue; bool any = false;
+ foreach (var (bc, yaw, bw, bd) in blocks)
+ {
+ float reach = size + 0.5f * (bw + bd);
+ if ((p - bc).sqrMagnitude > reach * reach) continue;
+ float a = yaw * Mathf.Deg2Rad, ca = Mathf.Cos(a), sa = Mathf.Sin(a);
+ var q = p - bc; float u = q.x * ca + q.y * sa, v = -q.x * sa + q.y * ca;
+ float du = Mathf.Max(0f, Mathf.Abs(u) - 0.5f * bw), dv = Mathf.Max(0f, Mathf.Abs(v) - 0.5f * bd);
+ float dist = du * du + dv * dv;
+ if (dist < best) { best = dist; streetYaw = yaw; any = true; }
+ }
+ if (!any) return false;
+ foreach (var (bc, yaw, bw, bd) in blocks)
+ {
+ float reach = size + 0.5f * (bw + bd);
+ if ((p - bc).sqrMagnitude > reach * reach) continue;
+ if (!BoxesClear(p, streetYaw, size, size, bc, yaw, bw, bd)) return false;
+ }
+ foreach (var (bc, yaw, bw, bd) in landmarks) if (!BoxesClear(p, streetYaw, size, size, bc, yaw, bw, bd)) return false;
+ return free(p, clearance) && seen(p, streetYaw);
+ });
+ if (street != null) { float a = streetYaw * Mathf.Deg2Rad; along = new Vector2(Mathf.Cos(a), Mathf.Sin(a)); }
+ return street;
}
void Rebuild()
@@ -884,6 +1472,7 @@ namespace Statecraft.Game.Map.Collection
Replan(log: false);
var ground = PlacementLayer.CampGround(map);
var holes = new List<(Vector2 centre, float radius)>();
+ var lanes = new List<(Vector2 at, float half, float baseY, float tan)>();
var boxes = new List<Bounds[]>();
foreach (var w in wants)
{
@@ -910,13 +1499,20 @@ namespace Statecraft.Game.Map.Collection
foreach (var r in go.GetComponentsInChildren<Renderer>(true)) { r.shadowCastingMode = ShadowCastingMode.On; r.forceRenderingOff = !LastClose; renderers.Add(r); }
Placed.Add((w.Key, w.Model, pos));
if (w.Model == Workshop) boxes.Add(new[] { Bounds(go) });
+ // #2876 (coordinator, 6 November 2026: a palm in front of the Jaffa b21 covered it): a major city's b21 also
+ // keeps the kit trees out of its sight lane toward the camera (south), across its clearance (it holds the
+ // model at any turn) and as far south as a tree's top would rise into the ray from its foot at the view's
+ // shallowest depression (SightTan): the trees are 100 times life size (KitScale.Trees), the b21 60 times (24x, WorldScale, times WorkshopScale).
+ if (w.Model == Workshop && Kits.TownModels.IsMajorCity(w.City)) lanes.Add((spot.at, ClearanceOf(w), pos.y, SightTan));
}
// Published once, whole (review of #2281, M1): a list handed to the labels is never changed after.
workshopBoxes = boxes;
// No kit tree stands on a building: the trees whose crowns reach its ground are left out at draw time, as under
- // the unit figures (Kits.VegetationLayer.Hide).
- Units.UnitShowcase.HideTrees(map, Name, holes);
- if (prefabs.Count > 0) Debug.Log($"BUILDINGS: {Placed.Count} of {wants.Count} special buildings placed ({string.Join(", ", Placed.Select(p => p.Key))})");
+ // the unit figures (Kits.VegetationLayer.Hide), and none in a major city's b21's sight lane.
+ var veg = map.GetComponentInChildren<Kits.VegetationLayer>(true);
+ if (veg != null) veg.Hide(Name, holes, lanes);
+ if (prefabs.Count > 0) Debug.Log($"BUILDINGS: {Placed.Count} of {wants.Count} special buildings placed ({string.Join(", ", Placed.Select(p => p.Key))})"
+ + (lanes.Count > 0 && veg != null ? FormattableString.Invariant($"; {veg.SightHidden} kit trees left out of {lanes.Count} b21 sight lanes") : ""));
}
static Bounds Bounds(GameObject go)
diff --git a/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs b/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs
index aed211a40..f074b090e 100644
--- a/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs
+++ b/unity/Assets/Scripts/Map/Collection/TownLandmarks.cs
@@ -15,8 +15,11 @@ 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
+ /// Tel Aviv, Jerusalem, Haifa and Jaffa, the major cities (<see cref="Kits.TownModels.IsMajorCity"/>), have no whole-town
+ /// model: since the owner's ruling of 6 November 2026, "Big blocks, every zoom", their kits draw from 40 km out, and since
+ /// the owner's ruling of 7 November 2026, "Tal's models close (Recommended)", their building models below the close
+ /// switch (before them, the 2 November 2026 ruling, "Yes, small buildings at every zoom" (superseded), drew their building
+ /// models at every zoom). 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
@@ -60,7 +63,9 @@ namespace Statecraft.Game.Map.Collection
Ramla = CollectionCatalog.RamlaTown;
/// <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
+ /// 2026, "Yes, small buildings at every zoom" (superseded on 6 November 2026 by "Big blocks, every zoom", itself
+ /// superseded below the close switch on 7 November 2026 by "Tal's models close (Recommended)"; both keep them without a
+ /// whole-town model: <see cref="Kits.TownModels.IsMajorCity"/>). 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"/>,
@@ -101,9 +106,10 @@ namespace Statecraft.Game.Map.Collection
internal 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: 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
+ /// <summary>The model for settlement <paramref name="s"/>, or null for none: none for the major cities, which draw their
+ /// kits from 40 km out and their building models below the close switch (<see cref="Kits.TownModels.IsMajorCity"/>; Jaffa, an Arab town, would otherwise take
+ /// <see cref="ByType"/>'s stone village).</summary>
+ public static string? ModelFor(Settlement s) => Kits.TownModels.IsMajorCity(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
diff --git a/unity/Assets/Scripts/Map/Kits/KitLayer.cs b/unity/Assets/Scripts/Map/Kits/KitLayer.cs
index cbde38e1d..3849ea0cd 100644
--- a/unity/Assets/Scripts/Map/Kits/KitLayer.cs
+++ b/unity/Assets/Scripts/Map/Kits/KitLayer.cs
@@ -44,6 +44,13 @@ namespace Statecraft.Game.Map.Kits
/// works, street palms: SettlementKits.Placed, its yaw as KitMesh.Corners), then each landmark's close copy as its
/// world box (yaw 0), so a model placed among a town's houses (SpecialBuildingModels.TownGap) keeps off them.</summary>
public IReadOnlyList<SettlementKits.Placed> Landmarks = System.Array.Empty<SettlementKits.Placed>();
+ /// <summary>#2876: the kit blocks of the major cities (TownModels.IsMajorCity), which draw their kits from 40 km out
+ /// (owner, 6 November 2026, "Big blocks, every zoom") and Tal Heuberger's building models below the close switch
+ /// (owner, 7 November 2026, "Tal's models close (Recommended)"): each "building" and "wing" the kits placed for one
+ /// of them (SettlementKits.Placed, Id the city's, its yaw as KitMesh.Corners), in placement order, so a model placed
+ /// among a major city's houses (SpecialBuildingModels.TownGap) keeps off the blocks drawn there as well as off its
+ /// building models.</summary>
+ public IReadOnlyList<SettlementKits.Placed> MajorCityBlocks = System.Array.Empty<SettlementKits.Placed>();
public override string ToString() =>
$"KITS buildings={Buildings} vertices={Vertices} triangles={Triangles} trees={Trees} route_segments={CorridorSegments} build_ms={BuildMs:0} plant_ms={PlantMs:0} " +
$"localities={Localities} locality_buildings={LocalityBuildings} camps={Camps} tents={Tents} boats={Boats} draws={Draws} models={Models} close_vertices={CloseVertices}";
@@ -149,19 +156,26 @@ namespace Statecraft.Game.Map.Kits
var towns = townGo.AddComponent<TownModelLayer>();
if (residency == null) throw new System.ArgumentNullException(nameof(residency));
towns.ConfigureProduction(residency.Towns);
- // #2378: beyond the close switch the four cities and every settlement with a whole-town model (the moshavot and
- // towns, the kibbutzim, Nahalal and the Arab towns: Acre, Nazareth, Lod, Gaza, Beersheba) draw the far-off copies
- // of their building models, in place of the whole-town model within the far band (owner, 3 November 2026,
- // "Cities/towns only (Recommended)"); the 271 1948 localities keep their kit blocks.
+ // #2378: beyond the close switch every settlement with a whole-town model (the moshavot and towns, the kibbutzim,
+ // Nahalal and the Arab towns: Acre, Nazareth, Lod, Gaza, Beersheba) draws the far-off copies of its building
+ // models, in place of the whole-town model within the far band (owner, 3 November 2026, "Cities/towns only
+ // (Recommended)"); the 271 1948 localities keep their kit blocks. The major cities (TownModels.IsMajorCity) have
+ // no whole-town model and take no far-off copies: they draw their kits from 40 km out (owner, 6 November 2026, "Big
+ // blocks, every zoom", which superseded the 2 November 2026 ruling, "Yes, small buildings at every zoom") and their
+ // building models below the close switch, as every place (owner, 7 November 2026, "Tal's models close
+ // (Recommended)", which supersedes "Big blocks, every zoom" below 40 km).
var farTowns = new List<string>();
foreach (var s in settlements)
- if (TownModels.AtEveryZoom(s.Id) || Collection.TownLandmarks.ModelFor(s) != null) farTowns.Add(s.Id);
+ if (Collection.TownLandmarks.ModelFor(s) != null) farTowns.Add(s.Id);
towns.Init(built.Models, townModels, swaps, nearTowns, rendererTownIds, rendererTileIds, farTowns);
stats.LandmarkParts = parts;
var landmarks = new List<SettlementKits.Placed>();
foreach (var p in placed) if (p.Kind != "building" && p.Kind != "wing") landmarks.Add(p);
foreach (var p in built.CloseLandmarks) landmarks.Add(new SettlementKits.Placed(p.Id, p.Kind, p.C, 0f, p.W, p.D, p.H, p.Wall, p.Y));
stats.Landmarks = landmarks;
+ var majorBlocks = new List<SettlementKits.Placed>();
+ foreach (var p in placed) if ((p.Kind == "building" || p.Kind == "wing") && TownModels.IsMajorCity(p.Id)) majorBlocks.Add(p);
+ stats.MajorCityBlocks = majorBlocks;
var localityIds = new HashSet<string>(System.StringComparer.Ordinal);
foreach (var locality in localities) localityIds.Add(locality.Id);
towns.ConfigureTownFootprints(stats.Footprints, localityIds);
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs
index 66ec1f019..31dca0c13 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Landmarks.cs
@@ -470,17 +470,25 @@ namespace Statecraft.Game.Map.Kits
}
if (pieces > 0) { Record(s.Id, "port", sea + new Vector2(-12f * m, 6f * m), 0f, 24f * m, 18f * m, 2.2f * m, stone); n++; }
var shed = C(0.82f, 0.79f, 0.72f);
+ // #2876: 8 m along the row (was 15 m) and 11.25 m across it (was 6 m), so each shed keeps its 90 square metres of
+ // ground (TownCensusTests.TheCitiesCoverTheirGround's floors). The row runs north-south, the way the camera looks,
+ // and the four major cities draw these kit sheds from 40 km out (TownModels.IsMajorCity): on the 17 m pitch a 15 m
+ // shed left a 2 m gap, which the shed in front hides, so the three drew as one strip. An 8 m shed leaves 9 m, more
+ // than a 5 m shed hides behind it at the camera's shallowest ray (TownCensusTests.TelAvivsPortShedsStandApart).
+ // The deeper shed's seaward side stays on the beach strip's inner edge: its lot is wanted half its depth plus
+ // 0.1 m (was 4 m) behind BeachSetbackM.
+ const float shedL = 8f, shedW = 11.25f, behindBeach = 0.5f * shedW + 0.1f;
for (int i = 0; i < 3; i++)
{
// Behind the beach strip (BeachSetbackM), so the sand stays open in front of them.
- if (!Claim(lots, l + new Vector2(BeachSetbackM + 4f * m, (i - 1) * 17f * m), 8.5f * m, s.Id, ground, out var q)) continue;
- var (bt, gy) = GroundSpan(q, 90f, 15f * m, 6f * m, ground, m);
- AddModel(s.Id, TownModel.B32CargoShed, q, 90f, 15f * m, 6f * m, 5f * m, bt, gy, km, m, exactHeight: false, flip: false); // #659
+ if (!Claim(lots, l + new Vector2(BeachSetbackM + behindBeach * m, (i - 1) * 17f * m), 8.5f * m, s.Id, ground, out var q)) continue;
+ var (bt, gy) = GroundSpan(q, 90f, shedL * m, shedW * m, ground, m);
+ AddModel(s.Id, TownModel.B32CargoShed, q, 90f, shedL * m, shedW * m, 5f * m, bt, gy, km, m, exactHeight: false, flip: false); // #659
var cut = km.CutStart();
- km.Box(q.x, q.y, 90f, 15f * m, 6f * m, bt, gy, 3.2f * m, shed, C(0.62f, 0.58f, 0.54f), Facade.Plain, m, roofed: true);
- km.Gable(q.x, q.y, 90f, 15f * m, 6f * m, gy + 3.2f * m, 1.8f * m, C(0.60f, 0.58f, 0.55f), shed);
+ km.Box(q.x, q.y, 90f, shedL * m, shedW * m, bt, gy, 3.2f * m, shed, C(0.62f, 0.58f, 0.54f), Facade.Plain, m, roofed: true);
+ km.Gable(q.x, q.y, 90f, shedL * m, shedW * m, gy + 3.2f * m, 1.8f * m, C(0.60f, 0.58f, 0.55f), shed);
km.CutEnd(cut);
- Record(s.Id, "warehouse", q, 90f, 15f * m, 6f * m, 5f * m, shed);
+ Record(s.Id, "warehouse", q, 90f, shedL * m, shedW * m, 5f * m, shed);
n++;
}
return n;
diff --git a/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs b/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs
index f9ce06dc1..fb7fcc73e 100644
--- a/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs
+++ b/unity/Assets/Scripts/Map/Kits/SettlementKits.Models.cs
@@ -11,9 +11,12 @@ 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). 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>
+ /// landmarks at the world scale, KitMesh.CloseCopy). Tel Aviv, Jerusalem, Haifa and Jaffa, the major cities
+ /// (TownModels.IsMajorCity), draw their models up close as every town (owner, 7 November 2026, "Tal's models close
+ /// (Recommended)") and their kits from 40 km out, with no far-off copies (owner, 6 November 2026, "Big blocks, every
+ /// zoom", which "Tal's models close (Recommended)" supersedes below 40 km; it superseded the 2 November 2026 ruling, "Yes,
+ /// small buildings at every zoom", that drew their models at every zoom). The layout, the lots and the census do not
+ /// change.</summary>
public static partial class SettlementKits
{
/// <summary>One placed model: its town (or locality) id, the model, its world matrix (the model's mesh space to the
diff --git a/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs b/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs
index 8aea9d13d..cc040386c 100644
--- a/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs
+++ b/unity/Assets/Scripts/Map/Kits/TownModelLayer.cs
@@ -8,12 +8,15 @@ namespace Statecraft.Game.Map.Kits
/// <summary>Building meshes for admitted towns and villages, instanced per model/tile: Tal Heuberger's originals below the
/// close switch (<see cref="CloseEnterM"/>, #1273) and their lighter far-off copies beyond it, out to the far band
/// (<see cref="FarEnterM"/>; owner, 3 November 2026, #2378: "Ask Tal; allow them far off only", then "I have Tal's OK;
- /// go ahead"). The far copies serve <see cref="Init"/>'s farTowns: the four cities and every settlement with a whole-town
- /// model (the moshavot and towns, the kibbutzim, Nahalal and the Arab towns: Acre, Nazareth, Lod, Gaza, Beersheba), whose
+ /// go ahead"). The far copies serve <see cref="Init"/>'s farTowns: every settlement with a whole-town model (the
+ /// moshavot and towns, the kibbutzim, Nahalal and the Arab towns: Acre, Nazareth, Lod, Gaza, Beersheba), whose
/// whole-town model gives way to them within the far band (owner, 3 November 2026, "Cities/towns only (Recommended)");
- /// the 271 1948 localities keep their kit blocks. Tel Aviv, Jerusalem, Haifa and Jaffa are admitted at every
- /// zoom, by view as below (owner ruling, 2 November 2026, "Yes, small buildings at every zoom":
- /// <see cref="TownModels.AtEveryZoom"/>), and draw their far copies beyond the far band too. Under the production policy
+ /// the 271 1948 localities keep their kit blocks. The major cities (Tel Aviv, Jerusalem, Haifa and Jaffa:
+ /// <see cref="TownModels.IsMajorCity"/>) are admitted below the close switch, as every other place, and draw Tal
+ /// Heuberger's building models there (owner, 7 November 2026, "Tal's models close (Recommended)"); from 40 km out they
+ /// take no far-off copies and draw their kits, with their landmarks (owner, 6 November 2026, "Big blocks, every zoom",
+ /// which "Tal's models close (Recommended)" supersedes below the switch; it superseded the 2 November 2026 ruling, "Yes,
+ /// small buildings at every zoom"). 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
@@ -29,7 +32,7 @@ namespace Statecraft.Game.Map.Kits
/// close checks (hero06, 6 km: CameraController.MinDistance) well inside.</summary>
public const float CloseEnterM = 40000f, CloseExitM = 45000f;
/// <summary>The far band (m), this layer's alone (the seven other layers on the close switch keep 40/45 km): from
- /// the close switch out to FarEnterM the four cities and every settlement with a whole-town model draw the far-off
+ /// the close switch out to FarEnterM every settlement with a whole-town model draws the far-off
/// copies of their building models instead of their kits; the kits come back above FarExitM. 100 km holds the 90 km opening and
/// the 60 km gameplay view and stays under the strategic cap (Collection.OriginalModelDistance, 120 km); a 204 m house is 3.5 px
/// there, where the kit's 100x houses read better as a mass, and the view's footprint (10,670 km2, about 170 places)
@@ -281,7 +284,7 @@ namespace Statecraft.Game.Map.Kits
}
public int Count { get; private set; }
/// <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>
+ /// instances, triangles and draws it submitted (test and profiling aids).</summary>
public bool LastClose { get; private set; }
public int LastDrawn { get; private set; }
public long LastTriangles { get; private set; }
@@ -293,9 +296,8 @@ namespace Statecraft.Game.Map.Kits
/// (<paramref name="rendererTileIds"/>: each tile renderer's villages). A complete editor model set is optional in a
/// player: acquired originals become ready independently per town, while incomplete/missing replies keep fallback. A
/// tile swaps only when every village in it is ready; no tile or unrelated town swaps on a partial global set.
- /// <paramref name="farTowns"/> names the places that draw the far-off copies beyond the close switch (the four cities
- /// and every settlement with a whole-town model: KitLayer passes them); null, the default of the small test fixtures, admits
- /// none there.</summary>
+ /// <paramref name="farTowns"/> names the places that draw the far-off copies beyond the close switch (every settlement
+ /// with a whole-town model: KitLayer passes them); null, the default of the small test fixtures, admits none there.</summary>
public void Init(IReadOnlyList<SettlementKits.ModelInstance> instances, TownModelSet? models, IReadOnlyList<(Renderer kit, Renderer? close)> swaps, IReadOnlyCollection<string>? townIds = null, IReadOnlyDictionary<Renderer, string>? rendererTownIds = null,
IReadOnlyDictionary<Renderer, string[]>? rendererTileIds = null, IReadOnlyCollection<string>? farTowns = null)
{
@@ -486,7 +488,7 @@ namespace Statecraft.Game.Map.Kits
if (!SpatialPolicyConfigured || !withinView) choice.hadFocus = false;
choice.selected = next;
choice.primary = next.Length == 0 ? null : next[0];
- if (!choice.towns.SetEquals(next))
+ if (!SameTowns(choice.towns, next))
{
choice.towns.Clear(); foreach (var id in next) choice.towns.Add(id); changed = true;
}
@@ -513,9 +515,26 @@ namespace Statecraft.Game.Map.Kits
}
}
+ /// <summary>Whether <paramref name="towns"/> holds exactly the ids of <paramref name="next"/>, as HashSet.SetEquals would
+ /// say, without allocating: SetEquals walks an array through IEnumerable, which boxes its enumerator, on every frame a
+ /// camera has a ground focus (below OriginalModelDistance.EnterM, 120 km), the far band included. The sets are a few
+ /// towns, so the two passes cost nothing.</summary>
+ static bool SameTowns(HashSet<string> towns, string[] next)
+ {
+ foreach (string id in next) if (!towns.Contains(id)) return false;
+ foreach (string id in towns) if (System.Array.IndexOf(next, id) < 0) return false;
+ return true;
+ }
+ static bool SameTowns(HashSet<string> towns, List<string> next)
+ {
+ foreach (string id in next) if (!towns.Contains(id)) return false;
+ foreach (string id in towns) if (!next.Contains(id)) return false;
+ return true;
+ }
+
/// <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>
+ /// so PrepareCameraCore holds no closure: a closure there was allocated on every call, far off too, where the far-off
+ /// copies draw.</summary>
System.Func<IReadOnlyList<string>, string, bool>? AllowanceFor(Choice owner) => EdgeAllowance == null ? null : (local, edge) =>
{
var admitted = new List<string>();
@@ -529,7 +548,7 @@ namespace Statecraft.Game.Map.Kits
/// <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; a far camera only the cities drawn at every zoom (<see cref="AtZoom"/>). Returns whether the
+ /// its ground focus first; a far camera only what its zoom admits (<see cref="AtZoom"/>). Returns whether the
/// admitted set changed.</summary>
bool AdmitInView(Choice choice, Camera cam)
{
@@ -548,7 +567,7 @@ namespace Statecraft.Game.Map.Kits
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 cities
+ if (!AtZoom(choice, ids[0])) continue; // a village tile's first village: never a major city
float 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]));
@@ -556,7 +575,7 @@ namespace Statecraft.Game.Map.Kits
viewScratch.Sort(ViewDistanceComparer.Instance);
viewNext.Clear();
foreach (var (i, _, _) in viewScratch) viewNext.AddRange(viewPlaces[i].ids);
- bool changed = !choice.viewed.SetEquals(viewNext);
+ bool changed = !SameTowns(choice.viewed, viewNext); // not SetEquals: no boxed enumerator while the view moves
choice.inView.Clear(); choice.inView.AddRange(viewNext); // the order alone loads nothing new
if (changed) { choice.viewed.Clear(); choice.viewed.UnionWith(viewNext); }
return changed;
@@ -587,9 +606,12 @@ namespace Statecraft.Game.Map.Kits
}
/// <summary>Whether a camera's zoom admits a place's building models: every place below the close switch (the
- /// originals); within the far band the places that take the far-off copies (<see cref="farTowns"/>); beyond it only
- /// the cities drawn at every zoom (owner ruling, 2 November 2026, "Yes, small buildings at every zoom").</summary>
- bool AtZoom(Choice c, string id) => c.close || TownModels.AtEveryZoom(id) || (c.far && farTowns != null && farTowns.Contains(id));
+ /// originals); within the far band the places that take the far-off copies (<see cref="farTowns"/>); beyond it none.
+ /// A major city (<see cref="TownModels.IsMajorCity"/>) only below the close switch, with its hysteresis (in below
+ /// CloseEnterM, out above CloseExitM, as every place): Tal Heuberger's building models there (owner, 7 November 2026,
+ /// "Tal's models close (Recommended)"), and from 40 km out its kit (owner, 6 November 2026, "Big blocks, every zoom",
+ /// superseded below the switch by "Tal's models close (Recommended)"); never in the far band.</summary>
+ bool AtZoom(Choice c, string id) => c.close || (c.far && !TownModels.IsMajorCity(id) && farTowns != null && farTowns.Contains(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>
@@ -790,8 +812,7 @@ namespace Statecraft.Game.Map.Kits
if (filter == null || renderer == null || filter.sharedMesh == null || renderer.sharedMaterial == null)
{
// Once per streamed id for this layer (an original and its far-off copy fail apart): 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).
+ // code-built kits.
if (warnedIds.Add(streamId)) Debug.LogWarning($"TOWN MODELS: {streamId} did not stream; the places built from it keep their kits.");
return;
}
@@ -863,10 +884,10 @@ namespace Statecraft.Game.Map.Kits
LastClose = close;
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.
+ // building models (the far-off copies) cast no shadows; below it every building casts.
var shadows = close ? ShadowCastingMode.On : ShadowCastingMode.Off;
- // Beyond the close switch the far-off copies draw (#2378): for the places the far band admits and, at every zoom,
- // the four cities (AtZoom); ReadyForTown admits nothing else there.
+ // Beyond the close switch the far-off copies draw (#2378): for the places the far band admits (AtZoom);
+ // ReadyForTown admits nothing else there.
var streamed = close ? models : farModels;
if (Draw)
{
diff --git a/unity/Assets/Scripts/Map/Kits/TownModels.cs b/unity/Assets/Scripts/Map/Kits/TownModels.cs
index d11dd8854..dfd988073 100644
--- a/unity/Assets/Scripts/Map/Kits/TownModels.cs
+++ b/unity/Assets/Scripts/Map/Kits/TownModels.cs
@@ -97,12 +97,21 @@ 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 1945 population (<see cref="KitPopulation"/>, content/map/settlement_population_1945.yaml) from which a
+ /// place is a major city: the owner, 6 November 2026, "Just the four (Recommended)". In the data that is Tel Aviv,
+ /// Jerusalem, Haifa and Jaffa; the next place below it is Gaza (34,250).</summary>
+ public const int MajorCityPopulation = 60000;
+
+ /// <summary>Whether a place is a major city (<see cref="MajorCityPopulation"/>): below TownModelLayer's close switch
+ /// (CloseEnterM, 40 km; out again above CloseExitM, 45 km) it draws Tal Heuberger's building models, as every place
+ /// (owner, 7 November 2026, "Tal's models close (Recommended)"), and from 40 km out its code-built kit, with its
+ /// landmarks, never the far-off copies (owner, 6 November 2026, "Big blocks, every zoom", which "Tal's models close
+ /// (Recommended)" supersedes below 40 km). Collection.TownLandmarks.ModelFor gives it no whole-town model. "Big blocks,
+ /// every zoom" superseded the owner's ruling of 2 November 2026, "Yes, small buildings at every zoom", which drew these
+ /// four from the building models at every zoom, and before it the 18 October 2026 "Whole model far, buildings near"
+ /// for them. Reads the table MapScene.Build hands the kits (KitPopulation.Of: 0, so
+ /// no major city, before that).</summary>
+ public static bool IsMajorCity(string id) => KitPopulation.Of(id) >= MajorCityPopulation;
/// <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>
diff --git a/unity/Assets/Scripts/Map/Kits/VegetationLayer.cs b/unity/Assets/Scripts/Map/Kits/VegetationLayer.cs
index 59434d768..fa3032be2 100644
--- a/unity/Assets/Scripts/Map/Kits/VegetationLayer.cs
+++ b/unity/Assets/Scripts/Map/Kits/VegetationLayer.cs
@@ -19,19 +19,28 @@ namespace Statecraft.Game.Map.Kits
/// <summary>A tile's trees: <c>all</c> as planted (shuffled), <c>m</c> the ones drawn (all, less those under a unit
/// figure: <see cref="Hide"/>), in the same order, so drawing a prefix still thins evenly; <c>crown</c> is the largest
- /// crown radius (m) among them.</summary>
- sealed class Tile { public TreeKind kind; public Bounds bounds; public float crown; public Matrix4x4[] all = System.Array.Empty<Matrix4x4>(), m = System.Array.Empty<Matrix4x4>(); }
+ /// crown radius (m) among them, <c>top</c> the highest tree top (world y).</summary>
+ sealed class Tile { public TreeKind kind; public Bounds bounds; public float crown, top; public Matrix4x4[] all = System.Array.Empty<Matrix4x4>(), m = System.Array.Empty<Matrix4x4>(); }
readonly List<Tile> tiles = new List<Tile>();
readonly SortedDictionary<string, List<(Vector2 centre, float radius)>> holes = new SortedDictionary<string, List<(Vector2, float)>>(System.StringComparer.Ordinal);
+ readonly SortedDictionary<string, List<(Vector2 at, float half, float baseY, float tan)>> lanes = new SortedDictionary<string, List<(Vector2, float, float, float)>>(System.StringComparer.Ordinal);
+ readonly Dictionary<TreeKind, float> topM = new Dictionary<TreeKind, float>();
+ static readonly IReadOnlyList<(Vector2 at, float half, float baseY, float tan)> NoLanes = System.Array.Empty<(Vector2, float, float, float)>();
readonly Dictionary<TreeKind, Mesh> meshes = new Dictionary<TreeKind, Mesh>();
Material? material;
public bool Draw { get; set; } = true;
public int Count { get; private set; }
/// <summary>Instances submitted for the last camera (a test and profiling aid).</summary>
public int LastDrawn { get; private set; }
- /// <summary>Trees left out now because they stand under a unit figure (<see cref="Hide"/>).</summary>
+ /// <summary>Trees left out now because they stand under a unit figure or a model, or in a model's sight lane (<see cref="Hide"/>).</summary>
public int Hidden { get; private set; }
+ /// <summary>Of <see cref="Hidden"/>, the trees left out because they stand in a sight lane (#2876).</summary>
+ public int SightHidden { get; private set; }
+
+ /// <summary>A tree's top (world y): its kind's mesh top (Vegetation.BuildMesh) at the instance's height scale, over the
+ /// ground it stands on.</summary>
+ float TopOf(TreeKind kind, Matrix4x4 m) => m.m13 + topM[kind] * ((Vector3)m.GetColumn(1)).magnitude;
/// <summary>A tree's crown radius (m) as placed: its kind's real crown times the instance's scale, with the planting
/// margin (Vegetation.Plant keeps a crown this wide off the lots and routes).</summary>
@@ -40,7 +49,7 @@ namespace Statecraft.Game.Map.Kits
public void Init(List<(TreeKind kind, Matrix4x4 m)> trees, Material treeMaterial, MapRuntimeAssets assets)
{
material = treeMaterial;
- foreach (TreeKind k in System.Enum.GetValues(typeof(TreeKind))) meshes[k] = assets.Own(Vegetation.BuildMesh(k));
+ foreach (TreeKind k in System.Enum.GetValues(typeof(TreeKind))) { meshes[k] = assets.Own(Vegetation.BuildMesh(k)); topM[k] = meshes[k].bounds.max.y; }
var byTile = new Dictionary<(TreeKind, int, int), List<Matrix4x4>>();
foreach (var (kind, m) in trees)
{
@@ -61,12 +70,13 @@ namespace Statecraft.Game.Map.Kits
foreach (var m in list) b.Encapsulate((Vector3)m.GetColumn(3));
b.Expand(new Vector3(400f, 800f, 400f) * (KitScale.Trees / KitScale.CountReference)); // the crowns round the trunk points
float crown = 0f;
- foreach (var m in list) crown = Mathf.Max(crown, CrownRadius(key.Item1, m));
+ float top = float.MinValue;
+ foreach (var m in list) { crown = Mathf.Max(crown, CrownRadius(key.Item1, m)); top = Mathf.Max(top, TopOf(key.Item1, m)); }
var arr = list.ToArray();
- tiles.Add(new Tile { kind = key.Item1, bounds = b, crown = crown, all = arr, m = arr });
+ tiles.Add(new Tile { kind = key.Item1, bounds = b, crown = crown, top = top, all = arr, m = arr });
}
Count = trees.Count;
- holes.Clear(); Hidden = 0;
+ holes.Clear(); lanes.Clear(); Hidden = 0; SightHidden = 0;
}
/// <summary>Issue #249: leaves out, at draw time, every tree whose crown reaches into one of <paramref name="where"/>
@@ -74,24 +84,56 @@ namespace Statecraft.Game.Map.Kits
/// units in play, the showcase) sets its own holes, and an empty list gives its trees back. The planting itself, and
/// so the kits' layout, never changes; only the tiles a hole reaches are rebuilt, when a caller's holes change (a
/// roster change), never per frame.</summary>
- public void Hide(string owner, IReadOnlyList<(Vector2 centre, float radius)> where)
+ public void Hide(string owner, IReadOnlyList<(Vector2 centre, float radius)> where) => Hide(owner, where, NoLanes);
+
+ /// <summary>As the disc-only Hide, with <paramref name="sight"/>
+ /// (#2876): the lanes from a model toward the map's camera, which looks north, so south of it. A lane at <c>at</c> (x, z)
+ /// is <c>half</c> either side of it across and from <c>half</c> north of it south to where the ray from its south edge's
+ /// foot (world y <c>baseY</c>), rising <c>tan</c> a metre toward the camera, passes over a tree's top
+ /// (<see cref="TopOf"/>); a tree whose crown reaches into it would stand in front of the model, and is left out.</summary>
+ public void Hide(string owner, IReadOnlyList<(Vector2 centre, float radius)> where, IReadOnlyList<(Vector2 at, float half, float baseY, float tan)> sight)
{
if (where.Count == 0) holes.Remove(owner); else holes[owner] = new List<(Vector2, float)>(where);
+ if (sight.Count == 0) lanes.Remove(owner); else lanes[owner] = new List<(Vector2, float, float, float)>(sight);
var all = new List<(Vector2 centre, float radius)>();
foreach (var h in holes.Values) all.AddRange(h);
- int hidden = 0;
+ var allLanes = new List<(Vector2 at, float half, float baseY, float tan)>();
+ foreach (var l in lanes.Values) allLanes.AddRange(l);
+ int hidden = 0, inLanes = 0;
var keep = new List<Matrix4x4>();
foreach (var t in tiles)
{
- if (!Reaches(t, all)) { t.m = t.all; continue; }
+ bool holesReach = Reaches(t, all), lanesReach = Reaches(t, allLanes);
+ if (!holesReach && !lanesReach) { t.m = t.all; continue; }
keep.Clear();
foreach (var m in t.all)
{
- if (Covered(t.kind, m, all)) hidden++; else keep.Add(m);
+ if (holesReach && Covered(t.kind, m, all)) hidden++;
+ else if (lanesReach && InLane(t.kind, m, allLanes)) { hidden++; inLanes++; }
+ else keep.Add(m);
}
t.m = keep.Count == t.all.Length ? t.all : keep.ToArray();
}
- Hidden = hidden;
+ Hidden = hidden; SightHidden = inLanes;
+ }
+
+ static bool Reaches(Tile t, List<(Vector2 at, float half, float baseY, float tan)> sight)
+ {
+ foreach (var (at, half, baseY, tan) in sight)
+ {
+ float run = Mathf.Max(0f, t.top - baseY) / tan;
+ if (t.bounds.min.x < at.x + half + t.crown && t.bounds.max.x > at.x - half - t.crown
+ && t.bounds.min.z < at.y + half + t.crown && t.bounds.max.z > at.y - half - run - t.crown) return true;
+ }
+ return false;
+ }
+
+ bool InLane(TreeKind kind, Matrix4x4 m, List<(Vector2 at, float half, float baseY, float tan)> sight)
+ {
+ var p = m.GetColumn(3); float crown = CrownRadius(kind, m), top = TopOf(kind, m);
+ foreach (var (at, half, baseY, tan) in sight)
+ if (Mathf.Abs(p.x - at.x) < half + crown && p.z - crown < at.y + half && (at.y - half - p.z) - crown < (top - baseY) / tan) return true;
+ return false;
}
static bool Reaches(Tile t, List<(Vector2 centre, float radius)> where)
@@ -116,6 +158,31 @@ namespace Statecraft.Game.Map.Kits
return false;
}
+ /// <summary>#2876 (the owner, 7 November 2026, on Hadera: "Move the workshop (Recommended)", the palms stay): whether no
+ /// tree as planted (hidden or not) stands in front of a model of clearance <paramref name="r"/> at <paramref name="p"/>
+ /// (x, z), in its sight lane toward the map's camera, which looks north, so south of it: a crown within
+ /// <paramref name="r"/> either side of it across, from <paramref name="r"/> north of it south to where the ray from its
+ /// south edge's foot (world y <paramref name="baseY"/>), rising <paramref name="tan"/> a metre toward the camera, passes
+ /// over the tree's top (<see cref="TopOf"/>), the lane <see cref="Hide"/>'s sight lanes clear. A tree whose crown
+ /// reaches the model's disc does not count: <see cref="Hide"/> leaves it out under the model, as every building's
+ /// (#249).</summary>
+ public bool ClearInFront(Vector2 p, float r, float baseY, float tan)
+ {
+ foreach (var t in tiles)
+ {
+ float run = Mathf.Max(0f, t.top - baseY) / tan, reach = r + t.crown;
+ if (t.bounds.min.x >= p.x + reach || t.bounds.max.x <= p.x - reach
+ || t.bounds.min.z >= p.y + reach || t.bounds.max.z <= p.y - reach - run) continue;
+ foreach (var m in t.all)
+ {
+ float x = m.m03, z = m.m23, crown = CrownRadius(t.kind, m), dx = x - p.x, dz = z - p.y;
+ if (dx * dx + dz * dz < (r + crown) * (r + crown)) continue; // under it: left out (Hide)
+ if (Mathf.Abs(dx) < r + crown && z - crown < p.y + r && (p.y - r - z) - crown < (TopOf(t.kind, m) - baseY) / tan) return false;
+ }
+ }
+ return true;
+ }
+
/// <summary>Every tree as planted, hidden or not (kind, world matrix): a test aid.</summary>
public IEnumerable<(TreeKind kind, Matrix4x4 m)> Planted()
{
diff --git a/unity/Assets/Scripts/Map/MapScene.cs b/unity/Assets/Scripts/Map/MapScene.cs
index 69aab8fca..8cd54daf8 100644
--- a/unity/Assets/Scripts/Map/MapScene.cs
+++ b/unity/Assets/Scripts/Map/MapScene.cs
@@ -56,6 +56,10 @@ namespace Statecraft.Game.Map
/// 1948 localities' and the Bedouin camps' footprints (empty without the kits). Anything placed on the map "off the
/// towns" (unit tokens: review I5) keeps clear of these, not of the 25 settlements alone.</summary>
public IReadOnlyList<(Vector2 centre, float radius, string id)> KitFootprints => KitStats?.Footprints ?? (IReadOnlyList<(Vector2, float, string)>)System.Array.Empty<(Vector2, float, string)>();
+ /// <summary>#2876: the major cities' kit blocks after the last Build (KitLayer.Stats.MajorCityBlocks; empty without the
+ /// kits): what those cities draw from 40 km out, in place of their building models, which they draw below the close
+ /// switch (owner, 7 November 2026, "Tal's models close (Recommended)").</summary>
+ public IReadOnlyList<Kits.SettlementKits.Placed> MajorCityBlocks => KitStats?.MajorCityBlocks ?? (IReadOnlyList<Kits.SettlementKits.Placed>)System.Array.Empty<Kits.SettlementKits.Placed>();
/// <summary>The game date the routes were last shown at (RouteLayer.ShowAt), so a rebuild draws them as at that date;
/// null before the game has set one (the routes then show as at the game's start).</summary>
public DateTime? RouteDate { get; set; }
diff --git a/unity/Assets/Scripts/Map/PromoPose.cs b/unity/Assets/Scripts/Map/PromoPose.cs
index bb965a60b..378136537 100644
--- a/unity/Assets/Scripts/Map/PromoPose.cs
+++ b/unity/Assets/Scripts/Map/PromoPose.cs
@@ -34,7 +34,9 @@ namespace Statecraft.Game.Map
};
/// <summary>Issue #659 (owner ruling on #700: "Models up close only"): the close views where Tal Heuberger's building models
- /// draw instead of the kits (TownModelLayer.CloseEnterM): Tel Aviv at 30 km and Jaffa's old town at 12 km. Not promo
+ /// draw instead of the kits (TownModelLayer.CloseEnterM): Tel Aviv at 30 km and Jaffa's old town at 12 km, below the
+ /// switch, where Tel Aviv and Jaffa draw them too (owner, 7 November 2026, "Tal's models close (Recommended)", which
+ /// supersedes "Big blocks, every zoom", 6 November 2026, below 40 km: TownModels.IsMajorCity). Not promo
/// matches: VisualShots shoots them after All (everything on), and FrameProfile prices them under "vclose".</summary>
public static IReadOnlyList<PromoPose> CloseUps { get; } = new[]
{
diff --git a/unity/Assets/Tests/EditMode/ArmsWorkshopVisibilityTests.cs b/unity/Assets/Tests/EditMode/ArmsWorkshopVisibilityTests.cs
index ad7dd4952..f504dcda0 100644
--- a/unity/Assets/Tests/EditMode/ArmsWorkshopVisibilityTests.cs
+++ b/unity/Assets/Tests/EditMode/ArmsWorkshopVisibilityTests.cs
@@ -82,7 +82,9 @@ public class ArmsWorkshopVisibilityTests
return w <= 0f || h <= 0f ? 0f : w * h / (model.width * model.height);
}
- IEnumerator Visible(string city)
+ /// <summary>The check for <paramref name="city"/>'s b21, built on the game's first day or, with <paramref name="builtOn"/>,
+ /// with the game moved to that day first (state and turn start, then a redraw, as MajorCityShots.SetDate).</summary>
+ IEnumerator Visible(string city, DateTime? builtOn = null)
{
var inputs = Statecraft.Game.Boot.GameInputs.FromDisk(Statecraft.Game.Paths.Content, Statecraft.Game.Paths.StreamingMap);
foreach (var era in inputs.Content.Eras) { era.Systems.Ruleset = SaveGame.Gdd03Ruleset; era.Systems.Loop = EraSystems.Gdd; }
@@ -104,6 +106,12 @@ public class ArmsWorkshopVisibilityTests
for (int i = 0; i < 5; i++) yield return null;
var state = root.Bridge!.State; var content = root.Bridge.Content;
Assert.AreEqual(SaveGame.Gdd03Ruleset, content.Ruleset);
+ if (builtOn is DateTime day)
+ {
+ foreach (var s in new HashSet<GameState> { root.Bridge.State, root.Bridge.TurnStart }) s.Date = day;
+ root.Bridge.Skip(-2876100); // an id no unit has: SimBridge.Skip raises Changed, so GameRoot redraws on the new day
+ for (int i = 0; i < 3; i++) yield return null;
+ }
Assert.IsNotNull(root.Units, "the game's units are drawn");
var home = content.SettlementHexes.Single(h => h.Id == city);
int id = state.NextId++;
@@ -134,7 +142,12 @@ public class ArmsWorkshopVisibilityTests
Assert.Less(worst, 0.5f, $"{city}'s b21 is hidden behind a unit's figures ({worstName} covers {worst:P0} of it)");
}
- [UnityTest] public IEnumerator TheJerusalemWorkshopIsNotHiddenBehindAUnit() { yield return Visible("jerusalem"); }
+ /// <summary>Jerusalem's b21 stands at the city's edge on ground the Israeli side holds the day it was built (#2876), and in
+ /// the control wash (control_hexes_1948_49.yaml) the hexes round Jerusalem are contested or the other side's until the
+ /// first truce (11 June 1948), so a workshop built on the first day has no spot. None is built that soon in play: an arms
+ /// workshop takes three turns (content/projects.yaml) of a month (content/rules.yaml, turn_lengths). Built on 15 August
+ /// 1948, three months in.</summary>
+ [UnityTest] public IEnumerator TheJerusalemWorkshopIsNotHiddenBehindAUnit() { yield return Visible("jerusalem", new DateTime(1948, 8, 15)); }
[UnityTest] public IEnumerator TheTelAvivWorkshopIsNotHiddenBehindAUnit() { yield return Visible("tel_aviv"); }
[UnityTest] public IEnumerator TheRehovotWorkshopIsNotHiddenBehindAUnit() { yield return Visible("rehovot"); }
}
diff --git a/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs b/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs
index 7d439696d..c2f71c213 100644
--- a/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs
+++ b/unity/Assets/Tests/EditMode/CivilianPeopleTests.cs
@@ -259,7 +259,7 @@ public sealed class CivilianPeopleTests
var 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) but Ramla, its own town (ById, owner 2 November 2026), and Jaffa, which draws its buildings at every zoom");
+ "the seven Arab towns: the stone village (TownLandmarks.ByType) but Ramla, its own town (ById, owner 2 November 2026), and Jaffa, a major city with no whole-town model (its kit from 40 km out, owner, 6 November 2026, \"Big blocks, every zoom\"; its building models below the close switch, 7 November 2026, \"Tal's models close (Recommended)\")");
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");
@@ -494,7 +494,10 @@ public sealed class CivilianPeopleTests
/// 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>
+ /// have no whole-town model (their kit blocks from 40 km out, owner, 6 November 2026, "Big blocks, every zoom"; their
+ /// building models below the close switch, 7 November 2026, "Tal's models close (Recommended)"; it superseded 2 November's
+ /// "Yes, small buildings at every zoom"). Their building kinds stay in TownModels.Ids, catalogued, though only those
+ /// cities placed some of them.</summary>
[Test]
public void EveryCatalogModelIsPlacedButThoseTheOwnerHeldBack()
{
@@ -521,8 +524,9 @@ public sealed class CivilianPeopleTests
placed.UnionWith(Statecraft.Game.Map.Units.UnitWeapons.ByFigure.Values); // #2083: held by the token figures
placed.Add(Statecraft.Game.Map.Units.UnitFigurePointFire.PoseFor(Statecraft.Game.Map.Units.UnitFigures.YoungRecruit)!); // #2084
placed.UnionWith(Statecraft.Game.Map.Kits.TownModels.Ids); // #1273: 18 originals and five generated houses are catalogued and requested by TownModelLayer
- // 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").
+ // Tel Aviv's, Jerusalem's and Haifa's whole towns stay catalogued but unused: the four major cities draw their kit
+ // blocks from 40 km out (owner, 6 November 2026, "Big blocks, every zoom", superseding 2 November's small buildings)
+ // and their building models below the close switch (7 November 2026, "Tal's models close (Recommended)").
// #336's soldier as delivered has no rig; the tokens draw his rigged copy in his place (#2384; owner, 3 November 2026:
// "rig Tal's later"), and the delivered file stays catalogued, unchanged and unplaced.
CollectionAssert.AreEquivalent(new[] { SpecialBuildingModels.Workshop, TownLandmarks.Jerusalem, TownLandmarks.TelAviv, TownLandmarks.Jerusalem3D, TownLandmarks.Haifa, "figure-soldier-1948-v1" },
diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.cs
index 9b151d155..fef40b6a7 100644
--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs
+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs
@@ -652,7 +652,7 @@ public class GameSceneTests
root.Bridge.Skip(state.Units.Keys.First());
var layer = Object.FindFirstObjectByType<MapScene>().Terrain.transform.Find(SpecialBuildingModels.Name);
Assert.IsNotNull(layer?.Find(SpecialBuildingModels.WorkshopKey(id)),
- "the real Changed hookup redraws a newly built workshop");
+ "the real Changed hookup redraws a newly built workshop (tel_aviv's b21; #2876: none may also mean tel_aviv lost its spot)");
}
finally { SpecialBuildingModels.Request = saved; }
}
diff --git a/unity/Assets/Tests/EditMode/HexPropModelsTests.cs b/unity/Assets/Tests/EditMode/HexPropModelsTests.cs
index 0f16e11db..d712d398c 100644
--- a/unity/Assets/Tests/EditMode/HexPropModelsTests.cs
+++ b/unity/Assets/Tests/EditMode/HexPropModelsTests.cs
@@ -605,7 +605,9 @@ namespace Statecraft.Game.Tests
var workshops = before.Select((f, i) =>
{
var (lon, lat) = map.Frame.ToLonLat(new Vector3(f.spot.x, 0f, f.spot.y));
- return new SpecialBuildingModels.Want(SpecialBuildingModels.WorkshopKey(400 + i), SpecialBuildingModels.Workshop, Opening, lon, lat, "test: at a farm scene");
+ // At b21's drawn scale, as ArmsWorkshops' rows (#2876), so its ground is the one ClearanceOf(Workshop) reads.
+ return new SpecialBuildingModels.Want(SpecialBuildingModels.WorkshopKey(400 + i), SpecialBuildingModels.Workshop, Opening, null, lon, lat, "test: at a farm scene",
+ SpecialBuildingModels.Siting.Seeded, "", SpecialBuildingModels.WorkshopScale);
}).ToList();
var buildings = SpecialBuildingModels.Placements(Opening).Concat(workshops).ToList();
Dictionary<string, Vector2> B21(IReadOnlyList<(RuralLife.Want want, Vector2 spot)> plan) =>
diff --git a/unity/Assets/Tests/EditMode/MajorCityShots.cs b/unity/Assets/Tests/EditMode/MajorCityShots.cs
new file mode 100644
index 000000000..30939dd15
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/MajorCityShots.cs
@@ -0,0 +1,346 @@
+#nullable enable
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.Map;
+using Statecraft.Game.Map.Collection;
+using Statecraft.Game.Map.Kits;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+using Object = UnityEngine.Object;
+
+/// <summary>Writes the before and after stills for PR #2876 (the major cities draw their kits from 40 km out: owner, 6 November
+/// 2026, "Big blocks, every zoom" and "Just the four (Recommended)"; below the 40 km close switch Tal Heuberger's building
+/// models, as on main: owner, 7 November 2026, "Tal's models close (Recommended)", which supersedes "Big blocks, every
+/// zoom" below 40 km) to `.superpowers/shots-2876/&lt;SHOTS_TAG&gt;/` at the
+/// repository root (local, not committed; SHOTS_TAG from the environment, "untagged" when unset). English only: a map change,
+/// and the labels do not change.
+/// <list type="bullet">
+/// <item>`&lt;city&gt;-&lt;km&gt;km.png` for tel_aviv, jerusalem, haifa and jaffa at 250, 60, 39 and 31 km (31 km is
+/// CameraRig.StartDistance), the camera (yaw 0) on the city's kit-footprint centre (MapScene.KitFootprints, also its label
+/// point: TownModelResidencyTests). The km are the town layer's own view distance (TownModelLayer.ViewDistance, the one its
+/// 40/45 km close switch and 100 km far band read), so the rig's distance is shortened by the look-at's height. Before
+/// (main): Tal Heuberger's far-off copies at 250 and 60 km (main's AtZoom admits these four in view at every zoom), the
+/// originals at 39 and 31 km. After: the kits at 250 and 60 km, the originals at 39 and 31 km.</item>
+/// <item>`&lt;prop&gt;-close.png`, the props placed to clear the 24x building models (SpecialBuildingModels.Plan's TownEdge rows,
+/// clear of TownModelLayer.InstancesOf) that may now stand inside the 60x/100x kit blocks, at 8 km: the Altalena sandbags on
+/// the Tel Aviv shore (tel_aviv_altalena_sandbags, the game date set to 15 June 1948, SandbagsFrom: the row covers 15 to 23
+/// June 1948 only), the Haifa port quay crates (haifa_quay_crates, 1948 turns, Year1948From), and a built arms workshop's b21
+/// in each of the four cities (gdd-0.3 only: SpecialBuildingModels.ArmsWorkshops; a fixture project built on the opening
+/// date, as TalModelsShots.ArmsWorkshop builds it).</item>
+/// </list>
+/// How the models load in edit mode, the same on main and on the branch: the town layer gets the editor's complete model list
+/// (MapScene.TownModelsForBuild reads Kits.TownModels.SetPath from the AssetDatabase in edit mode), so TownModelLayer does not
+/// stream and a town is ready as soon as a camera admits it; TownModelLayer.ModelAcquire is answered from the AssetDatabase too,
+/// as TalModelsShots.Houses does, in case it streams. The special layer is rebuilt as TalModelsShots.Prop rebuilds it
+/// (CollectionGeometryFixture.Special, its requests answered from the AssetDatabase), after GameRoot has refreshed on the same
+/// date, so GameRoot's next refresh keeps it.
+/// Each still is the map camera's frame with the UI drawn over it (CivMovementShots.Boot and its Shot's alpha composite), and
+/// each gets a `SHOT` line: whether the city's kit renderer "&lt;id&gt;" and its close mesh "&lt;id&gt; close" draw for the map camera
+/// (forceRenderingOff after TownModelLayer.PrepareCamera), whether the layer admits and has ready the city's models, and the
+/// instances the layer drew in the frame. It uses only calls main has. Run (Unity, the unity/ project), at the PR's head:
+/// <code>SHOTS_TAG=after &lt;Unity&gt; -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter MajorCityShots</code>
+/// then with this file and its .meta copied onto main:
+/// <code>SHOTS_TAG=before &lt;Unity&gt; -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter MajorCityShots</code>
+/// Explicit, so it does not run with the checks.</summary>
+[Explicit("writes stills for a pull request, not a check")]
+public class MajorCityShots
+{
+ static readonly string[] Cities = { "tel_aviv", "jerusalem", "haifa", "jaffa" };
+ /// <summary>The day WorkshopProps builds the four workshops on (#2876): three months into the game.</summary>
+ static readonly DateTime WorkshopsBuilt = new DateTime(1948, 8, 15);
+ static readonly float[] DistancesKm = { 250f, 60f, 39f, CameraRig.StartDistance / 1000f };
+ const float PropDistanceM = 8000f;
+ string shotDir = "", saveDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+ GameRoot root = null!;
+ int poke = -2876000; // ids no unit has, for SimBridge.Skip to raise Changed (each id only once)
+ Action<string, CollectionDetail, Action<GameObject?>>? savedSpecial;
+ Func<string, CollectionDetail, Action<GameObject?>, IDisposable>? savedTown;
+
+ [SetUp]
+ public void Prepare()
+ {
+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");
+ shotDir = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", ".superpowers", "shots-2876",
+ string.IsNullOrEmpty(tag) ? "untagged" : tag));
+ Directory.CreateDirectory(shotDir);
+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-major-city-shots-" + Guid.NewGuid().ToString("N"));
+ savedSpecial = SpecialBuildingModels.Request; savedTown = TownModelLayer.ModelAcquire;
+ TownModelLayer.ModelAcquire = (id, detail, done) => { done(Prefab(id, detail)); return new NoLease(); };
+ }
+
+ [TearDown]
+ public void DiscardScene()
+ {
+ SpecialBuildingModels.Request = savedSpecial!; TownModelLayer.ModelAcquire = savedTown!;
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ if (ps != null) Object.DestroyImmediate(ps);
+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }
+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);
+ }
+
+ sealed class NoLease : IDisposable { public void Dispose() { } }
+ static GameObject? Prefab(string id, CollectionDetail detail) => AssetDatabase.LoadAssetAtPath<GameObject>(CollectionCatalog.PrefabPath(id, detail));
+ static IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }
+ static MapScene Scene => Object.FindFirstObjectByType<MapScene>();
+ static TownModelLayer Towns => Scene.GetComponentInChildren<TownModelLayer>(true);
+
+ /// <summary>A city's kit-footprint centre on the ground (its label point); the settlement's own point without a footprint.</summary>
+ static Vector3 CentreOf(string id)
+ {
+ var map = Scene;
+ var f = map.KitFootprints.FirstOrDefault(x => x.id == id);
+ Vector3 at;
+ if (f.id != null) at = new Vector3(f.centre.x, 0f, f.centre.y);
+ else { var s = map.Settlements.First(x => x.Id == id); at = map.Frame.ToWorld(s.Lon, s.Lat, 0); }
+ return Ground(at);
+ }
+
+ static Vector3 Ground(Vector3 at)
+ {
+ var map = Scene;
+ at.y = map.Terrain.SampleHeight(at) + map.Terrain.transform.position.y;
+ return at;
+ }
+
+ /// <summary>The camera on <paramref name="at"/> with yaw 0 and the game's top inset, at <paramref name="viewM"/> of the town
+ /// layer's view distance (to the y = 0 plane: the rig's distance plus the look-at's height along the view ray).</summary>
+ static void Aim(Vector3 at, float viewM)
+ {
+ // CameraRig.Apply freezes the projection at the camera's own aspect, and a batch run's default is 4:3: without this every
+ // still came out 1.33 times too wide (found by #2880; #2882's helper sets it for every shot rig).
+ ShotCamera.Configure(Camera.main, CivMovementShots.Width, CivMovementShots.Height);
+ var rig = Camera.main.GetComponent<CameraRig>();
+ rig.LookAt = at; rig.Yaw = 0f; rig.Distance = viewM; rig.Apply();
+ float down = -Camera.main.transform.forward.y;
+ if (down > 1e-4f) { rig.Distance = Mathf.Max(1000f, viewM - at.y / down); rig.Apply(); }
+ }
+
+ /// <summary>Waits until the town layer has settled for the map camera: renders (each render runs the layer's own callback)
+ /// until the city, if this zoom admits it, has its models ready and no lease is retiring.</summary>
+ static IEnumerator Settle(string city)
+ {
+ var towns = Towns; var cam = Camera.main;
+ int i = 0;
+ for (; i < 60; i++)
+ {
+ towns.PrepareCamera(cam); towns.RestoreRenderers();
+ bool waiting = towns.PendingRetirementLeases > 0 || (towns.AdmitsTown(city, cam) && !towns.ReadyForTown(city, cam));
+ if (!waiting && i >= 3) break;
+ cam.Render();
+ yield return null;
+ }
+ if (i >= 60) Debug.LogWarning($"SHOT {city}: the town layer did not settle in 60 frames");
+ }
+
+ /// <summary>The map camera's state for <paramref name="city"/>: whether its kit and close renderers draw (as the layer leaves
+ /// them for this camera), and whether the layer admits it and has its models ready.</summary>
+ static string CityState(string city)
+ {
+ var towns = Towns; var cam = Camera.main;
+ var kits = Scene.transform.Find(KitLayer.RootName);
+ var kit = kits == null ? null : kits.Find(city)?.GetComponent<Renderer>();
+ var close = kits == null ? null : kits.Find(city + KitLayer.CloseSuffix)?.GetComponent<Renderer>();
+ towns.PrepareCamera(cam);
+ string Draws(Renderer? r) => r == null ? "missing" : (!r.forceRenderingOff).ToString();
+ string s = $"kit \"{city}\" draws={Draws(kit)}, \"{city}{KitLayer.CloseSuffix}\" draws={Draws(close)}, " +
+ $"models admitted={towns.AdmitsTown(city, cam)} ready={towns.ReadyForTown(city, cam)}";
+ towns.RestoreRenderers();
+ return s;
+ }
+
+ static Color[] Read(RenderTexture from)
+ {
+ var prev = RenderTexture.active;
+ RenderTexture.active = from;
+ var tex = new Texture2D(from.width, from.height, TextureFormat.RGBA32, false);
+ tex.ReadPixels(new Rect(0, 0, from.width, from.height), 0, 0);
+ tex.Apply();
+ RenderTexture.active = prev;
+ var px = tex.GetPixels();
+ Object.DestroyImmediate(tex);
+ return px;
+ }
+
+ /// <summary>CivMovementShots.Shot into this run's folder: the map camera's frame with the UI texture over it (the UI's
+ /// pixels are premultiplied by their alpha).</summary>
+ void Shot(string name)
+ {
+ int w = CivMovementShots.Width, h = CivMovementShots.Height;
+ var cam = Camera.main;
+ var frame = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);
+ var before = cam.targetTexture;
+ cam.targetTexture = frame; cam.Render(); cam.targetTexture = before;
+ var map = Read(frame); var over = Read(rt!);
+ frame.Release(); Object.DestroyImmediate(frame);
+ var outPx = new Color[map.Length];
+ for (int i = 0; i < map.Length; i++)
+ {
+ var u = over[i]; var m = map[i];
+ outPx[i] = new Color(u.r + m.r * (1f - u.a), u.g + m.g * (1f - u.a), u.b + m.b * (1f - u.a), 1f);
+ }
+ var tex = new Texture2D(w, h, TextureFormat.RGB24, false);
+ tex.SetPixels(outPx); tex.Apply();
+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());
+ Object.DestroyImmediate(tex);
+ }
+
+ static string Frame(Vector3 at)
+ {
+ var rig = Camera.main.GetComponent<CameraRig>(); var towns = Towns;
+ return FormattableString.Invariant($"look-at {at}, view {TownModelLayer.ViewDistance(Camera.main):F0} m (rig {rig.Distance:F0} m), ")
+ + FormattableString.Invariant($"layer drew {towns.LastDrawn} instances, close={towns.LastClose}, ")
+ + FormattableString.Invariant($"aspect {Camera.main.aspect:F3}, m00/m11 {Camera.main.projectionMatrix[0, 0] / Camera.main.projectionMatrix[1, 1]:F3}");
+ }
+
+ /// <summary>Sets the game's date (the state the map shows and the turn's start) and lets GameRoot redraw on it.</summary>
+ IEnumerator SetDate(DateTime date)
+ {
+ var bridge = root.Bridge!;
+ foreach (var s in new HashSet<GameState> { bridge.State, bridge.TurnStart }) s.Date = date;
+ bridge.Skip(poke--);
+ yield return Frames(3);
+ }
+
+ /// <summary>TalModelsShots.Prop's special layer: rebuilt with every model answered from the AssetDatabase, on the game's
+ /// date and its built arms workshops (as GameRoot shows it, so its next refresh keeps this layer).</summary>
+ SpecialBuildingModels Special()
+ {
+ var map = Scene; var state = root.Bridge!.State; var content = root.Bridge.Content;
+ SpecialBuildingModels.Request = (id, detail, done) => done(Prefab(id, detail));
+ var old = map.Terrain.transform.Find(SpecialBuildingModels.Name);
+ if (old != null) Object.DestroyImmediate(old.gameObject);
+ var layer = CollectionGeometryFixture.Special(map, state.Date, content, state.CityProjects.Values)!;
+ // Every placed row, and whether it stands inside one of the four cities' kit footprints.
+ foreach (var p in layer.Placed)
+ {
+ var inside = map.KitFootprints.Where(f => Cities.Contains(f.id) && Vector2.Distance(new Vector2(p.At.x, p.At.z), f.centre) < f.radius)
+ .Select(f => f.id).ToList();
+ Debug.Log(FormattableString.Invariant($"SCAN {state.Date:yyyy-MM-dd} {p.Key} ({p.Model}) at {p.At}: inside {(inside.Count == 0 ? "no major city" : string.Join(", ", inside))}"));
+ }
+ return layer;
+ }
+
+ IEnumerator Prop(SpecialBuildingModels layer, string key, string city, string name)
+ {
+ var placed = layer.Placed.Where(p => p.Key == key).ToList();
+ if (placed.Count == 0) { Debug.LogWarning($"SHOT {name}: {key} is not placed on {root.Bridge!.State.Date:yyyy-MM-dd}; no still"); yield break; }
+ var at = Ground(placed[0].At);
+ Aim(at, PropDistanceM);
+ layer.Choose(default, Camera.main);
+ yield return Settle(city);
+ var state = CityState(city);
+ Shot(name);
+ var f = Scene.KitFootprints.FirstOrDefault(x => x.id == city);
+ float fromCentre = f.id == null ? float.NaN : Vector2.Distance(new Vector2(at.x, at.z), f.centre);
+ Debug.Log(FormattableString.Invariant($"SHOT {name}: prop {key} ({placed[0].Model}) on {root.Bridge!.State.Date:yyyy-MM-dd}, ")
+ + FormattableString.Invariant($"{fromCentre:F0} m from {city}'s kit centre (radius {f.radius:F0} m), {PropDistanceM / 1000f:F0} km; {state}; {Frame(at)}")
+ + NearestBlocks(new Vector2(at.x, at.z), city));
+ }
+
+ /// <summary>#2876: a spot's box distance (m) to the nearest kit block of <paramref name="city"/> and of any other major city
+ /// (MapScene.MajorCityBlocks), for the SHOT line.</summary>
+ string NearestBlocks(Vector2 at, string city)
+ {
+ float own = float.MaxValue, other = float.MaxValue; string otherId = "none";
+ foreach (var b in Scene.MajorCityBlocks)
+ {
+ float a = b.Yaw * Mathf.Deg2Rad;
+ var q = b.C - at; float qu = q.x * Mathf.Cos(a) + q.y * Mathf.Sin(a), qv = -q.x * Mathf.Sin(a) + q.y * Mathf.Cos(a);
+ float du = Mathf.Max(0f, Mathf.Abs(qu) - 0.5f * b.W), dv = Mathf.Max(0f, Mathf.Abs(qv) - 0.5f * b.D);
+ float d = Mathf.Sqrt(du * du + dv * dv);
+ if (b.Id == city) own = Mathf.Min(own, d);
+ else if (d < other) { other = d; otherId = b.Id; }
+ }
+ return own == float.MaxValue ? "" : FormattableString.Invariant($"; nearest kit block: {city}'s {own:F0} m, {otherId}'s {other:F0} m");
+ }
+
+ [UnityTest]
+ public IEnumerator CityZooms()
+ {
+ yield return CivMovementShots.Boot(false, saveDir, (t, p, u, g) => { rt = t; ps = p; root = g; });
+ foreach (var city in Cities)
+ {
+ var at = CentreOf(city);
+ foreach (var km in DistancesKm)
+ {
+ Aim(at, km * 1000f);
+ yield return Settle(city);
+ var state = CityState(city);
+ var name = FormattableString.Invariant($"{city}-{km:0}km");
+ Shot(name);
+ Debug.Log(FormattableString.Invariant($"SHOT {name}: city {city}, {km:0} km; {state}; {Frame(at)}"));
+ }
+ }
+ }
+
+ /// <summary>The sandbags on the Altalena's turn (15 June 1948) and the crates on the opening date (15 May 1948, in 1948).</summary>
+ [UnityTest]
+ public IEnumerator Props()
+ {
+ yield return CivMovementShots.Boot(false, saveDir, (t, p, u, g) => { rt = t; ps = p; root = g; });
+ foreach (var (key, city, name, date) in new[] {
+ ("tel_aviv_altalena_sandbags", "tel_aviv", "altalena-sandbags-close", SpecialBuildingModels.SandbagsFrom),
+ ("haifa_quay_crates", "haifa", "haifa-quay-crates-close", SpecialBuildingModels.Year1948From) })
+ {
+ var want = SpecialBuildingModels.EveryPlacement.Single(w => w.Key == key);
+ Debug.Log(FormattableString.Invariant($"SHOT {name}: {key} covers {want.From:yyyy-MM-dd} to {(want.To is DateTime to ? to.ToString("yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture) : "open")}; the date set is {date:yyyy-MM-dd}"));
+ yield return SetDate(date);
+ var layer = Special();
+ yield return Prop(layer, key, city, name);
+ }
+ }
+
+ /// <summary>A gdd-0.3 game (every era's ruleset set on fresh inputs, as TalModelsShots.ArmsWorkshop boots it) with one arms
+ /// workshop built in each of the four cities on the opening date (a fixture state), each workshop's b21 from 8 km.</summary>
+ [UnityTest]
+ public IEnumerator WorkshopProps()
+ {
+ var inputs = Statecraft.Game.Boot.GameInputs.FromDisk(Paths.Content, Paths.StreamingMap);
+ foreach (var era in inputs.Content.Eras) { era.Systems.Ruleset = SaveGame.Gdd03Ruleset; era.Systems.Loop = EraSystems.Gdd; }
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var doc = Object.FindFirstObjectByType<UIDocument>();
+ rt = new RenderTexture(CivMovementShots.Width, CivMovementShots.Height, 24, RenderTextureFormat.ARGB32);
+ ps = Object.Instantiate(doc.panelSettings);
+ ps.targetTexture = rt; ps.clearColor = true; ps.colorClearValue = Color.clear;
+ doc.panelSettings = ps;
+ Scene.Build(inputs.Map);
+ root = Object.FindFirstObjectByType<GameRoot>();
+ root.Store = new SaveStore(saveDir);
+ root.Begin(inputs, 0);
+ var ui = doc.rootVisualElement;
+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;
+ yield return Frames(5);
+ GameSceneTests.HideTheOpeningCard(ui);
+ if (root.Advisor != null && root.Advisor.IsOpen) UiTestKit.Press(ui.Q<Button>("advisor-close"));
+ yield return Frames(3);
+ var state = root.Bridge!.State; var content = root.Bridge.Content;
+ Assert.AreEqual(SaveGame.Gdd03Ruleset, content.Ruleset);
+ // #2876: built three months in (an arms workshop takes three monthly turns), where every major city's edge has ground
+ // the Israeli side holds (round Jerusalem, none before the first truce, 11 June 1948).
+ yield return SetDate(WorkshopsBuilt);
+ var built = new List<(int id, string city)>();
+ foreach (var city in Cities)
+ {
+ var home = content.SettlementHexes.FirstOrDefault(h => h.Id == city);
+ if (home == null) { Debug.LogWarning($"SHOT {city}-workshop-close: {city} has no settlement hex; no workshop"); continue; }
+ int id = state.NextId++;
+ state.CityProjects.Add(id, new CityProject(id, Statecraft.Sim.Workshops.ArmsWorkshop, city, home.Q, home.R, 0, state.Date));
+ built.Add((id, city));
+ }
+ yield return SetDate(state.Date); // GameRoot redraws with the workshops first, on the same date
+ var layer = Special();
+ foreach (var (id, city) in built)
+ yield return Prop(layer, SpecialBuildingModels.WorkshopKey(id), city, $"{city}-workshop-close");
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/MajorCityShots.cs.meta b/unity/Assets/Tests/EditMode/MajorCityShots.cs.meta
new file mode 100644
index 000000000..652df60f4
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/MajorCityShots.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 67e404a4671a46b9996208a3dbfff6f1
diff --git a/unity/Assets/Tests/EditMode/MapLabelTests.cs b/unity/Assets/Tests/EditMode/MapLabelTests.cs
index 039f43476..3c37ec7f3 100644
--- a/unity/Assets/Tests/EditMode/MapLabelTests.cs
+++ b/unity/Assets/Tests/EditMode/MapLabelTests.cs
@@ -296,12 +296,13 @@ public class MapLabelTests
/// the map's names do not cover each other. With the real prefab placed and the camera at 30 km over the model (inside its
/// close zoom), no shown settlement, locality or location pill overlaps the model's projected bounds.</summary>
[UnityTest] public IEnumerator NoNamePillCoversAWorkshopModel() { yield return NoPillCovers("rehovot"); }
- /// <summary>The same among a town's houses (owner, 2 November 2026: "Among the houses"): Tel Aviv and Jerusalem.</summary>
+ /// <summary>The same at a major city's edge (owner, 6 November 2026, verbatim: "make the workshop at the edge of the city",
+ /// which replaces "Among the houses" of 2 November 2026 there): Tel Aviv and Jerusalem.</summary>
[UnityTest] public IEnumerator NoNamePillCoversAWorkshopModelInTelAviv() { yield return NoPillCovers("tel_aviv"); }
/// <summary>Jerusalem, every pill through the close zoom (15 to 45 km) but one: the "East Jerusalem / Old City"
/// location's pill is checked up to the close zoom's entry (40 km) only. At its exit (45 km, reached only on the way out)
/// that pill (263 px wide, about 7.6 km there, set above the Old City's kit) covers the b21: an open item on #2281.
- /// TownGap models the place names' bands, not a location pill at that zoom.</summary>
+ /// The plan models the place names' bands (SpecialBuildingModels.ClearOfName), not a location pill at that zoom.</summary>
[UnityTest] public IEnumerator NoNamePillCoversAWorkshopModelInJerusalem() { yield return NoPillCovers("jerusalem"); }
/// <summary>Review of #2281 on main: every city's workshop model, not only these three, clear of every name pill through the
@@ -363,7 +364,7 @@ public class MapLabelTests
for (int c = 0; c < 8; c++)
{
var corner = new Vector3((c & 1) == 0 ? b.min.x : b.max.x, (c & 2) == 0 ? b.min.y : b.max.y, (c & 4) == 0 ? b.min.z : b.max.z);
- var q = hd.ToPanel(corner, out bool front); Assert.IsTrue(front);
+ var q = hd.ToPanel(corner, out bool front); Assert.IsTrue(front, city + "'s workshop model is in front of the camera");
x0 = Mathf.Min(x0, q.x); y0 = Mathf.Min(y0, q.y); x1 = Mathf.Max(x1, q.x); y1 = Mathf.Max(y1, q.y);
}
}
@@ -391,7 +392,7 @@ public class MapLabelTests
if (pill.Overlaps(rect)) failures.Add($"{distance:0} m, {offset:0} m: {slot.name}'s pill {pill} covers the workshop model {rect}");
}
}
- Assert.IsEmpty(failures, string.Join("\n", failures));
+ Assert.IsEmpty(failures, city + ": " + string.Join("\n" + city + ": ", failures));
}
finally
{
diff --git a/unity/Assets/Tests/EditMode/SpecialBuildingModelsTests.cs b/unity/Assets/Tests/EditMode/SpecialBuildingModelsTests.cs
index 1dfe3fa5f..654f1bb01 100644
--- a/unity/Assets/Tests/EditMode/SpecialBuildingModelsTests.cs
+++ b/unity/Assets/Tests/EditMode/SpecialBuildingModelsTests.cs
@@ -441,6 +441,16 @@ namespace Statecraft.Game.Tests
Assert.AreEqual(1, g.Select(w => w.NearOnly).Distinct().Count(), g.Key + ": one near-only value for all its rows");
Assert.AreEqual(1, g.Select(w => w.Scale).Distinct().Count(), g.Key + ": one scale for all its rows");
}
+ // #2876: b21's rows are built per city project (ArmsWorkshops, not in EveryPlacement): one near-only value and one
+ // scale for all of them, in ordinary towns and major cities alike, and the scale ScaleOf(Workshop) reads, 2.5 (the
+ // owner, 6 November 2026: "the workshop should be bigger as it's barely visible"; 2.5x chosen with "do it").
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var towns = new[] { "rehovot", "hadera", "tel_aviv", "jerusalem" };
+ var workshops = SpecialBuildingModels.ArmsWorkshops(c, towns.Select((city, i) => Workshop(c, 30 + i, city, Built)));
+ CollectionAssert.AreEqual(towns, workshops.Select(w => w.City).ToArray(), "premise: a b21 row for each built workshop");
+ Assert.AreEqual(1, workshops.Select(w => w.NearOnly).Distinct().Count(), SpecialBuildingModels.Workshop + ": one near-only value for all its rows");
+ CollectionAssert.AreEqual(new[] { 2.5f }, workshops.Select(w => w.Scale).Distinct().ToArray(), SpecialBuildingModels.Workshop + ": one scale for all its rows, 2.5");
+ Assert.AreEqual(2.5f, SpecialBuildingModels.ScaleOf(SpecialBuildingModels.Workshop), SpecialBuildingModels.Workshop + ": ScaleOf by model name reads the rows' scale");
}
/// <summary>The residency anchors' radius (FillResidencyAnchors, the row's own ClearanceOf(w), from #2274) is the radius
@@ -508,6 +518,24 @@ namespace Statecraft.Game.Tests
Assert.AreEqual(SpecialBuildingModels.RealLengthM(w.Model) * SpecialBuildingModels.WorldScale * w.Scale, SpecialBuildingModels.SizeOf(w.Model), 0.01f, w.Key);
}
Assert.AreEqual(3.75f * 24f * 3f, SpecialBuildingModels.SizeOf(SpecialBuildingModels.Well), 0.01f, "the well, 270 m across");
+ // #2876, the owner, 6 November 2026 (verbatim): "the workshop should be bigger as it's barely visible"; 2.5x (720 m)
+ // chosen with "do it". b21's rows are built per city project (ArmsWorkshops, not in EveryPlacement): in an ordinary
+ // town and in a major city alike at 2.5 times the world scale, not at a town's edge, its size by row and by model
+ // name the same.
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var workshops = SpecialBuildingModels.ArmsWorkshops(c, new[] { Workshop(c, 31, "rehovot", Built), Workshop(c, 32, "tel_aviv", Built) });
+ Assert.AreEqual(2, workshops.Count, "premise: a b21 row in rehovot and in tel_aviv");
+ foreach (var w in workshops)
+ {
+ string who = w.Key + " (" + w.City + ")";
+ Assert.AreEqual(2.5f, w.Scale, who + "'s scale");
+ Assert.IsFalse(w.TownEdge, who + " does not stand at a town's edge as a prop does");
+ Assert.AreEqual(SpecialBuildingModels.RealLengthM(w.Model) * SpecialBuildingModels.WorldScale * 2.5f, SpecialBuildingModels.SizeOf(w), 0.01f, who + " by row");
+ Assert.AreEqual(SpecialBuildingModels.SizeOf(w), SpecialBuildingModels.SizeOf(w.Model), 0.01f, who + ": by row and by model name agree");
+ Assert.AreEqual(SpecialBuildingModels.ClearanceOf(w), SpecialBuildingModels.ClearanceOf(w.Model), 0.01f, who + ": its clearance by row and by model name agree");
+ }
+ Assert.AreEqual(12f * 24f * 2.5f, SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop), 0.01f, "the b21, 720 m long");
+ Assert.AreEqual(0.71f * 720f, SpecialBuildingModels.ClearanceOf(SpecialBuildingModels.Workshop), 0.01f, "the b21's clearance, about 511 m");
var map = OpenMap();
var layer = CollectionGeometryFixture.Special(map, new DateTime(1948, 6, 15))!; AnswerAll();
foreach (var key in props)
@@ -528,12 +556,17 @@ namespace Statecraft.Game.Tests
var flat = new Vector2(p.At.x, p.At.z); float r = SpecialBuildingModels.ClearanceOf(p.Model);
var ground = PlacementLayer.CampGround(map);
// The owner, 2 November 2026, on #2274: "Bigger, closer (Recommended)" ("let them stand at the town's edge right by the
- // sourced spot"): the four props may stand inside a town's kit footprint, but clear of its building models, of the
- // unit tokens standing in towns and of every settlement's and locality's name point.
+ // sourced spot"): the four props may stand inside a town's kit footprint, but clear of its drawn buildings (its building
+ // models, a major city's included, which it draws below the close switch: owner, 7 November 2026, "Tal's models close
+ // (Recommended)"; and a major city's kit blocks, which it draws from 40 km out: #2876), of the unit tokens standing in
+ // towns and of every settlement's and locality's name point.
var towns = map.GetComponentInChildren<Statecraft.Game.Map.Kits.TownModelLayer>(true);
Assert.IsNotNull(towns, "the town building models");
- var buildings = map.KitFootprints.SelectMany(f => towns.InstancesOf(f.id)).Select(i => (i.C, 0.5f * new Vector2(i.W, i.D).magnitude)).ToList();
- Assert.IsTrue(TownLandmarks.Clear(flat, r, buildings), key + " clear of the towns' buildings");
+ var buildings = map.KitFootprints.SelectMany(f => towns.InstancesOf(f.id))
+ .Select(i => (i.C, 0.5f * new Vector2(i.W, i.D).magnitude)).ToList();
+ Assert.IsTrue(TownLandmarks.Clear(flat, r, buildings), key + " clear of the towns' building models, the major cities' included");
+ foreach (var block in map.MajorCityBlocks)
+ Assert.IsTrue(SpecialBuildingModels.ClearOfBox(flat, r, block.C, block.Yaw, block.W, block.D), $"{key} clear of {block.Id}'s kit {block.Kind} at {block.C}");
Assert.IsTrue(TownLandmarks.Clear(flat, r, map.UnitClearings.ToList()), key + " clear of the tokens in the towns");
foreach (var s in map.Settlements.Concat(map.Localities.Select(l => l.Settlement)))
{
@@ -972,17 +1005,32 @@ namespace Statecraft.Game.Tests
Assert.IsEmpty(SpecialBuildingModels.ArmsWorkshops(Rules(Statecraft.Sim.SaveGame.GddRuleset), projects), "never under gdd-0.1");
}
- /// <summary>A built arms workshop on each city's own hex (the hardest ground: the town's footprint is there): every one
+ /// <summary>Every place a player can build an arms workshop in under gdd-0.3 (CityBuilt): the cities of cities.yaml
+ /// (Cities.Init fills GameState.Cities from them) and each settlement target whose residents stayed, which annexing makes
+ /// a city (Cities.Annex, R-CTRL-016; a fled one adds no city). Projects.CheckCityReason takes any of the state's cities
+ /// (the arms workshop needs no resource), so these are all of them: the cities in id order, then the annexed towns in id
+ /// order (so the cities' projects, and their keys, are those the test built before the annexed towns joined it).</summary>
+ static List<string> CityBuilt(Statecraft.Sim.Content c) =>
+ c.Cities.Select(x => x.Id).OrderBy(x => x, StringComparer.Ordinal)
+ .Concat(c.SettlementTargets.Where(t => t.Residents == Statecraft.Sim.ContentLoader.Stayed).Select(t => t.Id).OrderBy(x => x, StringComparer.Ordinal))
+ .Distinct().ToList();
+
+ /// <summary>A built arms workshop on the own hex of each place a player can build one in (<see cref="CityBuilt"/>; the
+ /// hardest ground: the town's footprint is there): every one
/// but those of the two cities whose footprint covers the whole hex gets its b21, wholly on that hex, clear of the towns' footprints (and so their labels), the routes, the unit tokens,
/// the civilians, the wildlife, the farm scenes and every other building model, upright, on the ground, hidden until the
- /// close zoom, and on the same spot when placed again.</summary>
+ /// close zoom, and on the same spot when placed again. A major city's (TownModels.IsMajorCity) stands at the city's edge
+ /// instead (owner, 6 November 2026: "make the workshop at the edge of the city"; <see cref="AtTheCitysEdge"/>), and so does
+ /// another town's whose hex leaves it no spot (#2876: SpecialBuildingModels.TownEdgeSpot; <see cref="AtTheTownsEdge"/>),
+ /// in the camera's sight past every major city's kit blocks; the run lists those towns ("fallback towns").</summary>
[Test]
public void OnTheMapEachBuiltWorkshopStandsOnItsHexClearAndUpright()
{
var map = OpenMap();
var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
- var cities = c.Cities.Select(x => x.Id).OrderBy(x => x, StringComparer.Ordinal).ToList();
- Assert.Greater(cities.Count, 5);
+ var cities = CityBuilt(c);
+ Assert.Greater(cities.Count, c.Cities.Count, "premise: an annexed town (a target whose residents stayed) is a city too");
+ TestContext.WriteLine($"the places a player can build an arms workshop in: {cities.Count} ({string.Join(", ", cities)})");
var projects = cities.Select((city, i) => Workshop(c, 100 + i, city, Built)).ToList();
var savedPeople = CivilianPeople.Request; var savedRural = RuralLife.Request;
CivilianPeople.Request = (id, detail, done) => { };
@@ -1000,7 +1048,14 @@ namespace Statecraft.Game.Tests
.Concat(rural.Placed.Select(p => (new Vector2(p.At.x, p.At.z), RuralLife.SceneRadiusM(p.Model)))).ToList();
var layer = CollectionGeometryFixture.Special(map, After, c, projects)!;
Assert.AreEqual(1, asked.Count(a => a.id == SpecialBuildingModels.Workshop), "b21 is asked for once, whatever the number of workshops");
+ var streets = Streets(map, c, projects, out var edged);
AnswerAll();
+ // #2876 (coordinator, 6 November 2026): the towns whose own hex leaves the b21 at 2.5x no spot, so that it stands at
+ // the town's edge instead (SpecialBuildingModels.TownEdgeSpot). Not a fixed count: it is what the map leaves.
+ var fallback = projects.Where(p => edged.Contains(SpecialBuildingModels.WorkshopKey(p.Id))).Select(p => p.City).ToList();
+ TestContext.WriteLine($"fallback towns: {fallback.Count} ({string.Join(", ", fallback)})");
+ CollectionAssert.IsEmpty(fallback.Where(Statecraft.Game.Map.Kits.TownModels.IsMajorCity).ToList(),
+ "a major city's b21 stands at its edge by its own search (EdgeSpot), never by the town fallback");
var footprints = map.KitFootprints.Select(f => (f.centre, f.radius)).ToList();
float r0 = SpecialBuildingModels.ClearanceOf(SpecialBuildingModels.Workshop);
// A town whose footprint covers its own hex (Jerusalem and Tel Aviv today: footprints of several hexes,
@@ -1016,59 +1071,256 @@ namespace Statecraft.Game.Tests
}
CollectionAssert.AreEquivalent(new[] { "jerusalem", "tel_aviv" }, covered, "the cities whose footprint covers their own hex");
var keys = projects.Select(p => SpecialBuildingModels.WorkshopKey(p.Id)).ToList();
- CollectionAssert.IsSubsetOf(keys, layer.Placed.Select(p => p.Key), "a b21 at every built workshop");
+ // #2876: each town named on a loss (the b21 at 2.5x keeps a wider clearance, so a crowded town may lose its spot).
+ var lost = projects.Where(p => !layer.Placed.Any(x => x.Key == SpecialBuildingModels.WorkshopKey(p.Id))).Select(p => p.City).ToList();
+ Assert.IsEmpty(lost, "a b21 at every built workshop; none in: " + string.Join(", ", lost));
Assert.AreEqual(keys.Count, layer.Placed.Count(p => p.Model == SpecialBuildingModels.Workshop), "exactly one b21 per built workshop");
var ground = PlacementLayer.CampGround(map);
+ var tops = BlockTops(map, ground); var toCamera = ToCamera();
var others = layer.Placed.Where(p => !keys.Contains(p.Key)).Select(p => (new Vector2(p.At.x, p.At.z), SpecialBuildingModels.ClearanceOf(p.Model))).ToList();
var spots = new List<(Vector2, float)>();
var prefab = AssetDatabase.LoadAssetAtPath<GameObject>(CollectionCatalog.PrefabPath(SpecialBuildingModels.Workshop, CollectionDetail.Near));
foreach (var project in projects)
{
- var key = SpecialBuildingModels.WorkshopKey(project.Id);
+ var key = SpecialBuildingModels.WorkshopKey(project.Id); string who = key + " (" + project.City + ")";
var p = layer.Placed.Single(x => x.Key == key);
- Assert.AreEqual(SpecialBuildingModels.Workshop, p.Model);
+ Assert.AreEqual(SpecialBuildingModels.Workshop, p.Model, who);
var hex = c.HexAt(project.Q, project.R)!; var centre3 = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
var flat = new Vector2(p.At.x, p.At.z); float r = SpecialBuildingModels.ClearanceOf(p.Model);
float off = (flat - new Vector2(centre3.x, centre3.z)).magnitude;
TestContext.WriteLine($"{key} ({project.City}): {off:0} m from its hex centre, clearance {r:0} m");
- Assert.LessOrEqual(off + r, SpecialBuildingModels.HexInnerRadiusM, key + " wholly on its project's hex");
- if (covered.Contains(project.City))
- AmongTheHouses(map, key, flat, r);
- else Assert.IsTrue(TownLandmarks.Clear(flat, r, footprints), key + " clear of the towns (and their labels)");
- Assert.IsFalse(ground.OnRoute(flat, r), key + " clear of the routes");
- Assert.IsFalse(ground.OnToken(flat, r, After), key + " clear of the unit tokens");
- Assert.IsTrue(TownLandmarks.Clear(flat, r, others), key + " clear of the sourced building models");
- Assert.IsTrue(TownLandmarks.Clear(flat, r, spots), key + " clear of the other workshops");
- Assert.IsTrue(TownLandmarks.Clear(flat, r, props), key + " clear of the civilians, the wildlife and the farm scenes");
+ // The owner, 6 November 2026 (verbatim): "make the workshop at the edge of the city": a major city's b21 stands at
+ // its edge, off its project's hex where no edge spot is on it; every other city's wholly on its hex, as before.
+ if (Statecraft.Game.Map.Kits.TownModels.IsMajorCity(project.City))
+ {
+ var edge = new List<string>();
+ AtTheCitysEdge(map, project.City, key, flat, r, edge, Built, (project.Q, project.R));
+ Assert.IsEmpty(edge, string.Join("\n", edge));
+ }
+ else if (edged.Contains(key))
+ {
+ // #2876: its hex left it no spot, so it stands at the edge of the town's drawn buildings, off its hex if
+ // need be, in the camera's sight past every major city's kit blocks.
+ Assert.IsFalse(covered.Contains(project.City), who + ": a covered town stands among its houses, not at its edge");
+ var edge = new List<string>();
+ AtTheTownsEdge(map, project.City, key, flat, r, edge, Built, (project.Q, project.R));
+ Assert.IsEmpty(edge, string.Join("\n", edge));
+ var model = layer.transform.Find(key)!;
+ var top = model.GetComponentsInChildren<Renderer>(true).Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; }).max.y;
+ var (hiddenTop, firstHidden) = HiddenOnTop(map, tops, flat, 0f, SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop), top, toCamera);
+ Assert.AreEqual(0, hiddenTop, $"{who}: {hiddenTop} of 25 points on its top are hidden from the camera; first: {firstHidden}");
+ }
+ else
+ {
+ Assert.LessOrEqual(off + r, SpecialBuildingModels.HexInnerRadiusM, who + " wholly on its project's hex");
+ if (covered.Contains(project.City))
+ AmongTheHouses(map, key, flat, r, streets);
+ else Assert.IsTrue(TownLandmarks.Clear(flat, r, footprints), who + " clear of the towns (and their labels)");
+ }
+ Assert.IsFalse(ground.OnRoute(flat, r), who + " clear of the routes");
+ Assert.IsFalse(ground.OnToken(flat, r, After), who + " clear of the unit tokens");
+ Assert.IsTrue(TownLandmarks.Clear(flat, r, others), who + " clear of the sourced building models");
+ Assert.IsTrue(TownLandmarks.Clear(flat, r, spots), who + " clear of the other workshops");
+ Assert.IsTrue(TownLandmarks.Clear(flat, r, props), who + " clear of the civilians, the wildlife and the farm scenes");
spots.Add((flat, r));
var go = layer.transform.Find(key)!;
- Assert.Less(Quaternion.Angle(prefab.transform.localRotation, go.localRotation), 0.01f, key + " keeps the FBX axis conversion");
+ if (streets.ContainsKey(key))
+ {
+ // On a street between a major city's kit blocks (#2876): turned about the vertical only, along the street.
+ var turn = go.localRotation * Quaternion.Inverse(prefab.transform.localRotation);
+ Assert.Greater(Vector3.Dot(turn * Vector3.up, Vector3.up), 0.9999f, who + " upright: turned only about the vertical");
+ }
+ else Assert.Less(Quaternion.Angle(prefab.transform.localRotation, go.localRotation), 0.01f, who + " keeps the FBX axis conversion");
var rs = go.GetComponentsInChildren<Renderer>(true);
var b = rs.Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; });
- Assert.AreEqual(p.At.y, b.min.y, 1f, key + " stands on the ground");
- Assert.Less(b.size.y, Mathf.Max(b.size.x, b.size.z), key + " upright: lower than it is long");
- Assert.AreEqual(SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop), Mathf.Max(b.size.x, b.size.z), 1f, key + " at the buildings' one world scale");
- Assert.IsTrue(rs.All(x => x.forceRenderingOff), key + " hidden until the close zoom");
+ Assert.AreEqual(p.At.y, b.min.y, 1f, who + " stands on the ground");
+ Assert.Less(b.size.y, Mathf.Max(b.size.x, b.size.z), who + " upright: lower than it is long");
+ // The size is the model's own: a street workshop's world-axis bounds also take in its turn along the street
+ // (#2876), so it is measured with that turn taken off for a moment (the FBX axis conversion alone), then put back.
+ var sized = b;
+ if (streets.ContainsKey(key))
+ {
+ var along = go.localRotation;
+ go.localRotation = prefab.transform.localRotation;
+ sized = rs.Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; });
+ go.localRotation = along;
+ }
+ // #2876, the owner, 6 November 2026 (verbatim): "the workshop should be bigger as it's barely visible"; the owner then
+ // chose 2.5x (720 m) on the coordinator's recommendation ("do it"). This assert moved on purpose, from the buildings'
+ // one world scale (12 m x 24 = 288 m) to 2.5 times it.
+ Assert.AreEqual(SpecialBuildingModels.RealLengthM(SpecialBuildingModels.Workshop) * SpecialBuildingModels.WorldScale * 2.5f, Mathf.Max(sized.size.x, sized.size.z), 1f,
+ who + " at 2.5 times the buildings' one world scale, 720 m (owner, 6 November 2026: \"the workshop should be bigger as it's barely visible\")");
+ Assert.IsTrue(rs.All(x => x.forceRenderingOff), who + " hidden until the close zoom");
}
// Deterministic: a second layer from nothing puts every workshop on the same spot.
var first = layer.Placed.Where(p => keys.Contains(p.Key)).ToDictionary(p => p.Key, p => p.At);
UnityEngine.Object.DestroyImmediate(layer.gameObject);
var again = CollectionGeometryFixture.Special(map, After, c, cities.Select((city, i) => Workshop(c, 100 + i, city, Built)).ToList())!;
AnswerAll();
- foreach (var key in keys) Assert.AreEqual(first[key], again.Placed.Single(p => p.Key == key).At, key + " on the same spot again");
+ foreach (var project in projects)
+ {
+ var key = SpecialBuildingModels.WorkshopKey(project.Id);
+ Assert.AreEqual(first[key], again.Placed.Single(p => p.Key == key).At, key + " (" + project.City + ") on the same spot again");
+ }
+ }
+
+ /// <summary>#2876, the owner, 7 November 2026, on Hadera: "Move the workshop (Recommended)": Hadera's arms workshop moves
+ /// to a clear spot at the town's edge, and the palms stay. With a workshop built in every place a player can build one in
+ /// (<see cref="CityBuilt"/>), placed as the layer places them (the civilians and the farm scenes first, as
+ /// <see cref="OnTheMapEachBuiltWorkshopStandsOnItsHexClearAndUpright"/>), each b21 of a town that is not a major city
+ /// stands off the beach; Hadera's stands at its town's edge (SpecialBuildingModels.TownEdgeSpot) and (no open sea, KitGround.SeaDistance, within the drawn full sand, BeachBands.FullSandAt, plus its
+ /// clearance) with no kit tree as planted (VegetationLayer.Planted) in front of it: no crown outside its clearance disc
+ /// reaches its sight lane toward the camera (south: across its clearance, as far as the ray from its foot at the view's
+ /// shallowest depression, SpecialBuildingModels.SightTan, passes over the tree's top). Another town's b21 keeps the spot
+ /// it had (only a hex spot on the beach sends a b21 to its town's edge): its trees in front are logged, not failed. The trees whose crowns reach its
+ /// disc are counted, not failed: they are left out under it, as under every building (VegetationLayer.Hide, #249). A
+ /// major city's b21 is listed too (its lane's trees are left out by design, VegetationLayer.Hide). Each b21's spot, its distance to the sea and the nearest tree crown, and the trees under it and
+ /// in front of it, are logged as a WORKSHOPSITE line.</summary>
+ [Test]
+ public void EveryTownsWorkshopStandsOffTheBeachWithNoTreeInFront()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var cities = CityBuilt(c);
+ var projects = cities.Select((city, i) => Workshop(c, 100 + i, city, Built)).ToList();
+ var savedPeople = CivilianPeople.Request; var savedRural = RuralLife.Request;
+ CivilianPeople.Request = (id, detail, done) => { };
+ RuralLife.Request = (id, detail, done) => done(AssetDatabase.LoadAssetAtPath<GameObject>(CollectionCatalog.PrefabPath(id, detail)));
+ try
+ {
+ CollectionGeometryFixture.People(map, After, Array.Empty<Statecraft.Sim.Placement>(), c);
+ CollectionGeometryFixture.Rural(map);
+ }
+ finally { CivilianPeople.Request = savedPeople; RuralLife.Request = savedRural; }
+ var layer = CollectionGeometryFixture.Special(map, After, c, projects)!;
+ Streets(map, c, projects, out var edged);
+ AnswerAll();
+ var ground = PlacementLayer.CampGround(map);
+ var veg = map.GetComponentInChildren<Statecraft.Game.Map.Kits.VegetationLayer>(true);
+ Assert.IsNotNull(veg, "the kit trees");
+ var tops = new Dictionary<Statecraft.Game.Map.Kits.TreeKind, float>();
+ foreach (Statecraft.Game.Map.Kits.TreeKind k in Enum.GetValues(typeof(Statecraft.Game.Map.Kits.TreeKind)))
+ {
+ var mesh = Statecraft.Game.Map.Kits.Vegetation.BuildMesh(k); tops[k] = mesh.bounds.max.y; UnityEngine.Object.DestroyImmediate(mesh);
+ }
+ var trees = veg!.Planted().Select(t => (kind: t.kind, at: new Vector2(t.m.m03, t.m.m23),
+ crown: Statecraft.Game.Map.Kits.VegetationLayer.CrownRadius(t.kind, t.m), top: t.m.m13 + tops[t.kind] * ((Vector3)t.m.GetColumn(1)).magnitude)).ToList();
+ Assert.Greater(trees.Count, 0, "the kit trees as planted");
+ var sand = Statecraft.Game.Map.Kits.BeachBands.Reaches(map.Settlements.Concat(map.Localities.Select(l => l.Settlement)).ToList(), ground);
+ float tan = SpecialBuildingModels.SightTan;
+ var failures = new List<string>();
+ int ordinary = 0;
+ foreach (var project in projects)
+ {
+ var key = SpecialBuildingModels.WorkshopKey(project.Id);
+ var placed = layer.Placed.Where(x => x.Key == key).ToList();
+ if (placed.Count == 0) { failures.Add($"{project.City}: {key} not placed"); continue; }
+ var flat = new Vector2(placed[0].At.x, placed[0].At.z); float r = SpecialBuildingModels.ClearanceOf(SpecialBuildingModels.Workshop);
+ float baseY = ground.Y(flat.x, flat.y);
+ float full = Statecraft.Game.Map.Kits.BeachBands.FullSandAt(map.Frame, flat.x, flat.y, sand);
+ bool onBeach = ground.SeaDistance(flat.x, flat.y, full + r) != float.MaxValue;
+ float sea = ground.SeaDistance(flat.x, flat.y, 8000f);
+ int under = 0, front = 0; float nearest = float.MaxValue;
+ foreach (var t in trees)
+ {
+ float d = (t.at - flat).magnitude;
+ if (d - t.crown - r > 3000f) continue;
+ nearest = Mathf.Min(nearest, d - t.crown - r);
+ if (d < r + t.crown) { under++; continue; }
+ if (Mathf.Abs(t.at.x - flat.x) < r + t.crown && t.at.y - t.crown < flat.y + r && (flat.y - r - t.at.y) - t.crown < (t.top - baseY) / tan) front++;
+ }
+ var fp = map.KitFootprints.FirstOrDefault(f => f.id == project.City);
+ float fromTown = fp.id == null ? float.NaN : (flat - fp.centre).magnitude;
+ bool major = Statecraft.Game.Map.Kits.TownModels.IsMajorCity(project.City);
+ TestContext.WriteLine(FormattableString.Invariant(
+ $"WORKSHOPSITE {project.City} {key}: at ({flat.x:0}, {flat.y:0}), {fromTown:0} m from its kit centre (radius {fp.radius:0} m){(edged.Contains(key) ? ", at its town's edge" : "")}{(major ? ", major city" : "")}; sea {(sea == float.MaxValue ? "over 8000" : sea.ToString("0", System.Globalization.CultureInfo.InvariantCulture))} m, full sand {full:0} m, on the beach {onBeach}; nearest tree crown {(nearest == float.MaxValue ? "over 3000" : nearest.ToString("0", System.Globalization.CultureInfo.InvariantCulture))} m past its disc, {under} under its disc, {front} in its sight lane"));
+ if (major) continue;
+ ordinary++;
+ if (onBeach) failures.Add($"{project.City}: {key} stands on the beach (sea within its full sand {full:0} m plus {r:0} m)");
+ if (project.City == "hadera")
+ {
+ if (front > 0) failures.Add($"{project.City}: {key} has {front} kit trees in front of it, in its sight lane");
+ if (!edged.Contains(key)) failures.Add($"{project.City}: {key} is not at its town's edge");
+ }
+ else if (front > 0) TestContext.WriteLine($"WORKSHOPSITE {project.City}: {front} kit trees in front of its b21");
+ }
+ Assert.Greater(ordinary, 10, "the ordinary towns with a b21");
+ Assert.IsEmpty(failures, string.Join("\n", failures));
}
- /// <summary>Owner, 2 November 2026 ("Among the houses"): a b21 on a hex a town's footprint covers overlaps none of the town
- /// layer's drawn buildings, whatever they are (read from the layer, not listed here). The names' pills are checked on
- /// screen by MapLabelTests.NoNamePillCoversAWorkshopModelInTelAviv and ...InJerusalem.</summary>
- static void AmongTheHouses(MapScene map, string key, Vector2 flat, float r)
+ /// <summary>#2876 (coordinator, 6 November 2026): the town's-edge fallback (SpecialBuildingModels.TownEdgeSpot) runs only
+ /// for a workshop whose hex has no spot, so it moves nothing else: with a workshop built in every place a player can build
+ /// one in (<see cref="CityBuilt"/>), the plan with the fallback is the plan without it (every row's spot and street the
+ /// same), plus the fallback towns' b21s, each of a town that is not a major city and that got no spot without it.</summary>
+ [Test]
+ public void TheTownEdgeFallbackMovesNoOtherSpot()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var projects = CityBuilt(c).Select((city, i) => Workshop(c, 100 + i, city, Built)).ToList();
+ var cityOf = projects.ToDictionary(p => SpecialBuildingModels.WorkshopKey(p.Id), p => p.City);
+ var wants = SpecialBuildingModels.Placements(After).Concat(SpecialBuildingModels.ArmsWorkshops(c, projects)).ToList();
+ var planned = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out var along, out var edged)
+ .ToDictionary(x => x.want.Key, x => x.at);
+ Dictionary<string, Vector2> without; IReadOnlyDictionary<string, Vector2> alongWithout;
+ try
+ {
+ SpecialBuildingModels.TownEdgeFallback = false;
+ without = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out alongWithout, out var none)
+ .ToDictionary(x => x.want.Key, x => x.at);
+ CollectionAssert.IsEmpty(none, "no town's edge without the fallback");
+ }
+ finally { SpecialBuildingModels.TownEdgeFallback = true; }
+ TestContext.WriteLine($"fallback towns: {edged.Count} ({string.Join(", ", edged.Select(k => cityOf[k]))})");
+ foreach (var k in edged)
+ {
+ Assert.IsTrue(cityOf.ContainsKey(k), k + " is a workshop");
+ Assert.IsFalse(Statecraft.Game.Map.Kits.TownModels.IsMajorCity(cityOf[k]), k + " (" + cityOf[k] + ") is not a major city's");
+ Assert.IsFalse(without.ContainsKey(k), k + " (" + cityOf[k] + ") had no spot without the fallback");
+ }
+ CollectionAssert.AreEquivalent(without.Keys.Concat(edged).ToList(), planned.Keys.ToList(), "the fallback adds only the fallback towns' b21s");
+ foreach (var kv in without)
+ Assert.AreEqual(kv.Value, planned[kv.Key], kv.Key + (cityOf.TryGetValue(kv.Key, out var city) ? " (" + city + ")" : "") + " on the same spot with the fallback");
+ CollectionAssert.AreEquivalent(alongWithout.OrderBy(x => x.Key, StringComparer.Ordinal).ToList(), along.OrderBy(x => x.Key, StringComparer.Ordinal).ToList(),
+ "the same streets and roads with the fallback");
+ }
+
+ /// <summary>The street direction the plan gives each workshop that stands on a street between a major city's kit blocks
+ /// (#2876; SpecialBuildingModels.PlanWithRoutes, the plan the layer draws), by key, and in <paramref name="atTownEdge"/>
+ /// the keys of the workshops it stands at their town's edge because their hex had no spot (TownEdgeSpot, #2876).</summary>
+ static IReadOnlyDictionary<string, Vector2> Streets(MapScene map, Statecraft.Sim.Content c, IEnumerable<Statecraft.Sim.CityProject> projects,
+ out IReadOnlyList<string> atTownEdge)
+ {
+ var wants = SpecialBuildingModels.Placements(After).Concat(SpecialBuildingModels.ArmsWorkshops(c, projects)).ToList();
+ SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out var along, out atTownEdge);
+ return wants.Where(w => w.Model == SpecialBuildingModels.Workshop && along.ContainsKey(w.Key)).ToDictionary(w => w.Key, w => along[w.Key]);
+ }
+
+ /// <summary>Owner, 2 November 2026 ("Among the houses"): a b21 on a hex a town's footprint covers overlaps none of the
+ /// drawn buildings, whatever they are (read from the map, not listed here): the town layer's models, a major city's
+ /// included (drawn below the close switch: owner, 7 November 2026, "Tal's models close (Recommended)"), and a major
+ /// city's kit blocks, which it draws from 40 km out (#2876). A b21 on a street between kit blocks
+ /// (<paramref name="streets"/>) is checked as its square along the street, SizeOf a side, against the blocks and the kit
+ /// landmarks; else as its clearance disc. The names' pills are checked on screen by
+ /// MapLabelTests.NoNamePillCoversAWorkshopModelInTelAviv and ...InJerusalem.</summary>
+ static void AmongTheHouses(MapScene map, string key, Vector2 flat, float r, IReadOnlyDictionary<string, Vector2> streets)
{
var layer = map.GetComponentInChildren<Statecraft.Game.Map.Kits.TownModelLayer>(true);
Assert.IsNotNull(layer, "the town layer");
+ bool street = streets.TryGetValue(key, out var dir);
+ float yaw = street ? Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg : 0f, size = SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop);
+ bool Clear(Vector2 c, float boxYaw, float w, float d) =>
+ street ? BoxesApart(flat, yaw, size, size, c, boxYaw, w, d) : SpecialBuildingModels.ClearOfBox(flat, r, c, boxYaw, w, d);
int n = 0;
+ foreach (var b in map.MajorCityBlocks)
+ {
+ if ((b.C - flat).magnitude > SpecialBuildingModels.HexInnerRadiusM + 0.5f * (b.W + b.D)) continue;
+ n++;
+ Assert.IsTrue(Clear(b.C, b.Yaw, b.W, b.D), $"{key} overlaps {b.Id}'s kit {b.Kind} at {b.C}");
+ }
foreach (var f in map.KitFootprints)
{
- foreach (var b in layer!.InstancesOf(f.id))
+ foreach (var b in layer!.InstancesOf(f.id)) // a major city's too: drawn below the close switch ("Tal's models close (Recommended)")
{
n++;
// The building's footprint, a W x D rectangle turned by its yaw: its nearest point to the model's centre.
@@ -1086,20 +1338,21 @@ namespace Statecraft.Game.Tests
{
if ((l.C - flat).magnitude > SpecialBuildingModels.HexInnerRadiusM + 0.5f * (l.W + l.D)) continue;
m++;
- Assert.IsTrue(SpecialBuildingModels.ClearOfBox(flat, r, l.C, l.Yaw, l.W, l.D), $"{key} stands on {l.Id}'s {l.Kind} at {l.C}");
+ Assert.IsTrue(Clear(l.C, l.Yaw, l.W, l.D), $"{key} stands on {l.Id}'s {l.Kind} at {l.C}");
}
foreach (var part in stats.LandmarkParts)
- Assert.IsTrue(SpecialBuildingModels.ClearOfBox(flat, r, new Vector2(part.Near.center.x, part.Near.center.z), 0f, part.Near.size.x, part.Near.size.z),
+ Assert.IsTrue(Clear(new Vector2(part.Near.center.x, part.Near.center.z), 0f, part.Near.size.x, part.Near.size.z),
$"{key} stands on {part.Owner}'s {part.Kind}");
- TestContext.WriteLine($"{key}: clear of {n} drawn buildings and {m} kit landmarks near it");
+ TestContext.WriteLine($"{key}: clear of {n} drawn buildings and {m} kit landmarks near it{(street ? $" (on a street at {yaw:0} deg)" : "")}");
Assert.Greater(m, 0, key + ": the kits drew landmarks near it to keep clear of");
}
- /// <summary>Owner, 2 November 2026 ("Among the houses"): a workshop built on Jerusalem's or Tel Aviv's own hex, which the
- /// town's footprint covers, gets its b21 in a gap between the town's drawn buildings, wholly on the hex, clear of the
- /// routes and the tokens, upright, and on the same spot when placed again.</summary>
+ /// <summary>A workshop built on Jerusalem's or Tel Aviv's own hex, which the town's footprint covers, gets its b21 at the
+ /// city's edge (owner, 6 November 2026, verbatim: "make the workshop at the edge of the city", which replaces "Among the
+ /// houses" of 2 November 2026 for the major cities; <see cref="AtTheCitysEdge"/>), outside the Old City's walls, clear of
+ /// the routes and the tokens, upright, and on the same spot when placed again; one plan with both stays under 50 ms.</summary>
[Test]
- public void AWorkshopInJerusalemOrTelAvivStandsAmongTheHouses()
+ public void AWorkshopInJerusalemOrTelAvivStandsAtTheCitysEdge()
{
var map = OpenMap();
var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
@@ -1110,33 +1363,38 @@ namespace Statecraft.Game.Tests
var first = new Dictionary<string, Vector3>();
foreach (var project in projects)
{
- string key = SpecialBuildingModels.WorkshopKey(project.Id);
+ string key = SpecialBuildingModels.WorkshopKey(project.Id), who = key + " (" + project.City + ")";
CollectionAssert.Contains(layer.Placed.Select(p => p.Key), key, project.City + " gets its b21");
var p = layer.Placed.Single(x => x.Key == key); first[key] = p.At;
var hex = c.HexAt(project.Q, project.R)!; var centre3 = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
var flat = new Vector2(p.At.x, p.At.z); float r = SpecialBuildingModels.ClearanceOf(p.Model);
float off = (flat - new Vector2(centre3.x, centre3.z)).magnitude;
TestContext.WriteLine($"{key} ({project.City}): {off:0} m from its hex centre");
- Assert.LessOrEqual(off + r, SpecialBuildingModels.HexInnerRadiusM, key + " wholly on its hex");
- AmongTheHouses(map, key, flat, r);
+ var edge = new List<string>();
+ AtTheCitysEdge(map, project.City, key, flat, r, edge, Built, (project.Q, project.R));
+ Assert.IsEmpty(edge, string.Join("\n", edge));
if (project.City == "jerusalem")
{
var (oc, half) = Statecraft.Game.Map.Kits.SettlementKits.OldCityWalls(map.Frame);
var d = flat - oc;
TestContext.WriteLine($"{key}: {d.x:0} m east and {d.y:0} m north of the Old City's centre (walls' half side {half:0} m)");
- Assert.IsTrue(Mathf.Abs(d.x) >= half + r || Mathf.Abs(d.y) >= half + r, key + " outside the Old City's walls");
+ Assert.IsTrue(Mathf.Abs(d.x) >= half + r || Mathf.Abs(d.y) >= half + r, who + " outside the Old City's walls");
}
- Assert.IsFalse(ground.OnRoute(flat, r), key + " clear of the routes");
- Assert.IsFalse(ground.OnToken(flat, r, After), key + " clear of the unit tokens");
+ Assert.IsFalse(ground.OnRoute(flat, r), who + " clear of the routes");
+ Assert.IsFalse(ground.OnToken(flat, r, After), who + " clear of the unit tokens");
var b = layer.transform.Find(key)!.GetComponentsInChildren<Renderer>(true).Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; });
- Assert.Less(b.size.y, Mathf.Max(b.size.x, b.size.z), key + " upright");
+ Assert.Less(b.size.y, Mathf.Max(b.size.x, b.size.z), who + " upright");
}
UnityEngine.Object.DestroyImmediate(layer.gameObject);
var again = CollectionGeometryFixture.Special(map, After, c, projects)!;
AnswerAll();
- foreach (var kv in first) Assert.AreEqual(kv.Value, again.Placed.Single(p => p.Key == kv.Key).At, kv.Key + " on the same spot again");
- // The load gate's rebuild line: one full plan (the sourced buildings and both workshops among the houses), as each
- // Rebuild computes it.
+ foreach (var project in projects)
+ {
+ string key = SpecialBuildingModels.WorkshopKey(project.Id);
+ Assert.AreEqual(first[key], again.Placed.Single(p => p.Key == key).At, key + " (" + project.City + ") on the same spot again");
+ }
+ // The load gate's rebuild line: one full plan (the sourced buildings and both workshops at their city's edge), as
+ // each Rebuild computes it.
var wants = SpecialBuildingModels.Placements(After).Concat(SpecialBuildingModels.ArmsWorkshops(c, projects)).ToList();
SpecialBuildingModels.Plan(map, After, wants, _ => true, log: false); // warm
var clock = System.Diagnostics.Stopwatch.StartNew();
@@ -1145,7 +1403,629 @@ namespace Statecraft.Game.Tests
double ms = clock.Elapsed.TotalMilliseconds / Runs;
TestContext.WriteLine($"PLAN-TIMING Jerusalem+Tel Aviv workshops: {ms:0.0} ms per plan");
// A design bound, not a budget: a plan runs on a prefab answer or a change of date or workshops, never per frame.
- Assert.Less(ms, 50.0, "one plan with two workshops among the houses");
+ Assert.Less(ms, 50.0, "one plan with two workshops at their city's edge");
+ }
+
+ /// <summary>#2876: the four major cities (TownModels.IsMajorCity) draw their kit blocks from 40 km out (owner, 6 November
+ /// 2026, "Big blocks, every zoom") and Tal Heuberger's building models below the close switch (owner, 7 November 2026,
+ /// "Tal's models close (Recommended)", which supersedes "Big blocks, every zoom" below 40 km), so a b21 among their
+ /// houses (owner, 2 November 2026: "Among the houses") and Tal Heuberger's props at their edge keep off both, on both
+ /// sides of the switch: the blocks (MapScene.MajorCityBlocks) and the model instances (TownModelLayer.InstancesOf,
+ /// each as a disc of its half diagonal). A workshop on each major city's own hex gets a planned spot (at the city's edge,
+ /// on or off the hex: owner, 6 November 2026, "make the workshop at the edge of the city"), whose ground (its clearance
+ /// disc, or on a street its square, SizeOf a side, along the street) overlaps no major city's kit block and no model
+ /// instance of any place; the Altalena sandbags (15 June 1948) and the Haifa quay crates, where planned, keep off them too.
+ /// The plan is the one the layer draws (every model available), placed twice to the same spots.</summary>
+ [Test]
+ public void AWorkshopOrPropInAMajorCityKeepsOffItsKitBlocksAndItsModels()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var blocks = map.MajorCityBlocks;
+ var majors = c.SettlementHexes.Select(h => h.Id).Where(Statecraft.Game.Map.Kits.TownModels.IsMajorCity).OrderBy(x => x, StringComparer.Ordinal).ToList();
+ CollectionAssert.AreEqual(new[] { "haifa", "jaffa", "jerusalem", "tel_aviv" }, majors, "the major cities with a settlement hex");
+ foreach (var city in majors) Assert.Greater(blocks.Count(b => b.Id == city), 0, city + " has kit blocks to keep clear of");
+ Assert.IsTrue(blocks.All(b => majors.Contains(b.Id) && (b.Kind == "building" || b.Kind == "wing")), "only the major cities' buildings and wings");
+ var projects = majors.Select((city, i) => Workshop(c, 700 + i, city, Built)).ToList();
+ var wants = SpecialBuildingModels.Placements(After).Concat(SpecialBuildingModels.ArmsWorkshops(c, projects)).ToList();
+ var plan = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out var along);
+ var again = SpecialBuildingModels.Plan(map, After, wants, _ => true, log: false);
+ CollectionAssert.AreEqual(plan.Select(x => (x.want.Key, x.at)).ToList(), again.Select(x => (x.want.Key, x.at)).ToList(), "the same spots when planned again");
+ float size = SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop), r = SpecialBuildingModels.ClearanceOf(SpecialBuildingModels.Workshop);
+ // Every place's model instances, the major cities' among them (drawn below the close switch since 7 November 2026).
+ var townLayer = map.GetComponentInChildren<Statecraft.Game.Map.Kits.TownModelLayer>(true);
+ Assert.IsNotNull(townLayer, "the town layer");
+ var models = map.KitFootprints.SelectMany(f => townLayer!.InstancesOf(f.id).Select(b => (id: f.id, b))).ToList();
+ foreach (var city in majors) Assert.Greater(models.Count(m => m.id == city), 0, city + " has model instances to keep clear of");
+ foreach (var project in projects)
+ {
+ string key = SpecialBuildingModels.WorkshopKey(project.Id);
+ CollectionAssert.Contains(plan.Select(x => x.want.Key).ToList(), key, project.City + "'s workshop gets a planned spot");
+ var at = plan.Single(x => x.want.Key == key).at;
+ var hex = c.HexAt(project.Q, project.R)!; var centre3 = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
+ float off = (at - new Vector2(centre3.x, centre3.z)).magnitude;
+ // Owner, 6 November 2026 (verbatim): "make the workshop at the edge of the city": it may stand off its hex.
+ bool street = along.TryGetValue(key, out var dir);
+ float yaw = street ? Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg : 0f;
+ int near = 0;
+ foreach (var b in blocks)
+ {
+ if ((b.C - at).magnitude > r + 0.5f * (b.W + b.D)) continue;
+ near++;
+ if (street)
+ Assert.IsTrue(BoxesApart(at, yaw, size, size, b.C, b.Yaw, b.W, b.D),
+ $"{key} ({project.City}): its {size:0} m square along the street at {at} overlaps {b.Id}'s {b.Kind} at {b.C} ({b.W:0} x {b.D:0} m, {b.Yaw:0} deg)");
+ else
+ Assert.IsTrue(SpecialBuildingModels.ClearOfBox(at, r, b.C, b.Yaw, b.W, b.D),
+ $"{key} ({project.City}): its {r:0} m disc at {at} overlaps {b.Id}'s {b.Kind} at {b.C} ({b.W:0} x {b.D:0} m, {b.Yaw:0} deg)");
+ }
+ foreach (var (id, b) in models)
+ {
+ float half = 0.5f * Mathf.Sqrt(b.W * b.W + b.D * b.D);
+ float need = (street ? 0.5f * Mathf.Sqrt(2f) * size : r) + half;
+ Assert.GreaterOrEqual((b.C - at).magnitude, need,
+ $"{key} ({project.City}): its ground at {at} meets {id}'s {b.Model} at {b.C} ({b.W:0} x {b.D:0} m)");
+ }
+ float closest = models.Min(m => (m.b.C - at).magnitude - 0.5f * Mathf.Sqrt(m.b.W * m.b.W + m.b.D * m.b.D));
+ TestContext.WriteLine($"{key} ({project.City}): {off:0} m from its hex centre{(street ? $", on a street at {yaw:0} deg" : "")}; {near} kit blocks within reach; the nearest model instance's disc {closest - r:0} m past its clearance disc");
+ }
+ // Tal Heuberger's props at a major city's edge (Want.TownEdge), on the day both stand.
+ var date = new DateTime(1948, 6, 15);
+ var props = SpecialBuildingModels.Plan(map, date, SpecialBuildingModels.Placements(date), _ => true, log: false);
+ foreach (var key in new[] { "tel_aviv_altalena_sandbags", "haifa_quay_crates" })
+ {
+ var row = props.Where(x => x.want.Key == key).ToList();
+ if (row.Count == 0) { TestContext.WriteLine($"{key}: not planned on 15 June 1948"); continue; }
+ var (want, at) = row[0]; float pr = SpecialBuildingModels.ClearanceOf(want);
+ foreach (var b in blocks)
+ Assert.IsTrue(SpecialBuildingModels.ClearOfBox(at, pr, b.C, b.Yaw, b.W, b.D), $"{key} at {at} overlaps {b.Id}'s {b.Kind} at {b.C}");
+ foreach (var (id, b) in models)
+ Assert.GreaterOrEqual((b.C - at).magnitude, pr + 0.5f * Mathf.Sqrt(b.W * b.W + b.D * b.D), $"{key} at {at} meets {id}'s {b.Model} at {b.C}");
+ TestContext.WriteLine($"{key}: at {at}, clear of the major cities' kit blocks and of every model instance");
+ }
+ }
+
+ /// <summary>#2876, coordinator's captures of 6 November 2026: clear of the major cities' kit blocks, the Tel Aviv b21 (on a
+ /// street between two tall blocks) and the Jerusalem b21 (in a gap with a tall block south of it) were still hidden. The
+ /// camera looks north (CameraRig yaw 0; fixed north under gdd-0.3, the only ruleset with workshops,
+ /// CameraHeadingPolicy.IsFixedNorth) and down at CameraRig.Pitch on the screen's centre row, less toward the top of the
+ /// screen, to CameraRig.Pitch - CameraRig.Fov / 2 at its top edge: the shallowest ray, the one a block hides most behind.
+ /// For each major city's workshop, as the layer draws it, a 5 by 5 grid of points on its top (the drawn model's highest
+ /// point, over its square, SizeOf a side, turned along its street if it has one) each sees the camera along that
+ /// shallowest ray: the ray toward the camera (south and up) meets no major-city kit block, each taken as its box (the
+ /// census footprint, Placed.C, Yaw, W, D) from the ground up to its wall top (the highest of the ground at its corners
+ /// and centre, where the kit stands it, plus Placed.H). Also, again: each workshop gets a spot (on or off its hex: owner,
+ /// 6 November 2026, "make the workshop at the edge of the city"), clear of the blocks, drawn where it was planned, and the
+ /// plan is the same when made twice. Every city's failures are listed together, by city. Since the owner's ruling of
+ /// 7 November 2026, "Tal's models close (Recommended)", the city draws Tal Heuberger's building models below the close
+ /// switch, so no building model (each its fitted box, <see cref="HiddenByModels"/>) may hide the top either.</summary>
+ [Test]
+ public void AWorkshopInAMajorCityIsInTheCamerasSightPastItsKitBlocksAndModels()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var blocks = map.MajorCityBlocks;
+ var majors = c.SettlementHexes.Select(h => h.Id).Where(Statecraft.Game.Map.Kits.TownModels.IsMajorCity).OrderBy(x => x, StringComparer.Ordinal).ToList();
+ CollectionAssert.AreEqual(new[] { "haifa", "jaffa", "jerusalem", "tel_aviv" }, majors, "the major cities with a settlement hex");
+ var projects = majors.Select((city, i) => Workshop(c, 700 + i, city, Built)).ToList();
+ var wants = SpecialBuildingModels.Placements(After).Concat(SpecialBuildingModels.ArmsWorkshops(c, projects)).ToList();
+ var plan = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out var along);
+ var again = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out var alongAgain);
+ CollectionAssert.AreEqual(plan.Select(x => (x.want.Key, x.at)).ToList(), again.Select(x => (x.want.Key, x.at)).ToList(), "the same spots when planned again");
+ CollectionAssert.AreEquivalent(along.OrderBy(x => x.Key, StringComparer.Ordinal).ToList(), alongAgain.OrderBy(x => x.Key, StringComparer.Ordinal).ToList(),
+ "the same streets when planned again");
+ var layer = CollectionGeometryFixture.Special(map, After, c, projects)!;
+ AnswerAll();
+ var ground = PlacementLayer.CampGround(map);
+ var toCamera = ToCamera();
+ var tops = BlockTops(map, ground);
+ float size = SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop), r = SpecialBuildingModels.ClearanceOf(SpecialBuildingModels.Workshop);
+ var failures = new List<string>();
+ foreach (var project in projects)
+ {
+ string city = project.City, key = SpecialBuildingModels.WorkshopKey(project.Id);
+ var row = plan.Where(x => x.want.Key == key).ToList();
+ if (row.Count == 0) { failures.Add($"{city}: {key} gets no planned spot, so it is not drawn"); continue; }
+ var at = row[0].at;
+ var hex = c.HexAt(project.Q, project.R)!; var centre3 = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
+ float off = (at - new Vector2(centre3.x, centre3.z)).magnitude;
+ // The owner, 6 November 2026 (verbatim): "make the workshop at the edge of the city": a major city's b21 may
+ // stand off its project's hex (AWorkshopInAMajorCityStandsAtTheCitysEdge), so its hex is not asserted here.
+ bool street = along.TryGetValue(key, out var dir);
+ float yaw = street ? Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg : 0f;
+ foreach (var b in blocks)
+ {
+ if ((b.C - at).magnitude > r + 0.5f * (b.W + b.D)) continue;
+ bool clear = street ? BoxesApart(at, yaw, size, size, b.C, b.Yaw, b.W, b.D) : SpecialBuildingModels.ClearOfBox(at, r, b.C, b.Yaw, b.W, b.D);
+ if (!clear) failures.Add($"{city}: {key} at {at} overlaps {b.Id}'s {b.Kind} at {b.C}");
+ }
+ var model = layer.transform.Find(key);
+ if (model == null) { failures.Add($"{city}: {key} is planned at {at} but not drawn"); continue; }
+ var mb = model.GetComponentsInChildren<Renderer>(true).Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; });
+ if ((new Vector2(mb.center.x, mb.center.z) - at).magnitude > 1f) failures.Add($"{city}: {key} is drawn at {mb.center}, not at its planned {at}");
+ var (hidden, first) = HiddenOnTop(map, tops, at, yaw, size, mb.max.y, toCamera);
+ TestContext.WriteLine(FormattableString.Invariant(
+ $"{key} ({city}): at {at}, {off:0} m from its hex centre{(street ? $", on a street at {yaw:0} deg" : "")}, top {mb.max.y:0} m; {hidden} of 25 points on its top hidden at {Shallowest:0.0} deg"));
+ if (hidden > 0) failures.Add($"{city}: {key}: {hidden} of 25 points on its top are hidden from the camera at {Shallowest:0.0} deg; first: {first}");
+ // Below the close switch the city draws Tal Heuberger's building models in place of its blocks (owner, 7 November
+ // 2026, "Tal's models close (Recommended)"): none of them may hide the b21's top either.
+ var (byModels, firstModel) = HiddenByModels(map, at, yaw, size, mb.max.y, toCamera);
+ TestContext.WriteLine(FormattableString.Invariant($"{key} ({city}): {byModels} of 25 points on its top hidden by a building model"));
+ if (byModels > 0) failures.Add($"{city}: {key}: {byModels} of 25 points on its top are hidden by a building model at {Shallowest:0.0} deg; first: {firstModel}");
+ }
+ Assert.IsEmpty(failures, string.Join("\n", failures));
+ }
+
+ /// <summary>As <see cref="HiddenOnTop"/>, against the town building models as placed at map build (TownModelLayer.InstancesOf
+ /// of every footprint within 20 km, each its fitted box from its ground to Ground + H, SettlementKits.ModelInstance).</summary>
+ static (int hidden, string? first) HiddenByModels(MapScene map, Vector2 at, float yaw, float size, float top, Vector3 toCamera)
+ {
+ var layer = map.GetComponentInChildren<Statecraft.Game.Map.Kits.TownModelLayer>(true);
+ Assert.IsNotNull(layer, "the town layer");
+ var models = map.KitFootprints.Where(f => (f.centre - at).magnitude < 20000f + f.radius * 2f).SelectMany(f => layer!.InstancesOf(f.id)).ToList();
+ float ya = yaw * Mathf.Deg2Rad, half = 0.49f * size;
+ var su = new Vector2(Mathf.Cos(ya), Mathf.Sin(ya)); var sv = new Vector2(-su.y, su.x);
+ int hidden = 0; string? first = null;
+ for (int i = 0; i < 5; i++)
+ for (int j = 0; j < 5; j++)
+ {
+ var p2 = at + su * (half * (i / 2f - 1f)) + sv * (half * (j / 2f - 1f));
+ var q = new Vector3(p2.x, top, p2.y);
+ foreach (var b in models)
+ {
+ if (!RayMeetsBox(q, toCamera, b.C, b.Yaw, b.W, b.D, b.Ground + b.H)) continue;
+ hidden++;
+ first ??= FormattableString.Invariant($"{b.Id}'s {b.Model} at {b.C} ({b.W:0} x {b.D:0} m, {b.Yaw:0} deg, top {b.Ground + b.H:0} m) hides its top at {q}");
+ break;
+ }
+ }
+ return (hidden, first);
+ }
+
+ /// <summary>The view's shallowest ray's depression (degrees): the screen's top edge, CameraRig.Pitch - Fov / 2.</summary>
+ static float Shallowest => CameraRig.Pitch - 0.5f * CameraRig.Fov;
+
+ /// <summary>The ray from a point toward the camera: the camera turns Euler(pitch, yaw 0, 0) and stands at LookAt - forward x
+ /// Distance (CameraRig.Apply), so back along forward; at the shallowest pitch.</summary>
+ static Vector3 ToCamera()
+ {
+ var toCamera = -(Quaternion.Euler(Shallowest, 0f, 0f) * Vector3.forward);
+ Assert.Greater(toCamera.y, 0f, "the camera is above the ground");
+ Assert.Less(toCamera.z, 0f, "the camera is south of what it looks at (x east, z north)");
+ Assert.AreEqual(0f, toCamera.x, 1e-6f, "the camera looks due north");
+ return toCamera;
+ }
+
+ /// <summary>Each major-city block's wall top (world y), in MapScene.MajorCityBlocks order: its wall height over the ground
+ /// the kit stands it on (SettlementKits.GroundSpan's: the highest of its corners and centre).</summary>
+ static List<float> BlockTops(MapScene map, Statecraft.Game.Map.Kits.KitGround ground) => map.MajorCityBlocks.Select(b =>
+ {
+ float a = b.Yaw * Mathf.Deg2Rad, ca = Mathf.Cos(a), sa = Mathf.Sin(a), hi = float.MinValue;
+ for (int i = 0; i < 5; i++)
+ {
+ float u = i == 4 ? 0f : ((i & 1) == 0 ? -0.5f : 0.5f) * b.W, v = i == 4 ? 0f : ((i & 2) == 0 ? -0.5f : 0.5f) * b.D;
+ hi = Mathf.Max(hi, ground.Y(b.C.x + u * ca - v * sa, b.C.y + u * sa + v * ca));
+ }
+ return hi + b.H;
+ }).ToList();
+
+ /// <summary>How many of 25 points on a b21's top (a 5 by 5 grid over its square, <paramref name="size"/> a side, turned
+ /// <paramref name="yaw"/>, inset 2% so a point is on the top, not its edge, at world y <paramref name="top"/>) a major-city
+ /// block hides from the camera (<see cref="RayMeetsBox"/> along <paramref name="toCamera"/>), and the first.</summary>
+ static (int hidden, string? first) HiddenOnTop(MapScene map, List<float> tops, Vector2 at, float yaw, float size, float top, Vector3 toCamera)
+ {
+ var blocks = map.MajorCityBlocks;
+ float ya = yaw * Mathf.Deg2Rad, half = 0.49f * size;
+ var su = new Vector2(Mathf.Cos(ya), Mathf.Sin(ya)); var sv = new Vector2(-su.y, su.x);
+ int hidden = 0; string? first = null;
+ for (int i = 0; i < 5; i++)
+ for (int j = 0; j < 5; j++)
+ {
+ var p2 = at + su * (half * (i / 2f - 1f)) + sv * (half * (j / 2f - 1f));
+ var q = new Vector3(p2.x, top, p2.y);
+ for (int k = 0; k < blocks.Count; k++)
+ {
+ var b = blocks[k];
+ if (!RayMeetsBox(q, toCamera, b.C, b.Yaw, b.W, b.D, tops[k])) continue;
+ hidden++;
+ first ??= FormattableString.Invariant($"{b.Id}'s {b.Kind} at {b.C} ({b.W:0} x {b.D:0} m, {b.Yaw:0} deg, top {tops[k]:0} m) hides its top at {q}");
+ break;
+ }
+ }
+ return (hidden, first);
+ }
+
+ /// <summary>How far past the outermost kit block of its city a major city's b21 may stand (m), centre to the block's
+ /// nearest point: the layer's design bound of 1 km past the block's face to the model's ground, plus the model's clearance
+ /// disc (r) and the band r either side of its bearing that the outermost block is taken from.</summary>
+ static float EdgeReach(float r) => 1000f + 2f * r;
+
+ /// <summary>The owner, 6 November 2026, on #2876 (verbatim): "make the workshop at the edge of the city". Whether the b21
+ /// planned at <paramref name="at"/> (its clearance disc <paramref name="r"/>) stands at the edge of the major city
+ /// <paramref name="city"/>, as this test reads it off the map (the kit census, the footprints, the ground), not off the
+ /// layer's search; each miss is added to <paramref name="failures"/>, naming the city:
+ /// - clear of every major city's kit block (its disc against each census box);
+ /// - past the city's blocks: no block of the city that the band <paramref name="r"/> either side of the ray from the city's
+ /// centre through the spot meets reaches farther out along that ray than the disc's near edge;
+ /// - near them: within <see cref="EdgeReach"/> of the nearest block of the city;
+ /// - the city's ground: deeper in the city's footprint (distance over radius, the kits' partition,
+ /// SettlementKits.OwnsFootprint) than in any other place's, and clear of every other place's plot reach
+ /// (SettlementKits.PlotReach of its radius), where its buildings stand;
+ /// - clear of every place's name pill (<see cref="SpecialBuildingModels.ClearOfName"/>);
+ /// - on land, off the beach: its centre dry, and no open sea within the drawn full sand (BeachBands.FullSandAt) plus r;
+ /// - on ground the player's side holds on <paramref name="built"/>, the day it was built: its centre and 8 points round
+ /// its disc each on the project's own hex <paramref name="home"/> (a player city, painted the player's) or on a hex the
+ /// map's control wash (MapScene.Control, control_hexes_1948_49.yaml) gives the Israeli side that day; the other side,
+ /// contested ground, no-man's land, a demilitarized zone, no colour and off the data all miss;
+ /// - nearer its own city's kit blocks than any other major city's (the nearest block of each, box distance).</summary>
+ static void AtTheCitysEdge(MapScene map, string city, string key, Vector2 at, float r, List<string> failures, DateTime built, (int q, int r) home)
+ {
+ string who = FormattableString.Invariant($"{city}: {key} at ({at.x:0}, {at.y:0})");
+ var fp = map.KitFootprints.Single(f => f.id == city);
+ var own = map.MajorCityBlocks.Where(b => b.Id == city).ToList();
+ if (own.Count == 0) { failures.Add(who + ": the city has no kit blocks"); return; }
+ foreach (var b in map.MajorCityBlocks)
+ if (!SpecialBuildingModels.ClearOfBox(at, r, b.C, b.Yaw, b.W, b.D))
+ failures.Add(FormattableString.Invariant($"{who} overlaps {b.Id}'s {b.Kind} at {b.C}"));
+ var toward = at - fp.centre; float dist = toward.magnitude;
+ var u = toward / dist; var n = new Vector2(-u.y, u.x);
+ float nearest = float.MaxValue;
+ foreach (var b in own)
+ {
+ float a = b.Yaw * Mathf.Deg2Rad;
+ var bu = new Vector2(Mathf.Cos(a), Mathf.Sin(a)); var bv = new Vector2(-bu.y, bu.x);
+ float hu = 0.5f * b.W * Mathf.Abs(Vector2.Dot(bu, u)) + 0.5f * b.D * Mathf.Abs(Vector2.Dot(bv, u));
+ float hn = 0.5f * b.W * Mathf.Abs(Vector2.Dot(bu, n)) + 0.5f * b.D * Mathf.Abs(Vector2.Dot(bv, n));
+ float tc = Vector2.Dot(b.C - fp.centre, u), sc = Vector2.Dot(b.C - fp.centre, n);
+ if (Mathf.Abs(sc) - hn < r - 0.5f && tc + hu > 0f && tc + hu > dist - r + 0.5f)
+ failures.Add(FormattableString.Invariant($"{who} is not past {city}'s {b.Kind} at {b.C} on its bearing: the block reaches {tc + hu:0} m out, the disc from {dist - r:0} m"));
+ var q = b.C - at; float qu = q.x * bu.x + q.y * bu.y, qv = q.x * bv.x + q.y * bv.y;
+ float du = Mathf.Max(0f, Mathf.Abs(qu) - 0.5f * b.W), dv = Mathf.Max(0f, Mathf.Abs(qv) - 0.5f * b.D);
+ nearest = Mathf.Min(nearest, Mathf.Sqrt(du * du + dv * dv));
+ }
+ if (nearest > EdgeReach(r)) failures.Add(FormattableString.Invariant($"{who} is {nearest:0} m from {city}'s nearest kit block, past {EdgeReach(r):0} m"));
+ float other = float.MaxValue; string otherId = "none";
+ foreach (var b in map.MajorCityBlocks)
+ {
+ if (b.Id == city) continue;
+ float a = b.Yaw * Mathf.Deg2Rad;
+ var q = b.C - at; float qu = q.x * Mathf.Cos(a) + q.y * Mathf.Sin(a), qv = -q.x * Mathf.Sin(a) + q.y * Mathf.Cos(a);
+ float du = Mathf.Max(0f, Mathf.Abs(qu) - 0.5f * b.W), dv = Mathf.Max(0f, Mathf.Abs(qv) - 0.5f * b.D);
+ float d = Mathf.Sqrt(du * du + dv * dv);
+ if (d < other) { other = d; otherId = b.Id; }
+ }
+ if (!(nearest < other)) failures.Add(FormattableString.Invariant($"{who} is {nearest:0} m from {city}'s nearest kit block, not nearer than {otherId}'s ({other:0} m)"));
+ float mine = dist / fp.radius;
+ OnThePlacesGround(map, city, who, fp.centre, fp.radius, at, r, failures, built, home);
+ var ground = PlacementLayer.CampGround(map);
+ TestContext.WriteLine(FormattableString.Invariant($"{key} ({city}): {Offset(at, fp.centre)} from the city's centre ({mine:0.00} of its radius), hex {ground.Hex(at.x, at.y)}; {nearest:0} m from its nearest kit block, {other:0} m from {otherId}'s"));
+ }
+
+ /// <summary>The checks <see cref="AtTheCitysEdge"/> and <see cref="AtTheTownsEdge"/> share, each miss added to
+ /// <paramref name="failures"/> as <paramref name="who"/>'s: the b21 at <paramref name="at"/> (its disc <paramref name="r"/>)
+ /// is on <paramref name="place"/>'s ground (its footprint at <paramref name="centre"/>, <paramref name="radius"/>): deeper
+ /// in it (distance over radius, SettlementKits.OwnsFootprint's partition) than in any other place's, and clear of every
+ /// other place's plot reach (SettlementKits.PlotReach of its radius); clear of every place's name pill; its centre dry and
+ /// no open sea within the drawn full sand (BeachBands.FullSandAt) plus r; and on ground the player's side holds on
+ /// <paramref name="built"/> (its centre and 8 points round its disc each on <paramref name="home"/> or on a hex the
+ /// control wash gives the Israeli side that day).</summary>
+ static void OnThePlacesGround(MapScene map, string place, string who, Vector2 centre, float radius, Vector2 at, float r, List<string> failures,
+ DateTime built, (int q, int r) home)
+ {
+ float mine = (at - centre).magnitude / radius;
+ foreach (var f in map.KitFootprints)
+ {
+ if (!SpecialBuildingModels.ClearOfName(at, r, f.centre, f.radius)) failures.Add($"{who} is under {f.id}'s name pill");
+ if (f.id == place) continue;
+ float d = (at - f.centre).magnitude;
+ if (d / f.radius <= mine) failures.Add(FormattableString.Invariant($"{who} reads as {f.id}'s: {d / f.radius:0.00} of its radius, {mine:0.00} of {place}'s"));
+ if (d < f.radius * Statecraft.Game.Map.Kits.SettlementKits.PlotReach + r) failures.Add($"{who} is on {f.id}'s ground (its plot reach)");
+ }
+ var ground = PlacementLayer.CampGround(map);
+ if (ground.Water(at.x, at.y)) failures.Add(who + " is in the water");
+ var reaches = Statecraft.Game.Map.Kits.BeachBands.Reaches(map.Settlements.Concat(map.Localities.Select(l => l.Settlement)).ToList(), ground);
+ float sand = Statecraft.Game.Map.Kits.BeachBands.FullSandAt(map.Frame, at.x, at.y, reaches);
+ if (ground.SeaDistance(at.x, at.y, sand + r) != float.MaxValue) failures.Add(FormattableString.Invariant($"{who} is on the beach (the sea within {sand:0} m of full sand plus its {r:0} m)"));
+ var control = map.Control;
+ if (control == null) failures.Add(who + ": the map has no control data to check the held ground against");
+ else
+ for (int i = 0; i < 9; i++)
+ {
+ float a = i * Mathf.PI / 4f;
+ var s = i == 8 ? at : at + r * new Vector2(Mathf.Cos(a), Mathf.Sin(a));
+ var (hq, hr) = ground.Hex(s.x, s.y);
+ if ((hq, hr) == home) continue;
+ var (side, holder) = control.At(hq, hr, built);
+ if (side != Control1948.Side.Israel)
+ failures.Add(FormattableString.Invariant($"{who}: its disc reaches hex {hq},{hr}, {side}{(holder != null ? " (" + holder + ")" : "")} on {built:yyyy-MM-dd}, not the Israeli side's"));
+ }
+ }
+
+ /// <summary>#2876 (coordinator, 6 November 2026: at 2.5x Petah Tikva's hex left its b21 no spot): whether the b21 of a
+ /// town that is not a major city, planned at <paramref name="at"/> (its disc <paramref name="r"/>) at the town's edge
+ /// because its hex had no spot (SpecialBuildingModels.TownEdgeSpot), stands at the edge of what the town draws, as this
+ /// test reads it off the map (the town layer's building models as placed at map build, TownModelLayer.InstancesOf, or
+ /// with none the reach of its kit's plots, its footprint radius times SettlementKits.PlotReach), not off the layer's
+ /// search; each miss is added to <paramref name="failures"/>, naming the town:
+ /// - clear of every major city's kit block (its disc against each census box), of every town's building models (a disc
+ /// of each one's half diagonal) and of the kits' walls, platforms, landmarks and landmark parts;
+ /// - past the town's buildings: none of them that the band <paramref name="r"/> either side of the ray from the town's
+ /// centre through the spot meets reaches farther out along that ray than the disc's near edge (with none, the disc's
+ /// near edge past the plots' reach);
+ /// - near them: within <see cref="EdgeReach"/> of the nearest of them (or of the plots' reach);
+ /// - nearer them than any major city's kit block;
+ /// - and <see cref="OnThePlacesGround"/>: the town's ground, no name pill, dry, off the beach, held on
+ /// <paramref name="built"/>.</summary>
+ static void AtTheTownsEdge(MapScene map, string town, string key, Vector2 at, float r, List<string> failures, DateTime built, (int q, int r) home)
+ {
+ string who = FormattableString.Invariant($"{town}: {key} at ({at.x:0}, {at.y:0})");
+ var fp = map.KitFootprints.First(f => f.id == town);
+ var layer = map.GetComponentInChildren<Statecraft.Game.Map.Kits.TownModelLayer>(true);
+ Assert.IsNotNull(layer, "the town layer");
+ var own = layer!.InstancesOf(town);
+ float disc = own.Count == 0 ? fp.radius * Statecraft.Game.Map.Kits.SettlementKits.PlotReach : 0f;
+ foreach (var b in map.MajorCityBlocks)
+ if (!SpecialBuildingModels.ClearOfBox(at, r, b.C, b.Yaw, b.W, b.D))
+ failures.Add(FormattableString.Invariant($"{who} overlaps {b.Id}'s {b.Kind} at {b.C}"));
+ foreach (var f in map.KitFootprints)
+ {
+ foreach (var b in layer.InstancesOf(f.id)) // a major city's too: drawn below the close switch ("Tal's models close (Recommended)")
+ if ((b.C - at).magnitude < r + 0.5f * Mathf.Sqrt(b.W * b.W + b.D * b.D))
+ failures.Add(FormattableString.Invariant($"{who} overlaps {f.id}'s {b.Model} at {b.C}"));
+ }
+ foreach (var l in map.KitStats.Landmarks)
+ if (!SpecialBuildingModels.ClearOfBox(at, r, l.C, l.Yaw, l.W, l.D)) failures.Add(FormattableString.Invariant($"{who} overlaps {l.Id}'s {l.Kind} at {l.C}"));
+ foreach (var part in map.KitStats.LandmarkParts)
+ if (!SpecialBuildingModels.ClearOfBox(at, r, new Vector2(part.Near.center.x, part.Near.center.z), 0f, part.Near.size.x, part.Near.size.z))
+ failures.Add(FormattableString.Invariant($"{who} overlaps {part.Owner}'s {part.Kind} at {part.Near.center}"));
+ var toward = at - fp.centre; float dist = toward.magnitude;
+ var u = toward / dist; var n = new Vector2(-u.y, u.x);
+ float nearest = float.MaxValue;
+ if (own.Count == 0)
+ {
+ if (dist - r < disc - 0.5f) failures.Add(FormattableString.Invariant($"{who} is not past {town}'s plots' reach ({disc:0} m): the disc from {dist - r:0} m"));
+ nearest = Mathf.Max(0f, dist - disc);
+ }
+ foreach (var b in own)
+ {
+ float a = b.Yaw * Mathf.Deg2Rad;
+ var bu = new Vector2(Mathf.Cos(a), Mathf.Sin(a)); var bv = new Vector2(-bu.y, bu.x);
+ float hu = 0.5f * b.W * Mathf.Abs(Vector2.Dot(bu, u)) + 0.5f * b.D * Mathf.Abs(Vector2.Dot(bv, u));
+ float hn = 0.5f * b.W * Mathf.Abs(Vector2.Dot(bu, n)) + 0.5f * b.D * Mathf.Abs(Vector2.Dot(bv, n));
+ float tc = Vector2.Dot(b.C - fp.centre, u), sc = Vector2.Dot(b.C - fp.centre, n);
+ if (Mathf.Abs(sc) - hn < r - 0.5f && tc + hu > 0f && tc + hu > dist - r + 0.5f)
+ failures.Add(FormattableString.Invariant($"{who} is not past {town}'s {b.Model} at {b.C} on its bearing: it reaches {tc + hu:0} m out, the disc from {dist - r:0} m"));
+ var q = b.C - at; float qu = q.x * bu.x + q.y * bu.y, qv = q.x * bv.x + q.y * bv.y;
+ float du = Mathf.Max(0f, Mathf.Abs(qu) - 0.5f * b.W), dv = Mathf.Max(0f, Mathf.Abs(qv) - 0.5f * b.D);
+ nearest = Mathf.Min(nearest, Mathf.Sqrt(du * du + dv * dv));
+ }
+ if (nearest > EdgeReach(r)) failures.Add(FormattableString.Invariant($"{who} is {nearest:0} m from {town}'s nearest building, past {EdgeReach(r):0} m"));
+ float other = float.MaxValue; string otherId = "none";
+ foreach (var b in map.MajorCityBlocks)
+ {
+ float a = b.Yaw * Mathf.Deg2Rad;
+ var q = b.C - at; float qu = q.x * Mathf.Cos(a) + q.y * Mathf.Sin(a), qv = -q.x * Mathf.Sin(a) + q.y * Mathf.Cos(a);
+ float du = Mathf.Max(0f, Mathf.Abs(qu) - 0.5f * b.W), dv = Mathf.Max(0f, Mathf.Abs(qv) - 0.5f * b.D);
+ float d = Mathf.Sqrt(du * du + dv * dv);
+ if (d < other) { other = d; otherId = b.Id; }
+ }
+ if (!(nearest < other)) failures.Add(FormattableString.Invariant($"{who} is {nearest:0} m from {town}'s nearest building, not nearer than {otherId}'s kit blocks ({other:0} m)"));
+ OnThePlacesGround(map, town, who, fp.centre, fp.radius, at, r, failures, built, home);
+ var ground = PlacementLayer.CampGround(map);
+ TestContext.WriteLine(FormattableString.Invariant($"{key} ({town}) at its town's edge: {Offset(at, fp.centre)} from the town's centre ({dist / fp.radius:0.00} of its radius), hex {ground.Hex(at.x, at.y)}; {nearest:0} m from its nearest {(own.Count > 0 ? "building" : "plot reach")}, {other:0} m from {otherId}'s kit blocks"));
+ }
+
+ /// <summary>#2876, the owner, 6 November 2026 (verbatim): "make the workshop at the edge of the city". A workshop built on
+ /// each major city's hex (haifa, jaffa, jerusalem, tel_aviv: TownModels.IsMajorCity, which draw their tall kit blocks from
+ /// 40 km out and Tal Heuberger's building models below the close switch: "Tal's models close (Recommended)") gets a planned spot (none is a failure naming the city: the layer then draws no b21), at the city's edge
+ /// (<see cref="AtTheCitysEdge"/>), drawn where planned, whose top the camera sees past every major city's kit blocks
+ /// along the view's shallowest ray (<see cref="HiddenOnTop"/>, the test's own ray test), and the plan is the same when
+ /// made twice. It may stand off its project's hex where no edge spot is on it; each spot's offset from its hex is
+ /// logged. Every city's failures are listed together, by city.</summary>
+ [Test]
+ public void AWorkshopInAMajorCityStandsAtTheCitysEdge()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var majors = c.SettlementHexes.Select(h => h.Id).Where(Statecraft.Game.Map.Kits.TownModels.IsMajorCity).OrderBy(x => x, StringComparer.Ordinal).ToList();
+ CollectionAssert.AreEqual(new[] { "haifa", "jaffa", "jerusalem", "tel_aviv" }, majors, "the major cities with a settlement hex");
+ var projects = majors.Select((city, i) => Workshop(c, 700 + i, city, Built)).ToList();
+ var wants = SpecialBuildingModels.Placements(After).Concat(SpecialBuildingModels.ArmsWorkshops(c, projects)).ToList();
+ var plan = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out var along);
+ var again = SpecialBuildingModels.PlanWithRoutes(map, After, wants, _ => true, false, null, out _);
+ CollectionAssert.AreEqual(plan.Select(x => (x.want.Key, x.at)).ToList(), again.Select(x => (x.want.Key, x.at)).ToList(), "the same spots when planned again");
+ var layer = CollectionGeometryFixture.Special(map, After, c, projects)!;
+ AnswerAll();
+ var ground = PlacementLayer.CampGround(map);
+ var toCamera = ToCamera();
+ var tops = BlockTops(map, ground);
+ float size = SpecialBuildingModels.SizeOf(SpecialBuildingModels.Workshop), r = SpecialBuildingModels.ClearanceOf(SpecialBuildingModels.Workshop);
+ var failures = new List<string>();
+ foreach (var project in projects)
+ {
+ string city = project.City, key = SpecialBuildingModels.WorkshopKey(project.Id);
+ var row = plan.Where(x => x.want.Key == key).ToList();
+ if (row.Count == 0) { failures.Add($"{city}: {key} gets no planned spot, so it is not drawn"); continue; }
+ var at = row[0].at;
+ var hex = c.HexAt(project.Q, project.R)!; var centre3 = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
+ var hexCentre = new Vector2(centre3.x, centre3.z);
+ bool onHex = (at - hexCentre).magnitude + r <= SpecialBuildingModels.HexInnerRadiusM;
+ TestContext.WriteLine($"{key} ({city}): {Offset(at, hexCentre)} from its hex centre, {(onHex ? "wholly on" : "off")} its project's hex");
+ AtTheCitysEdge(map, city, key, at, r, failures, Built, (project.Q, project.R));
+ bool street = along.TryGetValue(key, out var dir);
+ float yaw = street ? Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg : 0f;
+ var model = layer.transform.Find(key);
+ if (model == null) { failures.Add($"{city}: {key} is planned at {at} but not drawn"); continue; }
+ var mb = model.GetComponentsInChildren<Renderer>(true).Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; });
+ if ((new Vector2(mb.center.x, mb.center.z) - at).magnitude > 1f) failures.Add($"{city}: {key} is drawn at {mb.center}, not at its planned {at}");
+ var (hidden, first) = HiddenOnTop(map, tops, at, yaw, size, mb.max.y, toCamera);
+ if (hidden > 0) failures.Add($"{city}: {key}: {hidden} of 25 points on its top are hidden from the camera at {Shallowest:0.0} deg; first: {first}");
+ }
+ Assert.IsEmpty(failures, string.Join("\n", failures));
+ }
+
+ /// <summary>#2876: SpecialBuildingModels.OnHeldGround, on the control wash's own hexes (control_hexes_1948_49.yaml): a
+ /// hex the other side holds (-1,28, south of Jerusalem: "M" on 1 March 1949) is not held, unless it is the project's own;
+ /// a contested hex (-3,26, west of Jerusalem: "c" on 15 May 1948) is not held that day and is from the first truce on
+ /// ("I" on 1 March 1949); Tel Aviv's (-3,21) is held.</summary>
+ [Test]
+ public void HeldGroundIsTheIsraeliSidesOnTheDayAsked()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ Assert.IsNotNull(map.Control, "the map reads its control wash");
+ var ground = PlacementLayer.CampGround(map);
+ Vector2 Centre(int q, int r)
+ {
+ var hex = c.HexAt(q, r)!; var w = map.Frame.ToWorld(hex.Lon, hex.Lat, 0); var p = new Vector2(w.x, w.z);
+ Assert.AreEqual((q, r), ground.Hex(p.x, p.y), $"hex {q},{r}'s centre is on that hex");
+ return p;
+ }
+ var none = (int.MinValue, int.MinValue);
+ var opening = new DateTime(1948, 5, 15);
+ Assert.IsFalse(SpecialBuildingModels.OnHeldGround(map, ground, Centre(-1, 28), 50f, Built, none), "the other side's hex");
+ Assert.IsTrue(SpecialBuildingModels.OnHeldGround(map, ground, Centre(-1, 28), 50f, Built, (-1, 28)), "the project's own hex");
+ Assert.IsFalse(SpecialBuildingModels.OnHeldGround(map, ground, Centre(-3, 26), 50f, opening, none), "a contested hex");
+ Assert.IsTrue(SpecialBuildingModels.OnHeldGround(map, ground, Centre(-3, 26), 50f, Built, none), "the same hex once held");
+ Assert.IsTrue(SpecialBuildingModels.OnHeldGround(map, ground, Centre(-3, 21), 50f, Built, none), "Tel Aviv's hex");
+ }
+
+ /// <summary>#2876 (coordinator, 6 November 2026): the front moves with the date, so a major city's workshop keeps the spot it
+ /// got on the day it was built (its held ground, tokens and figures read that day, Want.From), whatever day the plan is
+ /// made on. A workshop built in each major city on <see cref="Built"/> is planned on that day and on two later days on
+ /// which the control wash differs (the Jordan armistice, 3 April 1949, and the Syrian one, 20 July 1949, each a new
+ /// period of control_hexes_1948_49.yaml): it gets a spot each time, the same one.</summary>
+ [Test]
+ public void AMajorCitysWorkshopKeepsItsSpotAsTheFrontMoves()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ Assert.IsNotNull(map.Control, "the map reads its control wash");
+ var majors = c.SettlementHexes.Select(h => h.Id).Where(Statecraft.Game.Map.Kits.TownModels.IsMajorCity).OrderBy(x => x, StringComparer.Ordinal).ToList();
+ var projects = majors.Select((city, i) => Workshop(c, 700 + i, city, Built)).ToList();
+ var workshops = SpecialBuildingModels.ArmsWorkshops(c, projects);
+ var dates = new[] { Built, new DateTime(1949, 4, 3), new DateTime(1949, 7, 20) };
+ Assert.AreEqual(dates.Length, dates.Select(d => map.Control!.PeriodOn(d)?.Id).Distinct().Count(), "three periods of the control wash");
+ var first = new Dictionary<string, Vector2>(StringComparer.Ordinal);
+ var failures = new List<string>();
+ foreach (var date in dates)
+ {
+ var plan = SpecialBuildingModels.Plan(map, date, SpecialBuildingModels.Placements(date).Concat(workshops).ToList(), _ => true, log: false);
+ foreach (var project in projects)
+ {
+ string key = SpecialBuildingModels.WorkshopKey(project.Id);
+ int changed = 0;
+ for (int dq = -2; dq <= 2; dq++)
+ for (int dr = -2; dr <= 2; dr++)
+ if (map.Control!.At(project.Q + dq, project.R + dr, date) != map.Control.At(project.Q + dq, project.R + dr, Built)) changed++;
+ var row = plan.Where(x => x.want.Key == key).ToList();
+ if (row.Count == 0) { failures.Add($"{project.City}: {key} gets no spot when planned on {date:yyyy-MM-dd}"); continue; }
+ TestContext.WriteLine(FormattableString.Invariant($"{key} ({project.City}) planned on {date:yyyy-MM-dd}: at ({row[0].at.x:0}, {row[0].at.y:0}); {changed} hexes near its own changed side or holder since {Built:yyyy-MM-dd}"));
+ if (!first.TryGetValue(key, out var at)) first[key] = row[0].at;
+ else if (at != row[0].at) failures.Add(FormattableString.Invariant($"{project.City}: {key} moves from ({at.x:0}, {at.y:0}) to ({row[0].at.x:0}, {row[0].at.y:0}) when planned on {date:yyyy-MM-dd}"));
+ }
+ }
+ Assert.IsEmpty(failures, string.Join("\n", failures));
+ }
+
+ /// <summary>#2876, coordinator's capture of 6 November 2026: the Jaffa b21 stood clear of the kit blocks but a palm's crown in
+ /// front of it (south, on the camera's side) covered it. The kit trees are 100 times life size (KitScale.Trees), the b21
+ /// 24 times (SettlementKits.ModelScale), so a tree a few kilometres south of it can hide it. For each major city's
+ /// workshop as the layer draws it, no kit tree is drawn (VegetationLayer.Drawable) whose crown reaches its sight lane:
+ /// across, the drawn model's width; along, from its north face south to where the ray from its south face's foot toward
+ /// the camera, at the view's shallowest depression (CameraRig.Pitch - Fov / 2), passes over that tree's top (the tree
+ /// mesh's top, Vegetation.BuildMesh, at the instance's scale, over the ground it stands on). Each lane's planted trees
+ /// left out are counted and logged.</summary>
+ [Test]
+ public void NoKitTreeStandsInAMajorCitysWorkshopSightLane()
+ {
+ var map = OpenMap();
+ var c = Rules(Statecraft.Sim.SaveGame.Gdd03Ruleset);
+ var veg = map.GetComponentInChildren<Statecraft.Game.Map.Kits.VegetationLayer>(true);
+ Assert.IsNotNull(veg, "the map plants its kit trees");
+ var majors = c.SettlementHexes.Select(h => h.Id).Where(Statecraft.Game.Map.Kits.TownModels.IsMajorCity).OrderBy(x => x, StringComparer.Ordinal).ToList();
+ var projects = majors.Select((city, i) => Workshop(c, 700 + i, city, Built)).ToList();
+ var layer = CollectionGeometryFixture.Special(map, After, c, projects)!;
+ AnswerAll();
+ var topM = new Dictionary<Statecraft.Game.Map.Kits.TreeKind, float>();
+ foreach (Statecraft.Game.Map.Kits.TreeKind k in Enum.GetValues(typeof(Statecraft.Game.Map.Kits.TreeKind)))
+ {
+ var mesh = Statecraft.Game.Map.Kits.Vegetation.BuildMesh(k);
+ topM[k] = mesh.bounds.max.y;
+ UnityEngine.Object.DestroyImmediate(mesh);
+ }
+ float tan = Mathf.Tan(Shallowest * Mathf.Deg2Rad);
+ var failures = new List<string>();
+ foreach (var project in projects)
+ {
+ string key = SpecialBuildingModels.WorkshopKey(project.Id);
+ var model = layer.transform.Find(key);
+ if (model == null) { failures.Add($"{project.City}: {key} is not drawn"); continue; }
+ var mb = model.GetComponentsInChildren<Renderer>(true).Select(x => x.bounds).Aggregate((x, y) => { x.Encapsulate(y); return x; });
+ bool InLane(Statecraft.Game.Map.Kits.TreeKind kind, Matrix4x4 m)
+ {
+ var p = (Vector3)m.GetColumn(3);
+ float crown = Statecraft.Game.Map.Kits.VegetationLayer.CrownRadius(kind, m);
+ float top = p.y + topM[kind] * ((Vector3)m.GetColumn(1)).magnitude;
+ return Mathf.Abs(p.x - mb.center.x) < mb.extents.x + crown && p.z - crown < mb.max.z
+ && (mb.min.z - p.z) - crown < (top - mb.min.y) / tan;
+ }
+ int planted = veg.Planted().Count(t => InLane(t.kind, t.m));
+ var drawn = veg.Drawable().Where(t => InLane(t.kind, t.m)).ToList();
+ TestContext.WriteLine(FormattableString.Invariant($"{key} ({project.City}): {planted} planted trees in its sight lane, {planted - drawn.Count} left out, {drawn.Count} drawn"));
+ if (drawn.Count > 0)
+ {
+ var p = drawn[0].m.GetColumn(3);
+ failures.Add(FormattableString.Invariant($"{project.City}: {key}: {drawn.Count} kit trees drawn in its sight lane; first a {drawn[0].kind} at ({p.x:0}, {p.z:0})"));
+ }
+ }
+ Assert.IsEmpty(failures, string.Join("\n", failures));
+ }
+
+ /// <summary>A point's offset from a centre: metres, compass bearing (0 north, 90 east) and the world point.</summary>
+ static string Offset(Vector2 p, Vector2 centre)
+ {
+ var d = p - centre;
+ float bearing = Mathf.Repeat(Mathf.Atan2(d.x, d.y) * Mathf.Rad2Deg, 360f);
+ return FormattableString.Invariant($"{d.magnitude:0} m at bearing {bearing:0} deg ({p.x:0}, {p.y:0})");
+ }
+
+ /// <summary>Whether the ray from <paramref name="q"/> along <paramref name="dir"/> (rising: dir.y &gt; 0) meets the upright box
+ /// centred at <paramref name="c"/> (x, z), turned <paramref name="yawDeg"/> anticlockwise in x-z (KitMesh.Corners), w along its
+ /// turn and d across, from below the ground up to <paramref name="top"/> (world y). Slabs: the ray is inside the box for
+ /// the parameters t within both side slabs and below the top; touching counts as missing.</summary>
+ static bool RayMeetsBox(Vector3 q, Vector3 dir, Vector2 c, float yawDeg, float w, float d, float top)
+ {
+ if (q.y >= top) return false; // the ray rises, so from above the top it never comes down into the box
+ float a = yawDeg * Mathf.Deg2Rad;
+ var u = new Vector2(Mathf.Cos(a), Mathf.Sin(a)); var v = new Vector2(-u.y, u.x);
+ var rel = new Vector2(q.x - c.x, q.z - c.y); var flat = new Vector2(dir.x, dir.z);
+ float t0 = 0f, t1 = (top - q.y) / dir.y;
+ foreach (var (axis, halfSide) in new[] { (u, 0.5f * w), (v, 0.5f * d) })
+ {
+ float o = Vector2.Dot(rel, axis), s = Vector2.Dot(flat, axis);
+ if (Mathf.Abs(s) < 1e-7f) { if (Mathf.Abs(o) >= halfSide) return false; continue; }
+ float ta = (-halfSide - o) / s, tb = (halfSide - o) / s;
+ t0 = Mathf.Max(t0, Mathf.Min(ta, tb)); t1 = Mathf.Min(t1, Mathf.Max(ta, tb));
+ if (t0 >= t1) return false;
+ }
+ return true;
+ }
+
+ /// <summary>Whether two boxes, each centred at c, turned yaw degrees anticlockwise in x-z (KitMesh.Corners), w along its turn
+ /// and d across, are apart (touching counts as apart): some side's axis separates them (the separating axis test).</summary>
+ static bool BoxesApart(Vector2 c1, float yaw1, float w1, float d1, Vector2 c2, float yaw2, float w2, float d2)
+ {
+ float a1 = yaw1 * Mathf.Deg2Rad, a2 = yaw2 * Mathf.Deg2Rad;
+ var u1 = new Vector2(Mathf.Cos(a1), Mathf.Sin(a1)); var v1 = new Vector2(-u1.y, u1.x);
+ var u2 = new Vector2(Mathf.Cos(a2), Mathf.Sin(a2)); var v2 = new Vector2(-u2.y, u2.x);
+ foreach (var n in new[] { u1, v1, u2, v2 })
+ {
+ float reach1 = 0.5f * w1 * Mathf.Abs(Vector2.Dot(u1, n)) + 0.5f * d1 * Mathf.Abs(Vector2.Dot(v1, n));
+ float reach2 = 0.5f * w2 * Mathf.Abs(Vector2.Dot(u2, n)) + 0.5f * d2 * Mathf.Abs(Vector2.Dot(v2, n));
+ if (Mathf.Abs(Vector2.Dot(c2 - c1, n)) >= reach1 + reach2) return true;
+ }
+ return false;
}
/// <summary>Review of #2281 (N3): every building takes its planned ground whether or not its model has streamed. A
@@ -1171,7 +2051,8 @@ namespace Statecraft.Game.Tests
var near = fortAt + 400f * side;
var (lon, lat) = map.Frame.ToLonLat(new Vector3(near.x, 0f, near.y));
wants = SpecialBuildingModels.Placements(After)
- .Append(new SpecialBuildingModels.Want(key41, SpecialBuildingModels.Workshop, Built, lon, lat, "test: by the fort's spot"))
+ .Append(new SpecialBuildingModels.Want(key41, SpecialBuildingModels.Workshop, Built, null, lon, lat, "test: by the fort's spot",
+ SpecialBuildingModels.Siting.Seeded, "", SpecialBuildingModels.WorkshopScale))
.ToList();
full = SpecialBuildingModels.Plan(map, After, wants, _ => true, log: false).ToDictionary(x => x.want.Key, x => x.at);
var withoutFort = SpecialBuildingModels.Plan(map, After, wants.Where(w => w.Key != "latrun_tegart").ToList(), _ => true, log: false)
@@ -1234,14 +2115,14 @@ namespace Statecraft.Game.Tests
AnswerAll(); // b21 streams in after the labels read the boxes
var first = layer.KeepClearFor(cam);
Assert.AreNotSame(before, first, "a new list once the b21 is drawn");
- Assert.AreEqual(1, first.Count);
+ Assert.AreEqual(1, first.Count, "rehovot's b21 drawn (#2876: none means rehovot lost its spot)");
Assert.AreEqual(0, before.Count, "the list handed out before is unchanged");
CollectionGeometryFixture.Special(map, After, c, new[] { one[0], Workshop(c, 52, "hadera", Built) }); // a second workshop
AnswerAll();
layer.Choose(default, cam);
var second = layer.KeepClearFor(cam);
Assert.AreNotSame(first, second, "a new list for the second b21");
- Assert.AreEqual(2, second.Count);
+ Assert.AreEqual(2, second.Count, "rehovot's and hadera's b21 drawn (#2876: one means a town lost its spot)");
Assert.AreEqual(1, first.Count, "the list handed out before is unchanged");
}
@@ -1259,8 +2140,12 @@ namespace Statecraft.Game.Tests
Assert.Greater(tokens, 0, "premise: some dated tokens end in between");
var atBuilt = SpecialBuildingModels.Plan(map, Built, wants, _ => true, log: false).ToDictionary(x => x.want.Key, x => x.at);
var later = SpecialBuildingModels.Plan(map, After, wants, _ => true, log: false).ToDictionary(x => x.want.Key, x => x.at);
- CollectionAssert.AreEquivalent(atBuilt.Keys, later.Keys, "the same workshops stand");
- foreach (var kv in atBuilt) Assert.AreEqual(kv.Value, later[kv.Key], kv.Key + " on the same spot at the later date");
+ // #2876: each town named (the b21 at 2.5x keeps a wider clearance, so a crowded town may lose its spot).
+ var cityOf = projects.ToDictionary(p => SpecialBuildingModels.WorkshopKey(p.Id), p => p.City);
+ var lost = projects.Where(p => !atBuilt.ContainsKey(SpecialBuildingModels.WorkshopKey(p.Id))).Select(p => p.City).ToList();
+ TestContext.WriteLine(lost.Count == 0 ? "every town's workshop gets a spot" : "no spot for the workshop in: " + string.Join(", ", lost));
+ CollectionAssert.AreEquivalent(atBuilt.Keys.Select(k => cityOf[k]), later.Keys.Select(k => cityOf[k]), "the same towns' workshops stand");
+ foreach (var kv in atBuilt) Assert.AreEqual(kv.Value, later[kv.Key], kv.Key + " (" + cityOf[kv.Key] + ") on the same spot at the later date");
}
/// <summary>Review of #2281 (N1): the ground a unit spot's figures hide (SpecialBuildingModels.Hidden), edge by edge: north
@@ -1294,7 +2179,7 @@ namespace Statecraft.Game.Tests
var built = new[] { Workshop(c, 9, "rehovot", Built) };
CollectionGeometryFixture.Special(map, Built, c, built);
AnswerAll();
- CollectionAssert.Contains(layer.Placed.Select(p => p.Key), key, "from the turn the build completes");
+ CollectionAssert.Contains(layer.Placed.Select(p => p.Key), key, "rehovot's b21 from the turn the build completes");
var model = layer.transform.Find(key)!.gameObject;
CollectionGeometryFixture.Special(map, Built, c, new[] { Workshop(c, 9, "rehovot", Built) });
Assert.IsTrue(model != null && model.transform.parent == layer.transform, "the same state keeps the same model");
@@ -1337,7 +2222,8 @@ namespace Statecraft.Game.Tests
for (int i = 0; i < farms.Count; i++)
{
var (lon, lat) = map.Frame.ToLonLat(new Vector3(farms[i].spot.x, 0f, farms[i].spot.y));
- wants.Add(new SpecialBuildingModels.Want(SpecialBuildingModels.WorkshopKey(500 + i), SpecialBuildingModels.Workshop, Built, lon, lat, "test: at a farm scene"));
+ wants.Add(new SpecialBuildingModels.Want(SpecialBuildingModels.WorkshopKey(500 + i), SpecialBuildingModels.Workshop, Built, null, lon, lat, "test: at a farm scene",
+ SpecialBuildingModels.Siting.Seeded, "", SpecialBuildingModels.WorkshopScale)); // at its drawn scale, as ArmsWorkshops' rows (#2876)
}
SpecialBuildingModels Layer()
{
diff --git a/unity/Assets/Tests/EditMode/TalModelsShots.cs b/unity/Assets/Tests/EditMode/TalModelsShots.cs
index e6e575118..339e3ba31 100644
--- a/unity/Assets/Tests/EditMode/TalModelsShots.cs
+++ b/unity/Assets/Tests/EditMode/TalModelsShots.cs
@@ -413,7 +413,9 @@ public class TalModelsShots
return ms[ms.Count / 2];
}
- /// <summary>Owner ruling, 2 November 2026, "Yes, small buildings at every zoom": Tel Aviv, Jerusalem, Haifa and Jaffa from
+ /// <summary>Written for the owner's ruling of 2 November 2026, "Yes, small buildings at every zoom" (superseded on 6 November
+ /// 2026 by "Big blocks, every zoom": these four draw their kits from 40 km out, and since 7 November 2026, "Tal's models
+ /// close (Recommended)", their building models below it; MajorCityShots shows them): Tel Aviv, Jerusalem, Haifa and Jaffa from
/// the opening view (the game's own camera, CameraRig.StartDistance), 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
diff --git a/unity/Assets/Tests/EditMode/TownCensusTests.cs b/unity/Assets/Tests/EditMode/TownCensusTests.cs
index 9417fcb30..6c07d5e05 100644
--- a/unity/Assets/Tests/EditMode/TownCensusTests.cs
+++ b/unity/Assets/Tests/EditMode/TownCensusTests.cs
@@ -178,6 +178,40 @@ public class TownCensusTests
Assert.Greater(aqsa.W, aqsa.D, "Al-Aqsa runs across the south end, not down it");
}
+ /// <summary>#2876: Tel Aviv's port sheds draw as three sheds, not as one long strip. The major cities draw their kits from
+ /// 40 km out (TownModels.IsMajorCity; below the close switch Tal's b32 models, owner, 7 November 2026, "Tal's models close
+ /// (Recommended)"), so there the sheds stand at the landmarks' symbolic scale (KitScale.Landmarks). They stand in a row along the shore (SettlementKits.TelAvivPort),
+ /// which runs north-south there, and the camera looks north (CameraRig, yaw 0) down at CameraRig.Pitch: a shed hides the
+ /// ground behind it for its height times cot(Pitch - Fov/2) at the view's shallowest ray (as
+ /// SpecialBuildingModels.FigureShadowM takes it), about 471 m for a 5 m shed at 60x. The clear gap between neighbours'
+ /// roofs (KitMesh.Gable's eaves reach 3% of the length past each end) must be wider than that, or the next shed's foot is
+ /// hidden and the row reads as one block. 15 m sheds on the 17 m pitch left 66 m.</summary>
+ [Test]
+ public void TelAvivsPortShedsStandApart()
+ {
+ var map = OpenMap();
+ Census(map, out var placed);
+ var sheds = placed.Where(p => p.Id == "tel_aviv" && p.Kind == "warehouse").ToList();
+ Assert.AreEqual(3, sheds.Count, "Tel Aviv's three port sheds");
+ float a = sheds[0].Yaw * Mathf.Deg2Rad;
+ var along = new Vector2(Mathf.Cos(a), Mathf.Sin(a)); var across = new Vector2(-along.y, along.x);
+ var row = sheds.OrderBy(p => Vector2.Dot(p.C, along)).ToList();
+ float cot = 1f / Mathf.Tan((CameraRig.Pitch - 0.5f * CameraRig.Fov) * Mathf.Deg2Rad);
+ var bad = new List<string>();
+ for (int i = 0; i + 1 < row.Count; i++)
+ {
+ var (s0, s1) = (row[i], row[i + 1]);
+ Assert.AreEqual(s0.Yaw, s1.Yaw, 0.01f, "the sheds stand parallel in their row");
+ var d = s1.C - s0.C;
+ if (Mathf.Abs(Vector2.Dot(d, across)) >= 0.5f * (s0.D + s1.D)) continue; // side by side, not one behind the other
+ float gap = Vector2.Dot(d, along) - 0.53f * (s0.W + s1.W); // between the roofs' eaves (KitMesh.Gable: 1.06 of the length)
+ float hidden = Mathf.Max(s0.H, s1.H) * cot;
+ TestContext.WriteLine($"sheds at {s0.C} and {s1.C}: {s0.W:0} and {s1.W:0} m long, roof gap {gap:0} m, hidden {hidden:0} m");
+ if (gap <= hidden) bad.Add($"the sheds at {s0.C} and {s1.C} are {gap:0} m apart, under the {hidden:0} m one hides behind it");
+ }
+ CollectionAssert.IsEmpty(bad, "Tel Aviv's port sheds merge into one strip");
+ }
+
/// <summary>No building or landmark stands on a railway or a road (their corridors, RouteLayer.Corridors, and the units'
/// clearings), and none stands in the sea: a building's centre and four corners are dry. Only harbour works (the
/// breakwaters) stand in the water.</summary>
diff --git a/unity/Assets/Tests/EditMode/TownLandmarksTests.cs b/unity/Assets/Tests/EditMode/TownLandmarksTests.cs
index 29aaca57f..8cb71a4bf 100644
--- a/unity/Assets/Tests/EditMode/TownLandmarksTests.cs
+++ b/unity/Assets/Tests/EditMode/TownLandmarksTests.cs
@@ -48,8 +48,12 @@ 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>
+ /// <summary>The four major cities (TownModels.IsMajorCity), written out as the tests' own expectation: no whole-town model
+ /// (owner, 2 November 2026), their kits from 40 km out (owner, 6 November 2026, "Big blocks, every zoom", which
+ /// superseded the 2 November 2026 ruling, "Yes, small buildings at every zoom", that drew their building models at every
+ /// zoom) and their building models below the close switch (owner, 7 November 2026, "Tal's models close (Recommended)",
+ /// which supersedes "Big blocks, every zoom" below 40 km). TownModelResidencyTests.TheMajorCitiesAreThePlacesOfSixtyThousandOrMoreIn1945 checks the
+ /// predicate agrees.</summary>
internal static readonly string[] BigCities = { "tel_aviv", "jerusalem", "haifa", "jaffa" };
static MapScene OpenMap()
@@ -100,8 +104,10 @@ public class TownLandmarksTests
}
/// <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
+ /// on the map (owner, 2 November 2026, "Yes, small buildings at every zoom" (superseded): Tel Aviv, Jerusalem, Haifa and
+ /// Jaffa have no whole-town model, and since 6 November 2026, "Big blocks, every zoom", draw their kits from 40 km out,
+ /// their building models below the switch since 7 November 2026, "Tal's models close (Recommended)";
+ /// 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()
@@ -134,7 +140,9 @@ public class TownLandmarksTests
/// "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>
+ /// towns. The owner's ruling of 6 November 2026, "Big blocks, every zoom", superseded the 2 November one for what these
+ /// four draw from 40 km out (their kits; below the close switch their building models since 7 November 2026, "Tal's
+ /// models close (Recommended)") and keeps them without a whole-town model.</summary>
[Test]
public void TheFourCitiesHaveNoWholeTownModelOnAnyDate()
{
@@ -310,7 +318,9 @@ public class TownLandmarksTests
/// <summary>The swap with #700's building models: the landmarks draw where TownModelLayer draws the kits' far view and
/// hide where it draws the building models (TownModelLayer.CloseAt: in below CloseEnterM, out above CloseExitM), with
/// the same hysteresis, at the start view (CameraRig.StartDistance, 31 km), 90 km, the gameplay view (60 km), both sides
- /// of the band and the closest zoom.</summary>
+ /// of the band and the closest zoom. Over Petah Tikva (where this looked over Tel Aviv before the owner's ruling of
+ /// 6 November 2026, "Big blocks, every zoom"; Tel Aviv draws its building models below the switch again since 7 November
+ /// 2026, "Tal's models close (Recommended)").</summary>
[Test]
public void TheLandmarksSwapWithTheBuildingModelsAtTheThreshold()
{
@@ -320,7 +330,7 @@ public class TownLandmarksTests
Assert.IsTrue(layer.HasModels);
var renderers = t.GetComponentsInChildren<Renderer>(true);
Assert.Greater(renderers.Length, 0);
- var tel = map.KitFootprints.First(f => f.id == "tel_aviv").centre;
+ var petah = map.KitFootprints.First(f => f.id == "petah_tikva").centre;
foreach (var (d, close, why) in new[]
{
(CameraRig.StartDistance, true, "the start view (owner, 3 November 2026: open at ~30 km)"),
@@ -330,7 +340,7 @@ public class TownLandmarksTests
(CameraController.MinDistance, true, "the closest zoom"),
})
{
- RenderAt(map, tel, d);
+ RenderAt(map, petah, d);
Assert.AreEqual(close, layer.LastClose, $"{d / 1000f} km, {why}: the building models");
foreach (var renderer in renderers)
{
@@ -350,8 +360,9 @@ public class TownLandmarksTests
[Test]
public void OnlyTheCurrentCamerasReadyTownsSuppressProceduralHouses()
{
- // 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
+ // Since #2085 every game settlement but the four major cities (no whole-town model since the owner's ruling of 2 November
+ // 2026; their kits from 40 km out since 6 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];
@@ -548,12 +559,13 @@ public class TownLandmarksTests
CollectionAssert.IsEmpty(t.Missing, "every wanted landmark found a spot");
Assert.AreEqual(t.Wanted.Count, t.Placed.Count);
- CollectionAssert.IsEmpty(t.Placed.Where(p => BigCities.Contains(p.Key)), "the four cities draw their buildings instead");
+ CollectionAssert.IsEmpty(t.Placed.Where(p => BigCities.Contains(p.Key)), "the four cities draw their kits 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)") and Jaffa draws its buildings instead ("Yes, small buildings at every zoom"), so the
- // stone village stands at the other five.
+ // ("Yes, Tal's Ramla (Recommended)") and Jaffa lost its stone village ("Yes, small buildings at every zoom", superseded
+ // on 6 November 2026 by "Big blocks, every zoom": Jaffa draws its kit from 40 km out, its building models below the
+ // switch since 7 November 2026, "Tal's models close (Recommended)"), so the stone village stands at the other five.
Assert.AreEqual(7, map.Settlements.Count(s => s.Type == "arab_town"));
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");
diff --git a/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs b/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs
index 5235882ef..c90332dfd 100644
--- a/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs
+++ b/unity/Assets/Tests/EditMode/TownModelResidencyTests.cs
@@ -50,6 +50,17 @@ public class TownModelResidencyTests
return places.Single(place => place.id == id).bounds;
}
+ /// <summary>Whether this camera's focus selection holds the town (its primary or an edge), whether or not its zoom
+ /// admits the town's building models: the selection mechanism alone (the major cities, TownModels.IsMajorCity, are
+ /// admitted only below the close switch: owner, 7 November 2026, "Tal's models close (Recommended)").</summary>
+ static bool Selects(TownModelLayer layer, string id, Camera camera)
+ {
+ var choices = (System.Collections.IDictionary)typeof(TownModelLayer).GetField("choices", Flags)!.GetValue(layer)!;
+ var choice = choices[camera.GetInstanceID()];
+ Assert.IsNotNull(choice, camera.name + ": a prepared camera");
+ return ((HashSet<string>)choice!.GetType().GetField("towns", Flags)!.GetValue(choice)!).Contains(id);
+ }
+
static Camera CopyCamera(Camera source, string name)
{
var camera = new GameObject(name).AddComponent<Camera>();
@@ -68,7 +79,10 @@ public class TownModelResidencyTests
/// <summary>R2: the production camera centres a town on its sourced label point, also the kit-footprint centre. Some
/// detailed instances do not cover that point; admission must therefore use the authoritative footprint union rather
- /// than treating the detailed-instance rectangle as the town itself.</summary>
+ /// than treating the detailed-instance rectangle as the town itself. The focus selects every detailed town there and,
+ /// at 11.8 km (below the close switch), admits its models, the major cities' included (TownModels.IsMajorCity; owner,
+ /// 7 November 2026, "Tal's models close (Recommended)", which supersedes "Big blocks, every zoom" (6 November 2026)
+ /// from 40 km out only).</summary>
[Test]
public void EveryDetailedTownIsAdmittedAtItsLabelAndKitFootprintCentre()
{
@@ -86,6 +100,7 @@ public class TownModelResidencyTests
"the three reported towns must remain in the mapped detailed-model census");
var outsideInstances = new List<string>();
+ var notSelected = new List<string>();
var notAdmitted = new List<string>();
var notReady = new List<string>();
foreach (var town in detailed)
@@ -111,6 +126,7 @@ public class TownModelResidencyTests
$"kit_centre={footprint.centre}; kit_radius={footprint.radius:0.###}m; kit_distance={kitDistance:0.###}m");
layer.PrepareCamera(camera);
+ if (!Selects(layer, town.Id, camera)) notSelected.Add(town.Id);
if (!layer.WantsTown(town.Id, camera)) notAdmitted.Add(town.Id);
if (!layer.ReadyForTown(town.Id, camera)) notReady.Add(town.Id);
}
@@ -121,10 +137,12 @@ public class TownModelResidencyTests
// still checked below with every other detailed town.
CollectionAssert.IsSubsetOf(new[] { "acre", "jaffa", "tel_aviv" }, outsideInstances,
"the regression evidence must keep covering the measured focus points outside their instance rectangles");
+ CollectionAssert.IsEmpty(notSelected,
+ "a camera focused on each authoritative town footprint must select that town");
CollectionAssert.IsEmpty(notAdmitted,
- "a camera focused on each authoritative town footprint must admit that town's detailed models");
+ "a camera focused on each authoritative town footprint must admit that town's detailed models, a major city's too below the close switch");
CollectionAssert.IsEmpty(notReady,
- "every admitted production town must have every required detailed-model kind");
+ "every admitted production town must have every required detailed-model kind, a major city's too");
}
finally
{
@@ -167,14 +185,21 @@ public class TownModelResidencyTests
pair.from.id + " to " + pair.to.id + " sequential pan camera");
try
{
+ // The selection moves with the pan, and so does the admission: at 11.8 km, below the close switch, a major
+ // city's building models are admitted too (owner, 7 November 2026, "Tal's models close (Recommended)").
layer.PrepareCamera(camera);
+ Assert.IsTrue(Selects(layer, pair.from.id, camera), pair.from.id + ": selected at its own label before the pan");
Assert.IsTrue(layer.WantsTown(pair.from.id, camera), pair.from.id + ": admitted at its own label before the pan");
camera.transform.position = new Vector3(pair.to.centre.x, ReportedCameraDistanceM, pair.to.centre.y);
layer.PrepareCamera(camera);
+ Assert.IsTrue(Selects(layer, pair.to.id, camera),
+ pair.from.id + " -> " + pair.to.id + ": the normalized-distance owner is selected at its label");
Assert.IsTrue(layer.WantsTown(pair.to.id, camera),
pair.from.id + " -> " + pair.to.id + ": the normalized-distance owner is admitted at its label");
- Assert.IsFalse(layer.WantsTown(pair.from.id, camera),
+ Assert.IsFalse(Selects(layer, pair.from.id, camera),
pair.from.id + " -> " + pair.to.id + ": the previous town cannot retain on its whole disc");
+ Assert.IsFalse(layer.WantsTown(pair.from.id, camera),
+ pair.from.id + " -> " + pair.to.id + ": nor its admission");
}
finally { UnityEngine.Object.DestroyImmediate(camera.gameObject); }
}
@@ -333,12 +358,18 @@ public class TownModelResidencyTests
}
try
{
- Move(jaffaSide);
- Assert.IsTrue(layer.WantsTown("jaffa", camera)); Assert.IsFalse(layer.WantsTown("tel_aviv", camera));
- Move(telAvivSide);
- Assert.IsFalse(layer.WantsTown("jaffa", camera)); Assert.IsTrue(layer.WantsTown("tel_aviv", camera));
- Move(jaffaSide);
- Assert.IsFalse(layer.WantsTown("tel_aviv", camera)); Assert.IsTrue(layer.WantsTown("jaffa", camera));
+ // Both are major cities, admitted below the close switch (owner, 7 November 2026, "Tal's models close
+ // (Recommended)"): the selection and the admission cross the seam together.
+ void Expect(string selected, string other)
+ {
+ Assert.IsTrue(Selects(layer, selected, camera), selected + " selected");
+ Assert.IsFalse(Selects(layer, other, camera), other + " not selected");
+ Assert.IsTrue(layer.WantsTown(selected, camera), selected + "'s building models admitted");
+ Assert.IsFalse(layer.WantsTown(other, camera), other + "'s building models not admitted");
+ }
+ Move(jaffaSide); Expect("jaffa", "tel_aviv");
+ Move(telAvivSide); Expect("tel_aviv", "jaffa");
+ Move(jaffaSide); Expect("jaffa", "tel_aviv");
}
finally { UnityEngine.Object.DestroyImmediate(camera.gameObject); }
}
@@ -948,40 +979,51 @@ public class TownModelResidencyTests
}
/// <summary>A town's neighbours in view load too, not only the town under the screen centre; the focused town's kinds
- /// are asked first (nearest first).</summary>
+ /// are asked first (nearest first). Over Petah Tikva its kinds come first; over Tel Aviv at 30 km, below the close
+ /// switch, Tel Aviv, Jaffa and Petah Tikva all load, the two major cities' models in place of their kits (owner,
+ /// 7 November 2026, "Tal's models close (Recommended)").</summary>
[Test]
public void NeighbouringTownsOfTheFocusLoadToo()
{
using var s = new StreamedMap();
+ var petah = s.Footprint("petah_tikva");
+ var first = s.Camera(petah.centre, ThirtyKmM);
+ s.Settle(first);
+ Assert.IsTrue(s.layer.ReadyForTown("petah_tikva", first), "Petah Tikva at 30 km over it: admitted and ready");
+ var petahKinds = s.layer.InstancesOf("petah_tikva").Select(m => TownModels.Ids[(int)m.Model]).ToHashSet(StringComparer.Ordinal);
+ CollectionAssert.Contains(petahKinds, s.RequestOrder[0], "the focused town's kinds are asked first");
var telAviv = s.Footprint("tel_aviv");
var camera = s.Camera(telAviv.centre, ThirtyKmM);
s.Settle(camera);
foreach (var id in new[] { "tel_aviv", "jaffa", "petah_tikva" })
- {
Assert.Greater(s.layer.CountFor(id), 0, id + " has building models");
- Assert.IsTrue(s.layer.ReadyForTown(id, camera), id + " at 30 km over Tel Aviv: admitted and ready");
+ Assert.IsTrue(s.layer.ReadyForTown("petah_tikva", camera), "petah_tikva at 30 km over Tel Aviv: admitted and ready");
+ foreach (var id in new[] { "tel_aviv", "jaffa" })
+ {
+ Assert.IsTrue(s.layer.ReadyForTown(id, camera), id + " at 30 km over Tel Aviv: a major city below the close switch, admitted and ready");
+ Assert.IsTrue(s.kits.Find(id).GetComponent<MeshRenderer>().forceRenderingOff, id + " at 30 km over Tel Aviv: its kit gives way");
}
- var telAvivKinds = s.layer.InstancesOf("tel_aviv").Select(m => TownModels.Ids[(int)m.Model]).ToHashSet(StringComparer.Ordinal);
- CollectionAssert.Contains(telAvivKinds, s.RequestOrder[0], "the focused town's kinds are asked first");
var jaffa = s.Footprint("jaffa");
s.Pose(camera, jaffa.centre, TwelveKmM); s.Settle(camera);
- Assert.IsTrue(s.layer.ReadyForTown("jaffa", camera), "Jaffa at 12 km");
- Assert.IsTrue(s.layer.ReadyForTown("tel_aviv", camera), "Tel Aviv beside Jaffa at 12 km");
+ Assert.IsTrue(s.layer.ReadyForTown("jaffa", camera), "Jaffa at 12 km: its building models");
+ Assert.IsTrue(s.layer.ReadyForTown("tel_aviv", camera), "Tel Aviv beside Jaffa at 12 km: its building models");
}
- /// <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 (the far-off copies beyond the close switch, #2378). A town with a whole-town model
- /// in view at 90 km (Petah Tikva) draws its far-off copies too (owner, 3 November 2026, "Cities/towns only
- /// (Recommended)").</summary>
+ /// <summary>Owner ruling, 7 November 2026, "Tal's models close (Recommended)" (it supersedes "Big blocks, every zoom",
+ /// 6 November 2026, below the 40 km close switch; from 40 km out that ruling stands). In the player's streaming path and
+ /// the production policy, each of the four cities in view keeps its kit at the widest zoom (250 km), the opening zoom
+ /// (90 km) and the gameplay view (60 km): its building models are not admitted there and the kit never gives way. At
+ /// 30 km and the closest zoom, below the close switch, Tal Heuberger's building models are admitted, the kit gives way
+ /// and the models draw. A town with a whole-town model in view at 90 km (Petah Tikva) draws its far-off copies (owner,
+ /// 3 November 2026, "Cities/towns only (Recommended)").</summary>
[Test]
- public void TheFourCitiesDrawTheirBuildingModelsAtEveryZoom()
+ public void TheFourCitiesKeepTheirKitsFarAndDrawTalsModelsClose()
{
using var s = new StreamedMap();
+ var majors = s.map.Settlements.Where(x => TownModels.IsMajorCity(x.Id)).Select(x => x.Id).ToList();
+ Assert.AreEqual(4, majors.Count, "the four major cities");
// First, a fresh camera over Petah Tikva (beside Tel Aviv and Jaffa) at the opening zoom: it draws its far-off copies
- // (Q15 option a: the cities and the towns), and only far-off copies are asked for.
+ // (Q15 option a: the towns), and only far-off copies are asked for.
var petah = s.Footprint("petah_tikva");
var far = s.Camera(petah.centre, 90_000f);
s.Settle(far);
@@ -989,46 +1031,50 @@ public class TownModelResidencyTests
Assert.IsTrue(s.kits.Find("petah_tikva").GetComponent<MeshRenderer>().forceRenderingOff, "Petah Tikva's kit gives way at 90 km");
CollectionAssert.IsSubsetOf(s.layer.InstancesOf("petah_tikva").Select(m => CollectionCatalog.FarCopy(TownModels.Ids[(int)m.Model])).Distinct().ToList(),
s.RequestOrder.Distinct().ToList(), "Petah Tikva's far-off copies are asked for");
- Assert.IsTrue(s.layer.ReadyForTown("tel_aviv", far), "Tel Aviv in the same view: its building models");
+ Assert.IsFalse(s.layer.ReadyForTown("tel_aviv", far), "Tel Aviv in the same view: its kit, no building models");
CollectionAssert.IsNotEmpty(s.RequestOrder);
- // #2378: far off only far-off copies are asked for, never an original; the cities' among them.
+ // #2378: far off only far-off copies are asked for, never an original. (That no far-off copy of a kind only the major
+ // cities place is asked for: TheMajorCitiesDrawTheirKitsFarAndTalsModelsBelowTheCloseSwitch.)
foreach (var id in s.RequestOrder) Assert.IsTrue(CollectionCatalog.IsFarCopy(id), "far off, asked for an original: " + id);
- CollectionAssert.IsSubsetOf(s.layer.InstancesOf("tel_aviv").Select(m => CollectionCatalog.FarCopy(TownModels.Ids[(int)m.Model])).Distinct().ToList(),
- s.RequestOrder.Distinct().ToList(), "Tel Aviv's far-off copies 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)
+ if (ids.Length > 1) CollectionAssert.IsEmpty(ids.Intersect(majors).ToList(), string.Join(",", ids));
+ foreach (var id in majors)
{
var at = s.Footprint(id).centre;
- Assert.Greater(s.layer.CountFor(id), 0, id + " has building models");
+ Assert.Greater(s.layer.CountFor(id), 0, id + " has building models placed");
var kit = s.kits.Find(id).GetComponent<MeshRenderer>();
foreach (float d in new[] { CameraController.MaxDistance, 90_000f, GameplayM, ThirtyKmM, CameraController.MinDistance })
{
+ bool close = d <= TownModelLayer.CloseEnterM;
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");
+ Assert.AreEqual(close, s.layer.ReadyForTown(id, camera), where + (close ? ": building models admitted and ready" : ": building models not admitted"));
+ Assert.AreEqual(close, kit.forceRenderingOff, where + (close ? ": the kit gives way" : ": the kit draws"));
s.Submit(camera);
- Assert.Greater(s.layer.LastDrawn, 0, where + ": the building models draw");
+ if (close) 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>
+ /// buildings' shadows beyond 40 km now"). Beyond the close switch the buildings (the far-off copies) draw without casting
+ /// shadows (90 km and the 60 km gameplay view); below it every building casts as before (30 km and the closest zoom).
+ /// Over Petah Tikva, a town with far-off copies: the four cities, whose building models this tested before, keep their
+ /// kits from 40 km out (owner, 6 November 2026, "Big blocks, every zoom"; below 40 km they draw Tal's models: owner,
+ /// 7 November 2026, "Tal's models close (Recommended)"), so take no far-off copies, and nothing draws far-off copies
+ /// beyond the far band (250 km).</summary>
[Test]
- public void TheFourCitiesBuildingsCastNoShadowsFarOff()
+ public void TheBuildingsCastNoShadowsFarOff()
{
using var s = new StreamedMap();
- foreach (var id in TownLandmarksTests.BigCities)
+ foreach (var id in new[] { "petah_tikva" })
{
var at = s.Footprint(id).centre;
- foreach (var (d, cast) in new[] { (CameraController.MaxDistance, false), (90_000f, false), (ThirtyKmM, true), (CameraController.MinDistance, true) })
+ foreach (var (d, cast) in new[] { (90_000f, false), (GameplayM, false), (ThirtyKmM, true), (CameraController.MinDistance, true) })
{
var camera = s.Camera(at, d);
string where = FormattableString.Invariant($"{id} at {d / 1000f} km");
@@ -1041,14 +1087,16 @@ public class TownModelResidencyTests
}
/// <summary>The v0.3.7 web perf fix: the web tier's last quality fallback step (QualityFallback.Steps, TownModelsFar)
- /// sets TownModelLayer.LowTier. Over Tel Aviv at the 30 km opening (CameraRig.StartDistance, below the close switch) the
- /// buildings then draw their far-off copies with no shadow casters instead of the originals with every building
- /// casting; clearing it puts the originals and their shadows back, both with the camera unmoved.</summary>
+ /// sets TownModelLayer.LowTier. Over Petah Tikva at the 30 km opening (CameraRig.StartDistance, below the close switch)
+ /// the buildings then draw their far-off copies with no shadow casters instead of the originals with every building
+ /// casting; clearing it puts the originals and their shadows back, both with the camera unmoved. (Over Petah Tikva, not
+ /// Tel Aviv: Tel Aviv takes no far-off copies; it keeps its kit from 40 km out, owner, 6 November 2026, "Big blocks,
+ /// every zoom", and the low tier counts as past the close switch.)</summary>
[Test]
public void TheLowTierDrawsTheFarCopiesWithoutShadowsAtTheOpeningAndClearingItPutsTheOriginalsBack()
{
using var s = new StreamedMap();
- var at = s.Footprint("tel_aviv").centre;
+ var at = s.Footprint("petah_tikva").centre;
var camera = s.Camera(at, CameraRig.StartDistance);
try
{
@@ -1060,7 +1108,7 @@ public class TownModelResidencyTests
TownModelLayer.LowTier = true;
s.Settle(camera); s.Submit(camera);
Assert.IsFalse(s.layer.LastClose, "the low tier is past the close switch at the opening");
- Assert.Greater(s.layer.LastDrawn, 0, "Tel Aviv's buildings still draw (the far copies)");
+ Assert.Greater(s.layer.LastDrawn, 0, "Petah Tikva's buildings still draw (the far copies)");
Assert.AreEqual(0, s.layer.LastShadowCasters, "and cast no shadows");
TownModelLayer.LowTier = false;
@@ -1072,75 +1120,82 @@ public class TownModelResidencyTests
}
/// <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>
+ /// out above CloseExitM, 45 km). Over Petah Tikva, 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. (Over Petah Tikva, not Tel Aviv:
+ /// Tel Aviv draws no building model from 40 km out, owner, 6 November 2026, "Big blocks, every zoom"; its own switch:
+ /// TheMajorCitiesDrawTheirKitsFarAndTalsModelsBelowTheCloseSwitch.)</summary>
[Test]
- public void TheFourCitiesShadowsFollowTheCloseSwitchBothWays()
+ public void TheBuildingsShadowsFollowTheCloseSwitchBothWays()
{
using var s = new StreamedMap();
- var at = s.Footprint("tel_aviv").centre;
+ var at = s.Footprint("petah_tikva").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");
+ string where = FormattableString.Invariant($"Petah Tikva 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>
+ /// <summary>The far view (the far band, where the far-off copies draw) is a common one: once settled, a far camera's draw
+ /// submission allocates nothing (no frustum array per camera per frame). Over Petah Tikva at 90 km: the four cities keep
+ /// their kits from 40 km out (owner, 6 November 2026, "Big blocks, every zoom"), and at 250 km no building model
+ /// draws.</summary>
[Test]
public void AFarViewSubmitsWithoutAllocating()
{
using var s = new StreamedMap();
- var camera = s.Camera(s.Footprint("tel_aviv").centre, CameraController.MaxDistance);
+ var camera = s.Camera(s.Footprint("petah_tikva").centre, 90_000f);
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");
+ Assert.IsFalse(s.layer.LastClose, "a far view");
+ Assert.Greater(s.layer.LastDrawn, 0, "the far-off copies draw at 90 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: its far-off copy at 90 km, the original at
- /// 2 km): the city keeps its code-built kit there (it has no whole-town model to fall back to), the map draws on, the
- /// original is asked for once, the far-off copy once per visit of the far band (its lease retires at 2 km), and the
- /// layer warns once for each failed id.</summary>
+ /// <summary>A failed building bundle in a town that draws far-off copies (Petah Tikva's first kind: its far-off copy at
+ /// 90 km, the original at 2 km): the town keeps its code-built kit there (in this fixture no whole-town model stands in),
+ /// the map draws on, the original is asked for once, the far-off copy once per visit of the far band (its lease retires
+ /// at 2 km), and the layer warns once for each failed id. (Petah Tikva, not Tel Aviv's b01: Tel Aviv takes no far-off
+ /// copies, keeping its kit from 40 km out, owner, 6 November 2026, "Big blocks, every zoom".)</summary>
[Test]
public void ACityWhoseBuildingBundleFailsKeepsItsKit()
{
using var s = new StreamedMap();
- const string original = "b01-white-city-v2"; string far = CollectionCatalog.FarCopy(original);
+ string original = TownModels.Ids[(int)s.layer.InstancesOf("petah_tikva")[0].Model]; string far = CollectionCatalog.FarCopy(original);
int warnings = 0;
void Count(string message, string _, LogType type) { if (type == LogType.Warning && message.Contains(original)) warnings++; }
Application.logMessageReceived += Count;
try
{
- var at = s.Footprint("tel_aviv").centre;
- var kit = s.kits.Find("tel_aviv").GetComponent<MeshRenderer>();
+ var at = s.Footprint("petah_tikva").centre;
+ var kit = s.kits.Find("petah_tikva").GetComponent<MeshRenderer>();
var camera = s.Camera(at, 90_000f);
foreach (var (d, failed) in new[] { (90_000f, far), (2_000f, original), (90_000f, far) })
{
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 " + failed);
+ string where = FormattableString.Invariant($"Petah Tikva at {d / 1000f} km");
+ Assert.IsFalse(s.layer.ReadyForTown("petah_tikva", camera), where + ": not ready without " + failed);
Assert.IsFalse(kit.forceRenderingOff, where + ": the kit draws");
Assert.DoesNotThrow(() => s.Submit(camera), where);
}
- Assert.AreEqual(2, s.RequestOrder.Count(id => id == far), "the far-off copy of b01 is asked for once per far visit");
- Assert.AreEqual(1, s.RequestOrder.Count(id => id == original), "b01 is asked for once");
+ Assert.AreEqual(2, s.RequestOrder.Count(id => id == far), "the far-off copy of " + original + " is asked for once per far visit");
+ Assert.AreEqual(1, s.RequestOrder.Count(id => id == original), original + " is asked for once");
Assert.AreEqual(2, warnings, "one warning for each failed id");
}
finally { Application.logMessageReceived -= Count; }
}
- /// <summary>The 1.5 GB guard: zooming out to the 60 km gameplay view releases every original's lease (the four cities'
- /// too: beyond the close switch they draw their far-off copies, #2378) and asks for far-off copies instead; until those
- /// arrive the kits draw again.</summary>
+ /// <summary>The 1.5 GB guard: zooming out to the 60 km gameplay view releases every original's lease and asks for
+ /// far-off copies instead (#2378); until those arrive the kits draw again. The four cities in view are not admitted
+ /// from 40 km out (owner, 6 November 2026, "Big blocks, every zoom"; below it they are: owner, 7 November 2026, "Tal's
+ /// models close (Recommended)").</summary>
[Test]
public void BuildingModelsUnloadAtSixtyKm()
{
@@ -1155,12 +1210,13 @@ public class TownModelResidencyTests
int originals = s.RequestOrder.Count;
s.Pose(camera, imwas.centre, GameplayM);
s.layer.PrepareCamera(camera); s.layer.RetireReleasedModels();
- // 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.
- 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");
- Assert.AreEqual(originals, s.Released, "every original's lease is released at 60 km, the cities' too");
+ // From 60 km over Imwas the view holds Jerusalem, Tel Aviv and Jaffa, not Haifa; none of them is admitted from 40 km
+ // out (owner, 6 November 2026, "Big blocks, every zoom"; "Tal's models close (Recommended)", 7 November 2026, admits
+ // them only below the close switch).
+ var majors = s.map.Settlements.Where(x => TownModels.IsMajorCity(x.Id)).Select(x => x.Id).ToList();
+ Assert.AreEqual(4, majors.Count, "the four major cities");
+ CollectionAssert.IsEmpty(majors.Where(id => s.layer.AdmitsTown(id, camera)).ToList(), "no major city admitted at 60 km over Imwas");
+ Assert.AreEqual(originals, s.Released, "every original's lease is released at 60 km");
var residency = s.layer.ResidencySnapshot();
Assert.AreEqual(0, residency.strongCacheRefs, "no original mesh or material is strongly referenced after unload");
CollectionAssert.IsEmpty(residency.detailIds.Where(id => id.EndsWith("|Near", StringComparison.Ordinal)).ToList(),
@@ -1172,35 +1228,150 @@ public class TownModelResidencyTests
Assert.IsFalse(kit.forceRenderingOff, "the kit tile draws again at 60 km");
}
- /// <summary>#2378 (owner, 3 November 2026: "Ask Tal; allow them far off only"): over Tel Aviv a fresh camera at 39 km asks
- /// for the originals and draws them; at 41 km and at 90 km it asks for the far-off copies ("&lt;id&gt;-far",
- /// CollectionCatalog.FarCopy) and never an original, and draws at least the city's instances (the copy stands in the
- /// original's matrix); every kind the city places is asked for at its tier.</summary>
+ /// <summary>#2378 (owner, 3 November 2026: "Ask Tal; allow them far off only"): over Petah Tikva a camera at 39 km
+ /// asks for the originals and draws them; at 41 km and at 90 km it asks for the far-off copies ("&lt;id&gt;-far",
+ /// CollectionCatalog.FarCopy) and never an original, and draws at least the town's instances (the copy stands in the
+ /// original's matrix); every kind the town places is asked for at its tier. (Over Petah Tikva, not Tel Aviv: Tel Aviv
+ /// takes no far-off copies, keeping its kit from 40 km out, owner, 6 November 2026, "Big blocks, every zoom".)</summary>
[Test]
public void BelowTheCloseSwitchTheOriginalsStreamAndBeyondItTheFarCopies()
{
using var s = new StreamedMap();
- var at = s.Footprint("tel_aviv").centre;
- var kinds = s.layer.InstancesOf("tel_aviv").Select(m => TownModels.Ids[(int)m.Model]).Distinct().ToList();
+ var at = s.Footprint("petah_tikva").centre;
+ var kinds = s.layer.InstancesOf("petah_tikva").Select(m => TownModels.Ids[(int)m.Model]).Distinct().ToList();
+ var camera = s.Camera(at, CameraController.MaxDistance);
foreach (var (d, far) in new[] { (39_000f, false), (41_000f, true), (90_000f, true) })
{
- // The earlier cameras stay (nothing retires), so a kind asked for at 41 km is not asked for again at 90 km: the
- // new requests of each pose are checked for their tier, and Tel Aviv's kinds against every request so far.
+ // Each pose starts from the widest zoom, where no building model is admitted (EditMode retires at once), so
+ // every pose asks for its own kinds afresh: the new requests of each pose are checked for their tier, and Petah
+ // Tikva's kinds against every request so far.
+ s.Pose(camera, at, CameraController.MaxDistance); s.layer.PrepareCamera(camera); s.layer.RetireReleasedModels();
+ Assert.AreEqual(0, s.layer.ResidencySnapshot().strongCacheRefs, "nothing held at the widest zoom");
int before = s.RequestOrder.Count;
- var camera = s.Camera(at, d);
- string where = FormattableString.Invariant($"Tel Aviv at {d / 1000f} km");
+ s.Pose(camera, at, d);
+ string where = FormattableString.Invariant($"Petah Tikva at {d / 1000f} km");
s.Settle(camera);
- Assert.IsTrue(s.layer.ReadyForTown("tel_aviv", camera), where + ": ready");
+ Assert.IsTrue(s.layer.ReadyForTown("petah_tikva", camera), where + ": ready");
var asked = s.RequestOrder.Skip(before).Distinct().ToList();
CollectionAssert.IsNotEmpty(asked, where);
foreach (var id in asked) Assert.AreEqual(far, CollectionCatalog.IsFarCopy(id), where + ": asked for " + id);
foreach (var kind in kinds) CollectionAssert.Contains(s.RequestOrder, far ? CollectionCatalog.FarCopy(kind) : kind, where);
s.Submit(camera);
- Assert.GreaterOrEqual(s.layer.LastDrawn, s.layer.CountFor("tel_aviv"), where + ": Tel Aviv's instances drawn");
+ Assert.GreaterOrEqual(s.layer.LastDrawn, s.layer.CountFor("petah_tikva"), where + ": Petah Tikva's instances drawn");
Assert.AreEqual(!far, s.layer.LastClose, where + ": the close switch");
}
}
+ /// <summary>The owner's bug of 6 November 2026 ("the look of the buildings in tel aviv changes when you change the zoom in
+ /// a way that you first see the big buildings and them the small ones"), ruled "Big blocks, every zoom" and "Just the
+ /// four (Recommended)" on 6 November 2026, then "Tal's models close (Recommended)" on 7 November 2026, which supersedes
+ /// "Big blocks, every zoom" below the close switch: from 40 km out (TownModelLayer.CloseEnterM, out again above
+ /// CloseExitM, 45 km, the hysteresis the other layers use) the major cities draw their code-built kit, its landmarks
+ /// with it; below it Tal Heuberger's building models, as on main. One camera over each city's footprint centre walks
+ /// from the widest zoom in through the far band and the close switch's band (42 km coming in: still far) to the closest
+ /// zoom and out again (43 km going out: still close). Far, before the stream answers and once it has, the kit draws, the
+ /// city's close mesh does not swap in and its building models are not ready; close, once settled, the models are ready,
+ /// the kit gives way and the close mesh swaps in. The low tier at the 31 km opening counts as past the switch: the kit.
+ /// Every kind only these cities place is asked for as an original, below the switch, and never as a far-off copy.</summary>
+ [Test]
+ public void TheMajorCitiesDrawTheirKitsFarAndTalsModelsBelowTheCloseSwitch()
+ {
+ using var s = new StreamedMap();
+ var majors = s.map.Settlements.Where(x => TownModels.IsMajorCity(x.Id)).Select(x => x.Id).ToArray();
+ Assert.AreEqual(4, majors.Length, "the four major cities (TheMajorCitiesAreThePlacesOfSixtyThousandOrMoreIn1945)");
+ Assert.AreEqual(40_000f, TownModelLayer.CloseEnterM, "the close switch"); Assert.AreEqual(45_000f, TownModelLayer.CloseExitM, "its exit");
+ (float d, bool close)[] walk = { (250_000f, false), (112_500f, false), (90_000f, false), (60_000f, false), (42_000f, false), (39_000f, true),
+ (CameraRig.StartDistance, true), (6_000f, true), (43_000f, true), (46_000f, false), (101_000f, false), (250_000f, false) };
+ foreach (var id in majors)
+ {
+ var at = s.Footprint(id).centre;
+ var kit = s.kits.Find(id)?.GetComponent<MeshRenderer>();
+ var close = s.kits.Find(id + KitLayer.CloseSuffix)?.GetComponent<MeshRenderer>();
+ Assert.IsNotNull(kit, id + ": its kit"); Assert.IsNotNull(close, id + ": its close mesh");
+ var camera = s.Camera(at, walk[0].d);
+ void Far(string where)
+ {
+ Assert.IsFalse(s.layer.AdmitsTown(id, camera), where + ": building models not admitted");
+ Assert.IsFalse(kit!.forceRenderingOff, where + ": the kit draws");
+ Assert.IsTrue(close!.forceRenderingOff, where + ": the close mesh does not swap in");
+ Assert.IsFalse(s.layer.ReadyForTown(id, camera), where + ": no building models");
+ }
+ void Close(string where)
+ {
+ Assert.IsTrue(s.layer.AdmitsTown(id, camera), where + ": building models admitted");
+ Assert.IsTrue(s.layer.ReadyForTown(id, camera), where + ": building models ready");
+ Assert.IsTrue(kit!.forceRenderingOff, where + ": the kit gives way");
+ Assert.IsFalse(close!.forceRenderingOff, where + ": the close mesh swaps in");
+ s.Submit(camera);
+ Assert.IsTrue(s.layer.LastClose, where + ": the close switch");
+ Assert.Greater(s.layer.LastDrawn, 0, where + ": the building models draw");
+ }
+ foreach (var (d, near) in walk)
+ {
+ string where = FormattableString.Invariant($"{id} at {d / 1000f} km");
+ s.Pose(camera, at, d); s.layer.PrepareCamera(camera);
+ if (near) Assert.IsTrue(s.layer.AdmitsTown(id, camera), where + ", before the stream answers: admitted");
+ else Far(where + ", before the stream answers");
+ s.Settle(camera);
+ if (near) Close(where + ", settled"); else Far(where + ", settled");
+ }
+ try
+ {
+ TownModelLayer.LowTier = true;
+ string where = FormattableString.Invariant($"{id} at {CameraRig.StartDistance / 1000f} km on the low tier");
+ s.Pose(camera, at, CameraRig.StartDistance); s.layer.PrepareCamera(camera);
+ Far(where + ", before the stream answers");
+ s.Settle(camera);
+ Far(where + ", settled");
+ }
+ finally { TownModelLayer.LowTier = false; }
+ }
+ // The kinds only the major cities place, from the data: every other place's instances (the other game settlements and
+ // the 1948 localities) leave them out.
+ var perPlace = (System.Collections.IDictionary)typeof(TownModelLayer).GetField("perPlace", Flags)!.GetValue(s.layer)!;
+ var elsewhere = new HashSet<TownModel>();
+ foreach (string place in perPlace.Keys)
+ if (!majors.Contains(place)) foreach (var m in s.layer.InstancesOf(place)) elsewhere.Add(m.Model);
+ var cityOnly = majors.SelectMany(id => s.layer.InstancesOf(id)).Select(m => m.Model).Where(k => !elsewhere.Contains(k))
+ .Distinct().OrderBy(k => k).ToList();
+ TestContext.WriteLine("kinds only the major cities place: " + string.Join(", ", cityOnly.Select(k => TownModels.Ids[(int)k])));
+ CollectionAssert.IsNotEmpty(cityOnly, "the major cities place kinds of their own (else the check below is vacuous)");
+ foreach (var kind in cityOnly)
+ {
+ string original = TownModels.Ids[(int)kind];
+ CollectionAssert.Contains(s.RequestOrder, original, original + " is asked for below the close switch");
+ CollectionAssert.DoesNotContain(s.RequestOrder, CollectionCatalog.FarCopy(original), original + "'s far-off copy is never asked for");
+ }
+ }
+
+ /// <summary>The major cities are a data predicate (owner, 6 November 2026, "Just the four (Recommended)"): a place is one
+ /// when its 1945 population (content/map/settlement_population_1945.yaml, the table MapScene.Build hands the kits) is at
+ /// least TownModels.MajorCityPopulation, 60,000. Over every game settlement and 1948 locality on the map that is exactly
+ /// Haifa, Jaffa, Jerusalem and Tel Aviv; the next place below it, Gaza (34,250), is not one.</summary>
+ [Test]
+ public void TheMajorCitiesAreThePlacesOfSixtyThousandOrMoreIn1945()
+ {
+ Assert.AreEqual(60_000, TownModels.MajorCityPopulation, "the threshold");
+ bool Major(string id) => TownModels.IsMajorCity(id);
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ try
+ {
+ var map = UnityEngine.Object.FindFirstObjectByType<MapScene>(); map.Build();
+ var places = map.Settlements.Select(x => x.Id).Concat(map.Localities.Select(p => p.Settlement.Id)).Distinct().ToList();
+ CollectionAssert.AreEquivalent(new[] { "haifa", "jaffa", "jerusalem", "tel_aviv" }, places.Where(Major).ToList(), "the major cities");
+ CollectionAssert.AreEquivalent(TownLandmarksTests.BigCities, places.Where(Major).ToList(), "the tests' own list agrees");
+ var next = places.Where(id => !Major(id)).OrderByDescending(id => KitPopulation.Of(id)).ThenBy(id => id, StringComparer.Ordinal).First();
+ Assert.AreEqual("gaza", next, "the next place below the threshold");
+ Assert.AreEqual(34_250, KitPopulation.Of("gaza"), "Gaza's 1945 population");
+ Assert.IsFalse(Major("gaza"), "Gaza is not a major city");
+ }
+ finally
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ VisualToggles.Clear();
+ }
+ }
+
/// <summary>The production view admission (ConfigureProduction) on a synthetic layer: towns and merged village tiles wired
/// as KitLayer wires them (explicit town ids, renderer identities and tile ids), in the player's streaming path. Each
/// model kind is answered only when the test says so.</summary>
diff --git a/unity/Assets/Tests/EditMode/TownModelTests.cs b/unity/Assets/Tests/EditMode/TownModelTests.cs
index 068b3c0a4..a6e1a9e4a 100644
--- a/unity/Assets/Tests/EditMode/TownModelTests.cs
+++ b/unity/Assets/Tests/EditMode/TownModelTests.cs
@@ -193,10 +193,11 @@ public class TownModelTests
{
var map = OpenMap();
var built = Build(map, out var placed);
- // With the four cities drawn from their building models at every zoom (owner, 2 November 2026), which have no whole-town model.
+ // With the four major cities, which have no whole-town model: their building models draw below the close switch
+ // (owner, 7 November 2026, "Tal's models close (Recommended)"), their kits from 40 km out (TownModels.IsMajorCity).
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))}");
+ TestContext.WriteLine($"{mapped.Count} towns with a whole-town model or major cities: {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());
@@ -530,14 +531,16 @@ public class TownModelTests
}
/// <summary>Owner ruling on #700, "Models up close only", and #2378 (owner, 3 November 2026, "allow them far off only"):
- /// at the close views (tel_aviv30, jaffa12) the originals 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. Within the far band (gameplay03 at 60 km, the 90 km opening) the four cities and the towns
- /// with a whole-town model draw their far-off copies instead (owner, 3 November 2026, "Cities/towns only
- /// (Recommended)"), at most TownModels.FarTriangles each, so the 90 km opening stays under four million triangles where
- /// today's originals cost about nine million (the four cities alone); the 1948 localities keep their kits. At diorama02 (250 km)
- /// no model draws. Zooming back out restores the kits. The "kits" toggle stops the models too. The log line is the draw
- /// cost at each pose.</summary>
+ /// at the close views (tel_aviv30, jaffa12, petah_tikva30) the originals draw (well over a hundred), every kit
+ /// individual-town mesh gives way to its close mesh, the major cities' included (mixed locality tiles keep fallback), and
+ /// the models stay within the fixture's complete original-geometry work. The major cities (TownModels.IsMajorCity) draw
+ /// Tal Heuberger's models below the close switch (owner, 7 November 2026, "Tal's models close (Recommended)") and keep
+ /// their kits from 40 km out (owner, 6 November 2026, "Big blocks, every zoom", which "Tal's models close
+ /// (Recommended)" supersedes below the switch). Within the far band (gameplay03 at 60 km, the 90 km opening) the
+ /// towns with a whole-town model draw their far-off copies instead (owner, 3 November 2026, "Cities/towns only
+ /// (Recommended)"), at most TownModels.FarTriangles each, so the 90 km opening stays under four million triangles; the
+ /// 1948 localities keep their kits. At diorama02 (250 km) no model draws. 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()
{
@@ -566,46 +569,48 @@ public class TownModelTests
var kitRs = map.Settlements.Select(s => root.Find(s.Id).GetComponent<MeshRenderer>())
.Concat(renderers.Where(r => r.name.StartsWith("Localities ") && !r.name.EndsWith(KitLayer.CloseSuffix))).ToList();
Assert.Greater(closeRs.Count, 20, "close meshes"); Assert.Greater(kitRs.Count, 40, "kit meshes");
- Assert.IsNotNull(root.Find("tel_aviv" + KitLayer.CloseSuffix), "Tel Aviv keeps its landmarks and palms up close");
+ Assert.IsNotNull(root.Find("tel_aviv" + KitLayer.CloseSuffix), "Tel Aviv's close mesh is still built (a major city: it never swaps in)");
var originals = AssetDatabase.LoadAssetAtPath<TownModelSet>(TownModels.SetPath);
// Full-original geometry has no decimated-mesh triangle cap. Bound submitted WORK instead:
// 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;
+ var big = map.Settlements.Where(s => TownModels.IsMajorCity(s.Id)).Select(s => s.Id).ToList();
+ CollectionAssert.AreEquivalent(TownLandmarksTests.BigCities, big, "the four major cities");
int bigInstances = big.Sum(id => layer.CountFor(id));
- // The places that draw the far-off copies beyond the close switch (KitLayer): the four cities and every settlement with
- // a whole-town model, i.e. the moshavot and towns, the kibbutzim, Nahalal and the Arab towns (Q15 option a).
- var farTier = map.Settlements.Where(s => big.Contains(s.Id) || Statecraft.Game.Map.Collection.TownLandmarks.ModelFor(s) != null)
+ // The places that draw the far-off copies beyond the close switch (KitLayer): every settlement with a whole-town
+ // model, i.e. the moshavot and towns, the kibbutzim, Nahalal and the Arab towns (Q15 option a). Not the four major
+ // cities, which keep their kits from 40 km out (owner, 6 November 2026, "Big blocks, every zoom").
+ var farTier = map.Settlements.Where(s => Statecraft.Game.Map.Collection.TownLandmarks.ModelFor(s) != null)
.Select(s => s.Id).ToHashSet();
- CollectionAssert.IsSubsetOf(big, farTier, "the four cities");
+ CollectionAssert.IsEmpty(farTier.Intersect(big).ToList(), "the four major cities take no far-off copies");
CollectionAssert.Contains(farTier, "petah_tikva", "a moshava draws its far-off copies");
- // The far tier pinned to the content, not to the condition above: the 25 game settlements of
- // content/map/settlements_1948.yaml, written out by hand (the four cities; the six moshavot, Tiberias, Safed, Netanya
- // and Ramla; the five kibbutzim and Nahalal; Acre, Nazareth, Lod, Gaza and Beersheba). KitLayer's own list is checked,
- // so a broken condition there cannot pass by agreeing with this test's copy of it.
+ // The far tier pinned to the content, not to the condition above: the 21 game settlements of
+ // content/map/settlements_1948.yaml that are not major cities, written out by hand (the six moshavot, Tiberias, Safed,
+ // Netanya and Ramla; the five kibbutzim and Nahalal; Acre, Nazareth, Lod, Gaza and Beersheba). KitLayer's own list is
+ // checked, so a broken condition there cannot pass by agreeing with this test's copy of it.
string[] expectedFarTier =
{
- "acre", "beersheba", "degania_alef", "ein_harod", "gaza", "hadera", "haifa", "hanita", "jaffa", "jerusalem", "lod",
+ "acre", "beersheba", "degania_alef", "ein_harod", "gaza", "hadera", "hanita", "lod",
"nahalal", "nazareth", "netanya", "petah_tikva", "ramla", "rehovot", "revivim", "rishon_lezion", "rosh_pinna",
- "safed", "tel_aviv", "tiberias", "yad_mordechai", "zikhron_yaakov",
+ "safed", "tiberias", "yad_mordechai", "zikhron_yaakov",
};
- Assert.AreEqual(25, expectedFarTier.Distinct().Count(), "the expected far tier names 25 settlements");
+ Assert.AreEqual(21, expectedFarTier.Distinct().Count(), "the expected far tier names 21 settlements");
var productionFarTier = (HashSet<string>?)typeof(TownModelLayer).GetField("farTowns", fixtureFlags)!.GetValue(layer);
Assert.IsNotNull(productionFarTier, "KitLayer passes the far tier to the layer");
- CollectionAssert.AreEquivalent(expectedFarTier, productionFarTier!, "KitLayer's far tier: exactly the 25 game settlements, no locality");
+ CollectionAssert.AreEquivalent(expectedFarTier, productionFarTier!, "KitLayer's far tier: exactly the 21 game settlements, no major city, no locality");
CollectionAssert.Contains(productionFarTier!, "degania_alef", "a kibbutz (a whole-town row by type) draws its far-off copies");
CollectionAssert.AreEquivalent(expectedFarTier, farTier, "this test's far tier matches the content");
int farInstances = farTier.Sum(id => layer.CountFor(id));
- void Check(PromoPose pose, bool close)
+ void Check(PromoPose pose, bool close, string? floorTown = null)
{
- // Up close every detailed town; within the far band the far-tier places, beyond it the four cities, and in this
- // fixture only within its focus admission (OriginalModelDistance.EnterM, 120 km: gameplay03 at 60 km and the
- // 90 km opening, not diorama02 at 250 km). This fixture has no view admission;
- // TheFourCitiesDrawTheirBuildingModelsAtEveryZoom checks production's at 250 km.
+ // Up close every detailed town, the major cities included; within the far band the far-tier places (never a major
+ // city), beyond it none, and in this fixture only within its focus admission (OriginalModelDistance.EnterM, 120 km:
+ // gameplay03 at 60 km and the 90 km opening, not diorama02 at 250 km). This fixture has no view admission;
+ // TheFourCitiesKeepTheirKitsFarAndDrawTalsModelsClose checks production's at 250 km.
bool farFocus = pose.Distance < Statecraft.Game.Map.Collection.OriginalModelDistance.EnterM;
bool farBand = TownModelLayer.FarAt(pose.Distance, null);
- bool Ready(string town) => layer.CountFor(town) > 0 && (close || (farFocus && (big.Contains(town) || (farBand && farTier.Contains(town)))));
+ bool Ready(string town) => layer.CountFor(town) > 0 && (close || (farFocus && farBand && !big.Contains(town) && farTier.Contains(town)));
foreach (var s in map.Settlements)
Assert.AreEqual(Ready(s.Id), layer.ReadyForTown(s.Id, cam), pose.Name + ": " + s.Id + (Ready(s.Id) ? " draws its building models" : " has no building model"));
Assert.AreEqual(close, layer.LastClose, pose.Name);
@@ -626,26 +631,36 @@ public class TownModelTests
if (!close)
{
// Beyond the close switch only the far-off copies: never more instances than the far-tier places hold, and
- // never more than TownModels.FarTriangles each; some at gameplay03 and at the 90 km opening (Tel Aviv and
- // Jaffa in view), none at diorama02 (outside this fixture's focus admission).
- Assert.LessOrEqual(layer.LastDrawn, farBand ? farInstances : bigInstances, pose.Name + ": no other town's building model");
+ // never more than TownModels.FarTriangles each; some at gameplay03 and at the 90 km opening, none at
+ // diorama02 (outside this fixture's focus admission).
+ Assert.LessOrEqual(layer.LastDrawn, farBand ? farInstances : 0, pose.Name + ": no other town's building model");
Assert.LessOrEqual(layer.LastTriangles, (long)layer.LastDrawn * TownModels.FarTriangles, pose.Name + ": the far-off copies, not the originals");
if (farFocus) Assert.Greater(layer.LastDrawn, 0, pose.Name + ": the buildings in view");
else Assert.AreEqual(0, layer.LastDrawn, pose.Name + ": nothing outside the fixture's focus admission");
return;
}
+ // Up close: well over a hundred models, and over floorTown at least all of its instances.
Assert.Greater(layer.LastDrawn, 100, pose.Name + ": models drawn");
+ if (floorTown != null)
+ {
+ Assert.Greater(layer.CountFor(floorTown), 0, floorTown + " has building models");
+ Assert.GreaterOrEqual(layer.LastDrawn, layer.CountFor(floorTown), pose.Name + ": " + floorTown + "'s 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); }
+ // Petah Tikva at 30 km (its settlements_1948.yaml point), framed as tel_aviv30: a close view over a town that draws
+ // its building models.
+ var petah30 = new PromoPose("petah_tikva30", 34.8864, 32.0889, 30000f, 10f);
+ petah30.Apply(rig, map.Frame); RenderSample.Render(cam, 1920, 1080); layer.PrepareCamera(cam); Check(petah30, true, "petah_tikva");
PromoPose.Gameplay03.Apply(rig, map.Frame); RenderSample.Render(cam, 1920, 1080); layer.PrepareCamera(cam); Check(PromoPose.Gameplay03, false);
// The opening camera of today (CameraRig.Distance, 90 km, over 34.95E 31.95N): the far-off copies' budget there.
var start90 = new PromoPose("start90", 34.95, 31.95, 90_000f, 0f);
start90.Apply(rig, map.Frame); RenderSample.Render(cam, 1920, 1080); layer.PrepareCamera(cam); Check(start90, false);
- Assert.Greater(layer.LastDrawn, bigInstances / 2, "start90: the far copies of Tel Aviv, Jaffa and Jerusalem in view, and more");
+ Assert.GreaterOrEqual(layer.LastDrawn, layer.CountFor("lod"), "start90: the far copies of Lod, under the opening's centre, and more");
Assert.LessOrEqual(layer.LastTriangles, 4_000_000L, "start90: the far tier's budget at the 90 km opening");
- TestContext.WriteLine($"{layer.Count} models ({bigInstances} in the four cities: " +
+ TestContext.WriteLine($"{layer.Count} models ({bigInstances} in the four major cities, drawn below the close switch: " +
string.Join(", ", big.Select(id => $"{id} {layer.CountFor(id)}")) + $"; {farInstances} in the {farTier.Count} far-tier game settlements); " + string.Join("; ", results));
PromoPose.CloseUps[0].Apply(rig, map.Frame);
VisualToggles.Set("kits", false); RenderSample.Render(cam, 320, 180);