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: MATKOT's ships and C-54 at the train's 24x scale: the steamer off Haifa, fishing boats off Jaffa and Acre, the Altalena, the C-54 at Lod (fixes #669) (#1086)

Eyal Golan04710af690a3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6e2d9a10d..814ffb760 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
that the year-level date starts after that year. Like the other #707 buildings it draws only close up, streams after
the first frame in `collection-special-buildings`, and keeps clear of the towns, routes, unit tokens, civilians and
wildlife (refs #707, #1068).
+- MATKOT's 1948 Collection ships and C-54 are on the map, at the steam train's 24x scale: the immigrant steamer off Haifa,
+ a fishing boat off Jaffa and one off Acre, the Altalena off Tel Aviv on the Altalena card's turn (15 June 1948), and a
+ C-54 at Lod Airport from July 1949 to September 1950, during Operation Magic Carpet. They stream after the first frame,
+ keep clear of the surf, the harbour works, the other boats and the labels, and a model that does not stream is left out
+ (#669).
- The military unit record (GDD Phase 5 PR 2): a unit can hold a side, a strength and a standing order with its target,
each written into the state hash only when set, so a halutz hashes as before and no golden moves. `unit_types.yaml`
gains Israel's `veteran_soldier` (infantry), `artillery` and `armoured_car` (armour) with a `side` and a `class`; the
diff --git a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs
new file mode 100644
index 000000000..419a19150
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs
@@ -0,0 +1,282 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Game.Map.Kits;
+using Statecraft.Sim;
+using UnityEngine;
+using UnityEngine.Rendering;
+
+namespace Statecraft.Game.Map.Collection
+{
+ /// <summary>MATKOT's ships and the C-54 from The 1948 Collection (issue #669), presentation only:
+ /// <list type="bullet">
+ /// <item>the immigrant steamer off Haifa's port, and a wooden fishing boat off Jaffa and one off Acre, at every date (the
+ /// issue's harbours);</item>
+ /// <item>the Altalena off Tel Aviv on the turn the Altalena card plays: the card's own window (content/events/altalena.yaml,
+ /// 15-23 June 1948, owner Q-CUT-7), the monthly turn that holds the ship's sourced days off the coast, 20-22 June
+ /// (Kfar Vitkin on the 20th, aground off Tel Aviv on the 21st, shelled on the 22nd: the card's sources). One ship on one
+ /// turn stands at one place, so it stands off Tel Aviv, where it ran aground and burned;</item>
+ /// <item>a C-54 at Lod (Lydda) Airport while Operation Magic Carpet's main airlift ran, from July 1949 to its last flights
+ /// into Lydda on 24 September 1950 (<see cref="C54From"/>, <see cref="C54To"/>).</item>
+ /// </list>
+ /// The boats lie on the open sea past the surf, where SeaCraft's own boats sail (SeaCraft.OffshoreNearM to OffshoreM out
+ /// from the same shore points), each hull clear of the harbour works, of SeaCraft's boats and of each other
+ /// (SeaCraft.Clear). Every craft is at the one world scale of the map's ambient models (<see cref="SizeOf"/>: 24x real,
+ /// set by the steam train; #1030, #1033). The C-54 stands on the nearest free ground by the airport, clear of the kits,
+ /// routes, units and the player's placements, with the kit trees under it left out (VegetationLayer.Hide, as under the
+ /// unit figures). Every craft draws at every zoom, as SeaCraft's boats do. Each model is the Far mesh, asked of
+ /// <see cref="CollectionStream"/> when first wanted, so nothing is fetched before the first frame. It fails open: a model
+ /// that does not stream logs one warning and is not drawn; the map plays on.</summary>
+ public sealed class SeaAirCollection : MonoBehaviour
+ {
+ public const string Name = "SeaAirCollection";
+ public const string Altalena = "vehicle-altalena-lst-1948-v2wl";
+ public const string FishingBoat = "vehicle-fishing-boat-1948-v2wl";
+ public const string Steamer = "vehicle-immigrant-steamer-1948-v2wl";
+ public const string C54 = "figure-vehicle-c54-skymaster-1948-v2";
+
+ /// <summary>The card whose window dates the Altalena (content/events/altalena.yaml).</summary>
+ public const string AltalenaEvent = "altalena";
+
+ /// <summary>The C-54 at Lod from 1 July 1949 to 24 September 1950. Operation Magic Carpet flew Yemenite Jews to Israel
+ /// in chartered Douglas DC-4s (the civilian C-54 Skymaster) and Curtiss C-46s; its main wave ran from July to November
+ /// 1949 (Meir-Glitzenstein, Israel Studies, 2011), and it ended on 24 September 1950, "when the last two aircraft
+ /// reached Lydda Airport" (Schechtman, Jewish Social Studies, 1952): both as cited by en.wiki "Operation Magic Carpet
+ /// (Yemen)", checked 18 October 2026. On the game's monthly turns (the 15th) it shows from the 15 July 1949 turn to the
+ /// 15 September 1950 turn.</summary>
+ public static readonly DateTime C54From = new DateTime(1949, 7, 1), C54To = new DateTime(1950, 9, 24);
+
+ /// <summary>Lod (Lydda) Airport, today Ben Gurion Airport: 32.00944 N, 34.88278 E (en.wiki "Ben Gurion Airport",
+ /// checked 18 October 2026). Taken by the IDF on 10 July 1948 (Operation Danny); flights resumed on 24 November 1948.</summary>
+ public const double LodLon = 34.88278, LodLat = 32.00944;
+
+ /// <summary>The real long side (m, seen from above) each model stands for. The Altalena was USS LST-138, an LST-1-class
+ /// tank landing ship (en.wiki "Altalena Affair" and "LST-1-class tank landing ship", its LST-100 to LST-199 list),
+ /// 328 ft overall (en.wiki "USS LST-1", the class's lead ship: "328 ft (100 m) oa"); the C-54's wingspan is 35.81 m (en.wiki
+ /// "Douglas C-54 Skymaster", C-54G); all checked 18 October 2026. The steamer and the fishing boat are generic models,
+ /// no one ship, so theirs are DESIGN VALUES, typical of the kind: an 80 m immigrant steamer and a 10 m wooden fishing
+ /// boat.</summary>
+ const float FootM = 0.3048f;
+ public static float RealLengthM(string model) => model switch
+ {
+ Altalena => 328f * FootM, C54 => 35.81f, Steamer => 80f, FishingBoat => 10f,
+ _ => throw new ArgumentException($"'{model}' is not one of #669's models", nameof(model)),
+ };
+
+ /// <summary>The model's long side on the map (m): its real size at the one world scale of every MATKOT model that is not
+ /// a game piece (SettlementKits.ModelScale, 24x: an 8.5 m house as long as the steam train's 204 m locomotive car; the
+ /// owner, 18 October 2026, #1033: "Train scale for all ambient life"). The Altalena is 2.4 km, the C-54 860 m across.</summary>
+ public static float SizeOf(string model) => RealLengthM(model) * SettlementKits.ModelScale;
+
+ /// <summary>DESIGN VALUE: every craft lies with its length east-west (SeaCraft heading 0), side-on to the gameplay
+ /// camera looking north, as SeaCraft's boats lie. A model is turned 0 or 90 degrees about the vertical, on top of its
+ /// prefab's own rotation, whichever lays its longer side along x.</summary>
+ public const float Heading = 0f;
+
+ internal static Action<string, CollectionDetail, Action<GameObject?>> Request = CollectionStream.Request;
+
+ /// <summary>One craft to draw: its key, its model, and the place it belongs to (a SeaCraft coast's place, or "lod").</summary>
+ public readonly struct Want : IEquatable<Want>
+ {
+ public readonly string Key, Model, Place;
+ public Want(string key, string model, string place) { Key = key; Model = model; Place = place; }
+ public bool Equals(Want o) => Key == o.Key && Model == o.Model && Place == o.Place;
+ public override bool Equals(object? obj) => obj is Want w && Equals(w);
+ public override int GetHashCode() => (Key, Model, Place).GetHashCode();
+ }
+
+ /// <summary>The craft wanted as at <paramref name="date"/>, in a fixed order.</summary>
+ public static List<Want> Wants(DateTime date, Content content)
+ {
+ var wants = new List<Want>
+ {
+ new Want("haifa-steamer", Steamer, "haifa"),
+ new Want("jaffa-fishing", FishingBoat, "jaffa"),
+ new Want("acre-fishing", FishingBoat, "acre"),
+ };
+ var card = content.Events.FirstOrDefault(e => e.Id == AltalenaEvent);
+ if (card != null && card.To is DateTime to && date >= card.From && date < to)
+ wants.Add(new Want("tel-aviv-altalena", Altalena, "tel_aviv"));
+ if (date >= C54From && date <= C54To) wants.Add(new Want("lod-c54", C54, "lod"));
+ return wants;
+ }
+
+ /// <summary>A boat's spot: out from its coast's shore point (SeaCraft.Coasts) between SeaCraft.OffshoreNearM and
+ /// OffshoreM, at a seeded spread along the shore, the first whose hull passes SeaCraft.Clear against the harbour works
+ /// and every boat already placed. Null when none is.</summary>
+ internal static Vector2? SeaSpot(Want want, KitGround ground, IReadOnlyList<SettlementKits.Placed> works, List<SeaCraft.Craft> boats)
+ {
+ var coast = SeaCraft.Coasts.FirstOrDefault(c => c.place == want.Place);
+ if (coast.place == null) return null;
+ var w = ground.Frame.ToWorld(coast.lon, coast.lat, 0); var at = new Vector2(w.x, w.z);
+ var shore = ground.Water(at.x, at.y) ? at : SeaCraft.FirstWater(at, coast.seaward, ground, 20000f);
+ if (!(shore is Vector2 s)) return null;
+ var along = new Vector2(-coast.seaward.y, coast.seaward.x);
+ float m = KitScale.Landmarks / 60f, length = SizeOf(want.Model);
+ var rnd = new KitRandom(want.Key, 669);
+ var workList = works as List<SettlementKits.Placed> ?? works.ToList();
+ for (int tries = 0; tries < 60; tries++)
+ {
+ var c = s + coast.seaward * rnd.Range(SeaCraft.OffshoreNearM, SeaCraft.OffshoreM) * m + along * rnd.Range(-2.2f, 2.2f) * length;
+ var craft = new SeaCraft.Craft(SeaCraft.Kind.Steamer, c, Heading, length, want.Place);
+ if (SeaCraft.Clear(craft, ground, workList, boats, 0.5f * length)) return c;
+ }
+ return null;
+ }
+
+ MapScene? map;
+ Content? content;
+ readonly Dictionary<string, GameObject?> prefabs = new Dictionary<string, GameObject?>(StringComparer.Ordinal);
+ readonly HashSet<string> asked = new HashSet<string>(StringComparer.Ordinal);
+ List<Want> wants = new List<Want>();
+ List<(int q, int r)> placements = new List<(int, int)>();
+ List<(Vector2 centre, float radius)> taken = new List<(Vector2, float)>();
+ List<WildlifeLayer.Want>? wildlife;
+ DateTime date;
+
+ /// <summary>The craft drawn (key, model, spot at the water's or ground's height): a test aid.</summary>
+ public readonly List<(string Key, string Model, Vector3 At)> Placed = new List<(string, string, Vector3)>();
+ /// <summary>The craft wanted but not drawn: the model did not stream, or no spot was clear (a test aid).</summary>
+ public readonly List<string> Missing = new List<string>();
+
+ /// <summary>Every drawn craft's world box, for the map labels to keep clear of, as they do of the unit tokens
+ /// (MapLabelsPresenter's keepClear, issue #197). A new list after every rebuild and the same list otherwise, so the
+ /// labels re-read it only when it changes.</summary>
+ public IReadOnlyList<Bounds[]> KeepClear => !isActiveAndEnabled ? (IReadOnlyList<Bounds[]>)Array.Empty<Bounds[]>() : keepAll;
+ List<Bounds[]> keepAll = new List<Bounds[]>();
+
+ /// <summary>Shows the craft wanted as at <paramref name="date"/> (GameRoot calls it on every change, beside
+ /// TownLandmarks.ShowAt), redrawing only when the wanted set or the player's placements change.</summary>
+ public static SeaAirCollection? ShowAt(MapScene map, DateTime date, IEnumerable<Placement> placements, Content content)
+ {
+ if (map == null || map.Terrain == null || map.Hexes == null) return null;
+ var layer = map.Terrain.transform.Find(Name)?.GetComponent<SeaAirCollection>();
+ if (layer == null)
+ {
+ var go = new GameObject(Name); go.transform.SetParent(map.Terrain.transform, false);
+ layer = go.AddComponent<SeaAirCollection>(); layer.map = map;
+ }
+ layer.content = content;
+ layer.Show(Wants(date, content), placements.Select(p => (p.Q, p.R)).ToList(), date);
+ return layer;
+ }
+
+ void Show(List<Want> next, List<(int q, int r)> placed, DateTime at)
+ {
+ date = at;
+ var others = next.Any(w => w.Model == C54) ? Taken() : new List<(Vector2, float)>();
+ if (next.SequenceEqual(wants) && placed.SequenceEqual(placements) && others.SequenceEqual(taken)) return;
+ wants = next; placements = placed; taken = others;
+ foreach (var w in wants)
+ if (asked.Add(w.Model)) { var model = w.Model; Request(model, CollectionDetail.Far, p => OnModel(model, p)); }
+ Rebuild();
+ }
+
+ void OnModel(string model, GameObject? prefab)
+ {
+ if (this == null) return; // the map was rebuilt before the model came; the new map asks again
+ prefabs[model] = prefab;
+ if (prefab == null) Debug.LogWarning($"SEA/AIR: the model {model} did not stream; it is not drawn, and the map plays on without it.");
+ Rebuild();
+ }
+
+ void Rebuild()
+ {
+ if (map == null || map.Terrain == null) return;
+ for (int i = transform.childCount - 1; i >= 0; i--)
+ {
+ var old = transform.GetChild(i).gameObject;
+ if (Application.isPlaying) { old.transform.SetParent(null); Destroy(old); } else DestroyImmediate(old);
+ }
+ Placed.Clear(); Missing.Clear();
+ keepAll = new List<Bounds[]>();
+ var ground = PlacementLayer.CampGround(map);
+ var works = map.KitStats?.HarbourWorks ?? Array.Empty<SettlementKits.Placed>();
+ var boats = new List<SeaCraft.Craft>(map.KitStats?.Crafts ?? Array.Empty<SeaCraft.Craft>());
+ foreach (var w in wants)
+ {
+ if (!prefabs.TryGetValue(w.Model, out var prefab)) continue; // still streaming
+ Vector2? at = null;
+ if (prefab != null)
+ {
+ at = w.Model == C54 ? LandSpot(ground) : SeaSpot(w, ground, works, boats);
+ if (at != null && w.Model != C54) boats.Add(new SeaCraft.Craft(SeaCraft.Kind.Steamer, at.Value, Heading, SizeOf(w.Model), w.Place));
+ }
+ if (at == null) { Missing.Add(w.Key); continue; }
+ var go = Instantiate(prefab!, transform, false); go.name = w.Key;
+ // The yaw goes on top of the prefab's own rotation: every Collection Far prefab's root carries the FBX axis
+ // conversion (-90 degrees about X), and setting the yaw alone lays a model on its side (#979).
+ go.transform.localRotation = prefab!.transform.localRotation;
+ var b = Bounds(go);
+ if (b.size.z > b.size.x) { go.transform.localRotation = Quaternion.Euler(0f, 90f, 0f) * prefab.transform.localRotation; b = Bounds(go); }
+ float edge = Mathf.Max(b.size.x, b.size.z);
+ go.transform.localScale *= edge > 1e-3f ? SizeOf(w.Model) / edge : 1f;
+ // A boat's waterline and the plane's wheels on the surface under the spot (the sea is the heightmap's 0 m).
+ var pos = new Vector3(at.Value.x, ground.Y(at.Value.x, at.Value.y), at.Value.y);
+ go.transform.position = pos; b = Bounds(go);
+ go.transform.position += new Vector3(pos.x - b.center.x, pos.y - b.min.y, pos.z - b.center.z);
+ foreach (var r in go.GetComponentsInChildren<Renderer>(true)) r.shadowCastingMode = ShadowCastingMode.On;
+ Placed.Add((w.Key, w.Model, pos));
+ keepAll.Add(new[] { Bounds(go) });
+ }
+ // The kit trees under the C-54 are left out at draw time, as under the unit figures (VegetationLayer.Hide, #249).
+ var plane = Placed.Where(p => p.Model == C54).Select(p => (new Vector2(p.At.x, p.At.z), 0.5f * SizeOf(C54))).ToList();
+ Statecraft.Game.Map.Units.UnitShowcase.HideTrees(map, Name, plane);
+ Debug.Log($"SEA/AIR: {Placed.Count} collection craft placed, {Missing.Count} not drawn");
+ }
+
+ /// <summary>The ground the other 1948 Collection layers hold (GameRoot shows them first), for the C-54 to keep off, as
+ /// SpecialBuildingModels keeps off the people and the wildlife: the civilians (#666), the wildlife (#670), the farm
+ /// scenes drawn (#667) and the fort, barracks and factory drawn (#707). Show compares it, so the plane moves when they
+ /// do.</summary>
+ List<(Vector2 centre, float radius)> Taken()
+ {
+ var list = new List<(Vector2, float)>();
+ if (map == null || map.Terrain == null) return list;
+ var t = map.Terrain.transform;
+ var people = t.Find(CivilianPeople.Name)?.GetComponent<CivilianPeople>();
+ if (people != null) foreach (var p in people.Wanted) list.Add((new Vector2(p.At.x, p.At.z), CivilianPeople.FigureClearanceM));
+ wildlife ??= WildlifeLayer.Wants(map); // fixed for a map: no date in it
+ foreach (var a in wildlife) list.Add((a.At, 0.5f * WildlifeLayer.SizeM));
+ var rural = t.Find(RuralLife.Name)?.GetComponent<RuralLife>();
+ if (rural != null) foreach (var p in rural.Placed) list.Add((new Vector2(p.At.x, p.At.z), RuralLife.SceneRadiusM(p.Model)));
+ var special = t.Find(SpecialBuildingModels.Name)?.GetComponent<SpecialBuildingModels>();
+ if (special != null) foreach (var p in special.Placed) list.Add((new Vector2(p.At.x, p.At.z), SpecialBuildingModels.ClearanceOf(p.Model)));
+ return list;
+ }
+
+ /// <summary>The C-54's spot: the first free ground by the airport (TownLandmarks.Spot's rings), clear of the water, the
+ /// kits' footprints, the other Collection layers (<see cref="Taken"/>), the routes, the units and the player's placed
+ /// hexes.</summary>
+ Vector2? LandSpot(KitGround ground)
+ {
+ var w = map!.Frame.ToWorld(LodLon, LodLat, 0); var airport = new Vector2(w.x, w.z);
+ float r = 0.5f * SizeOf(C54), hexHalf = 500f * map.Hexes.hex_size_km;
+ var discs = map.KitFootprints.Select(f => (f.centre, f.radius)).Concat(taken).ToList();
+ foreach (var (q, rr) in placements)
+ {
+ var hex = content?.HexAt(q, rr);
+ if (hex == null) continue;
+ var h = map.Frame.ToWorld(hex.Lon, hex.Lat, 0); discs.Add((new Vector2(h.x, h.z), hexHalf));
+ }
+ bool Free(Vector2 p, float rad)
+ {
+ if (!TownLandmarks.Clear(p, rad, discs) || !ground.Inside(p.x - rad, p.y - rad) || !ground.Inside(p.x + rad, p.y + rad)) return false;
+ for (int k = 0; k < 9; k++)
+ {
+ var q = k == 0 ? p : p + new Vector2(Mathf.Cos(k * Mathf.PI / 4f), Mathf.Sin(k * Mathf.PI / 4f)) * rad * 0.8f;
+ if (ground.Water(q.x, q.y)) return false;
+ }
+ return !ground.OnRoute(p, rad) && !ground.OnToken(p, rad) && !ground.OnToken(p, rad, date);
+ }
+ return Free(airport, r) ? airport : TownLandmarks.Spot(airport, 0f, r, Free);
+ }
+
+ static Bounds Bounds(GameObject go)
+ {
+ var rs = go.GetComponentsInChildren<Renderer>(true); if (rs.Length == 0) return new Bounds(go.transform.position, Vector3.zero);
+ var b = rs[0].bounds; foreach (var r in rs) b.Encapsulate(r.bounds); return b;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs.meta b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs.meta
new file mode 100644
index 000000000..bf6256de7
--- /dev/null
+++ b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 37b6188d990e4ca6802887db132e4fd5
diff --git a/unity/Assets/Scripts/Map/Kits/KitLayer.cs b/unity/Assets/Scripts/Map/Kits/KitLayer.cs
index 8aa539ec5..fbb706546 100644
--- a/unity/Assets/Scripts/Map/Kits/KitLayer.cs
+++ b/unity/Assets/Scripts/Map/Kits/KitLayer.cs
@@ -23,6 +23,10 @@ namespace Statecraft.Game.Map.Kits
public int Buildings, Vertices, Triangles, Trees, CorridorSegments, Localities, LocalityBuildings, Camps, Tents, Draws, Boats, Models, CloseVertices; public float BuildMs, PlantMs;
/// <summary>Every footprint the build claimed (towns, localities, camps), in claim order (MapScene.KitFootprints).</summary>
public IReadOnlyList<(Vector2 centre, float radius, string id)> Footprints = System.Array.Empty<(Vector2, float, string)>();
+ /// <summary>The boats SeaCraft placed and the harbour works the kits recorded ("breakwater" pieces), so the 1948
+ /// Collection's craft (SeaAirCollection, #669) keep clear of both.</summary>
+ public IReadOnlyList<SeaCraft.Craft> Crafts = System.Array.Empty<SeaCraft.Craft>();
+ public IReadOnlyList<SettlementKits.Placed> HarbourWorks = 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}";
@@ -86,7 +90,10 @@ namespace Statecraft.Game.Map.Kits
SeaCraft.Draw(crafts, ground, km);
Add(SeaCraftName, km.ToMesh(SeaCraftName));
}
- stats.Boats = crafts.Count;
+ stats.Boats = crafts.Count; stats.Crafts = crafts;
+ var works = new List<SettlementKits.Placed>();
+ foreach (var p in placed) if (p.Kind == "breakwater") works.Add(p);
+ stats.HarbourWorks = works;
// Issue #659: the buildings' models, instanced up close (without a complete model list, the kits at every zoom).
var townGo = new GameObject(TownModelsName);
townGo.transform.SetParent(root.transform, false);
diff --git a/unity/Assets/Scripts/Map/Kits/SeaCraft.cs b/unity/Assets/Scripts/Map/Kits/SeaCraft.cs
index c0ba29298..7265c113d 100644
--- a/unity/Assets/Scripts/Map/Kits/SeaCraft.cs
+++ b/unity/Assets/Scripts/Map/Kits/SeaCraft.cs
@@ -31,7 +31,7 @@ namespace Statecraft.Game.Map.Kits
/// x, z) and how many boats. Jaffa's, Tel Aviv's and Haifa's are the points the settlement kits build those ports at
/// (docs/visual-v1.md, "Towns round 2"); Bat Yam's, Acre's and Gaza's are approximate points on their shores, chosen
/// for placement only.</summary>
- static readonly (string place, double lon, double lat, Vector2 seaward, int boats)[] Coasts =
+ internal static readonly (string place, double lon, double lat, Vector2 seaward, int boats)[] Coasts =
{
("jaffa", 34.7505056, 32.0534583, Vector2.left, 3),
("tel_aviv", 34.7732528, 32.0964833, Vector2.left, 2),
@@ -85,7 +85,7 @@ namespace Statecraft.Game.Map.Kits
/// <summary>How far out the boats under way sail (world m at the default landmark scale, 60): from past the surf to the
/// edge of the gameplay pose's view of the coast.</summary>
- const float OffshoreNearM = 2400f, OffshoreM = 7500f;
+ internal const float OffshoreNearM = 2400f, OffshoreM = 7500f;
/// <summary>A harbour's water as the settlement kits record it: Jaffa's a circle (its breakwater's centre and radius,
/// SettlementKits.Port), Tel Aviv's and Haifa's a box (centre, width east-west, depth north-south). Returns how far
@@ -143,7 +143,7 @@ namespace Statecraft.Game.Map.Kits
}
}
- static Vector2? FirstWater(Vector2 from, Vector2 dir, KitGround ground, float maxM)
+ internal static Vector2? FirstWater(Vector2 from, Vector2 dir, KitGround ground, float maxM)
{
for (float d = 0f; d <= maxM; d += 125f)
{
@@ -157,7 +157,7 @@ namespace Statecraft.Game.Map.Kits
/// its samples all lie in open sea (not a lake: the rift lakes are below sea level), it meets no harbour work
/// (<paramref name="works"/>, each piece's own rectangle), and its centre keeps clear of every boat already
/// placed.</summary>
- static bool Clear(Craft c, KitGround ground, List<SettlementKits.Placed> works, List<Craft> list, float margin)
+ internal static bool Clear(Craft c, KitGround ground, List<SettlementKits.Placed> works, List<Craft> list, float margin)
{
var f = c.Forward; var side = new Vector2(-f.y, f.x);
float half = 0.5f * c.Length + margin, beam = 0.5f * Beam * c.Length + margin;
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 91c65202a..008c1a1e2 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -332,11 +332,20 @@ namespace Statecraft.Game.UI
var labelCamera = cameraController.GetComponent<Camera>();
labels = Own(new MapLabelsPresenter(root, map, labelCamera, null,
p => MapLabelsPresenter.TipOf(p, n => text.Format("map.today", n), text["map.mixed"], hebrew),
- () => // the names keep clear of the unit tokens (issue #197), their badges and flags as this camera will draw them
- {
- if (unitLayer == null) return null;
- unitLayer.FaceCamera(labelCamera);
- return unitLayer.KeepClear;
+ () => // the names keep clear of the unit tokens (issue #197), their badges and flags as this camera will draw them,
+ { // and of the 1948 Collection's ships and C-54 (#669)
+ IReadOnlyList<Bounds[]>? tokens = null;
+ if (unitLayer != null) { unitLayer.FaceCamera(labelCamera); tokens = unitLayer.KeepClear; }
+ var craft = seaAir != null ? seaAir.KeepClear : null;
+ if (craft == null || craft.Count == 0) return tokens;
+ if (tokens == null || tokens.Count == 0) return craft;
+ // One merged list per pair of lists, so the labels see a new list only when either changes (they refresh then).
+ if (!ReferenceEquals(tokens, keptTokens) || !ReferenceEquals(craft, keptCraft))
+ {
+ keptTokens = tokens; keptCraft = craft;
+ var merged = new List<Bounds[]>(tokens); merged.AddRange(craft); keptBoth = merged;
+ }
+ return keptBoth;
},
// Issue #710: the static 1948 tier from cities.yaml's people, not the sim's live count (owner, 15 October 2026).
bridge.Content.Cities.Where(c => c.People != null).ToDictionary(c => c.Id, c => c.People!.Value),
@@ -470,6 +479,9 @@ namespace Statecraft.Game.UI
/// <summary>Draws the placements only when State.Placements differs from what was drawn (every order and every turn
/// raises Changed; rebuilding the markers each time would be wasted work).</summary>
+ Statecraft.Game.Map.Collection.SeaAirCollection? seaAir; // the 1948 Collection's craft (#669), for the labels to keep clear of
+ IReadOnlyList<Bounds[]>? keptTokens, keptCraft, keptBoth;
+
void RenderPlacementsIfChanged()
{
if (Bridge == null) return;
@@ -484,6 +496,8 @@ namespace Statecraft.Game.UI
Statecraft.Game.Map.Collection.RuralLife.Show(map);
// MATKOT's Tegart fort, barracks and factory at their sourced places and dates, close up only, streamed (#707).
Statecraft.Game.Map.Collection.SpecialBuildingModels.ShowAt(map, Bridge.State.Date);
+ // MATKOT's ships off Haifa, Jaffa, Acre and (on the Altalena's turn) Tel Aviv, and the C-54 at Lod, streamed after the first frame (#669).
+ seaAir = Statecraft.Game.Map.Collection.SeaAirCollection.ShowAt(map, Bridge.State.Date, Bridge.State.Placements, Bridge.Content);
RenderSitesIfChanged();
var now = Bridge.State.Placements.Select(p => (p.Action, p.Q, p.R, p.Date)).ToList();
if (drawn != null && drawn.SequenceEqual(now)) return;
diff --git a/unity/Assets/Tests/EditMode/MapLabelTests.cs b/unity/Assets/Tests/EditMode/MapLabelTests.cs
index 654e12869..f74104694 100644
--- a/unity/Assets/Tests/EditMode/MapLabelTests.cs
+++ b/unity/Assets/Tests/EditMode/MapLabelTests.cs
@@ -1274,4 +1274,55 @@ public class MapLabelTests
}
finally { labels.Dispose(); hd.Dispose(); }
}
+
+ /// <summary>Issue #669: the 1948 Collection's craft stay off the labels. At the 60 km gameplay view over Tel Aviv and Jaffa,
+ /// Haifa and Acre, and Lod, on the Altalena's turn (15 June 1948) and in Magic Carpet's main wave (15 August 1949), no
+ /// shown pill meets a drawn craft (its renderers' world box, every corner through the camera's pixels): the pills keep
+ /// clear of the craft's boxes as GameRoot passes them (SeaAirCollection.KeepClear).</summary>
+ [UnityTest]
+ public IEnumerator TheCollectionCraftStayOffEveryShownPill()
+ {
+ var c = Statecraft.Sim.ContentLoader.Load(Statecraft.Game.Paths.Content);
+ var saved = Statecraft.Game.Map.Collection.SeaAirCollection.Request;
+ Statecraft.Game.Map.Collection.SeaAirCollection.Request = (id, d, done) => done(AssetDatabase.LoadAssetAtPath<GameObject>(
+ Statecraft.Game.Map.Collection.CollectionCatalog.PrefabPath(id, d)));
+ var hd = new HdPanel(cam);
+ Statecraft.Game.Map.Collection.SeaAirCollection? craftLayer = null;
+ // As GameRoot wires it: the names keep clear of the craft's boxes (SeaAirCollection.KeepClear), as of the unit tokens.
+ var labels = new MapLabelsPresenter(hd.Root, map, cam, keepClear: () => craftLayer != null ? craftLayer.KeepClear : null);
+ int checkedCraft = 0;
+ try
+ {
+ foreach (var date in new[] { new System.DateTime(1948, 6, 15), new System.DateTime(1949, 8, 15) })
+ {
+ var layer = craftLayer = Statecraft.Game.Map.Collection.SeaAirCollection.ShowAt(map, date, System.Array.Empty<Statecraft.Sim.Placement>(), c)!;
+ Assert.AreEqual(4, layer.Placed.Count, "every craft drawn on " + date.ToString("d MMM yyyy"));
+ foreach (var (lon, lat) in new[] { (34.76, 32.07), (35.03, 32.86), (34.88, 32.0) })
+ {
+ Pose(lon, lat, 60000f);
+ yield return Settle(labels);
+ var pills = labels.Labels.Where(l => Shown(l.parent)).Concat(labels.LocalityLabels.Where(l => Shown(l.parent))).Select(l => l.worldBound).ToList();
+ Assert.Greater(pills.Count, 0, $"pills shown over {lon}, {lat}");
+ foreach (Transform craft in layer.transform)
+ {
+ var b = craft.GetComponentsInChildren<Renderer>(true).Select(r => r.bounds).Aggregate((a, x) => { a.Encapsulate(x); return a; });
+ float x0 = float.MaxValue, y0 = float.MaxValue, x1 = float.MinValue, y1 = float.MinValue; bool front = true;
+ for (int k = 0; k < 8; k++)
+ {
+ var corner = new Vector3((k & 1) == 0 ? b.min.x : b.max.x, (k & 2) == 0 ? b.min.y : b.max.y, (k & 4) == 0 ? b.min.z : b.max.z);
+ var q = hd.ToPanel(corner, out var inFront); front &= inFront;
+ x0 = Mathf.Min(x0, q.x); y0 = Mathf.Min(y0, q.y); x1 = Mathf.Max(x1, q.x); y1 = Mathf.Max(y1, q.y);
+ }
+ var rect = Rect.MinMaxRect(x0, y0, x1, y1);
+ if (!front || !rect.Overlaps(hd.Root.worldBound)) continue; // off this view
+ checkedCraft++;
+ foreach (var pill in pills)
+ Assert.IsFalse(pill.Overlaps(rect), $"{craft.name} {rect} under a pill {pill} at {lon}, {lat} on {date:d MMM yyyy}");
+ }
+ }
+ }
+ Assert.GreaterOrEqual(checkedCraft, 5, "the craft were in view");
+ }
+ finally { labels.Dispose(); hd.Dispose(); Statecraft.Game.Map.Collection.SeaAirCollection.Request = saved; }
+ }
}
diff --git a/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs
new file mode 100644
index 000000000..9ab193b9b
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs
@@ -0,0 +1,284 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using NUnit.Framework;
+using Statecraft.Game.Map;
+using Statecraft.Game.Map.Collection;
+using Statecraft.Game.Map.Kits;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TestTools;
+using Object = UnityEngine.Object;
+
+/// <summary>Issue #669: MATKOT's immigrant steamer off Haifa, fishing boats off Jaffa and Acre, the Altalena off Tel Aviv on
+/// its card's turn and the C-54 at Lod during Operation Magic Carpet, streamed after the first frame (SeaAirCollection).</summary>
+public class SeaAirCollectionTests
+{
+ Action<string, CollectionDetail, Action<GameObject?>> saved = null!;
+ readonly List<(string id, CollectionDetail detail, Action<GameObject?> done)> asked = new List<(string, CollectionDetail, Action<GameObject?>)>();
+ static readonly Content C = ContentLoader.Load(Statecraft.Game.Paths.Content);
+
+ [SetUp]
+ public void Seam()
+ {
+ saved = SeaAirCollection.Request; asked.Clear();
+ SeaAirCollection.Request = (id, d, done) => asked.Add((id, d, done));
+ }
+
+ [TearDown]
+ public void Reset()
+ {
+ SeaAirCollection.Request = saved;
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ }
+
+ static MapScene OpenMap()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>(); map.Build(); return map;
+ }
+
+ static GameObject Far(string id) => AssetDatabase.LoadAssetAtPath<GameObject>(CollectionCatalog.PrefabPath(id, CollectionDetail.Far));
+
+ void AnswerAll()
+ {
+ var pending = asked.ToList(); asked.Clear();
+ foreach (var (id, _, done) in pending) done(Far(id));
+ }
+
+ static Bounds WorldBounds(GameObject go) =>
+ go.GetComponentsInChildren<Renderer>(true).Select(x => x.bounds).Aggregate((a, x) => { a.Encapsulate(x); return a; });
+
+ static readonly string[] Models = { SeaAirCollection.Altalena, SeaAirCollection.FishingBoat, SeaAirCollection.Steamer, SeaAirCollection.C54 };
+
+ /// <summary>The owner (#663): every model is used. All four of this lane's are in the streamed vehicle bundle and each is
+ /// wanted on some turn of the game, on the game's own monthly turn dates.</summary>
+ [Test]
+ public void EveryModelOfTheLaneIsWantedOnSomeTurnFromTheStreamedVehicleBundle()
+ {
+ foreach (var id in Models) Assert.AreEqual(CollectionCatalog.Vehicles, CollectionCatalog.BundleOf(id), id + " is in the streamed vehicle bundle");
+ var turns = new List<DateTime>();
+ for (var d = C.Rules.Start; d < C.End; d = d.AddMonths(1)) turns.Add(d);
+ Assert.AreEqual(new DateTime(1948, 5, 15), turns[0]);
+ foreach (var id in Models)
+ Assert.IsTrue(turns.Any(d => SeaAirCollection.Wants(d, C).Any(w => w.Model == id)), id + " is wanted on some monthly turn");
+ Assert.AreEqual(1, turns.Count(d => SeaAirCollection.Wants(d, C).Any(w => w.Model == SeaAirCollection.Altalena)), "the Altalena on one turn");
+ }
+
+ /// <summary>Dated items only on their sourced dates. The Altalena on its card's window, 15-23 June 1948 (the turn that holds
+ /// 20-22 June, the days the card's sources put the ship off Kfar Vitkin and Tel Aviv), off Tel Aviv. The C-54 at Lod from
+ /// 1 July 1949 (Magic Carpet's main wave) to 24 September 1950 (its last flights into Lydda). The harbour craft always.</summary>
+ [Test]
+ public void TheAltalenaAndTheC54AreWantedOnlyOnTheirSourcedDates()
+ {
+ var card = C.Events.Single(e => e.Id == SeaAirCollection.AltalenaEvent);
+ Assert.AreEqual(new DateTime(1948, 6, 15), card.From); Assert.AreEqual(new DateTime(1948, 6, 23), card.To);
+ string[] Keys(DateTime d) => SeaAirCollection.Wants(d, C).Select(w => w.Key).ToArray();
+ CollectionAssert.AreEqual(new[] { "haifa-steamer", "jaffa-fishing", "acre-fishing" }, Keys(new DateTime(1948, 5, 15)));
+ CollectionAssert.AreEqual(new[] { "haifa-steamer", "jaffa-fishing", "acre-fishing", "tel-aviv-altalena" }, Keys(new DateTime(1948, 6, 15)));
+ Assert.AreEqual("tel_aviv", SeaAirCollection.Wants(new DateTime(1948, 6, 15), C).Single(w => w.Model == SeaAirCollection.Altalena).Place);
+ CollectionAssert.DoesNotContain(Keys(new DateTime(1948, 6, 14)), "tel-aviv-altalena");
+ CollectionAssert.DoesNotContain(Keys(new DateTime(1948, 6, 23)), "tel-aviv-altalena");
+ CollectionAssert.DoesNotContain(Keys(new DateTime(1948, 7, 15)), "tel-aviv-altalena");
+ CollectionAssert.DoesNotContain(Keys(new DateTime(1949, 6, 30)), "lod-c54");
+ CollectionAssert.Contains(Keys(new DateTime(1949, 7, 1)), "lod-c54");
+ CollectionAssert.Contains(Keys(new DateTime(1950, 9, 24)), "lod-c54");
+ CollectionAssert.DoesNotContain(Keys(new DateTime(1950, 9, 25)), "lod-c54");
+ }
+
+ /// <summary>Nothing is drawn until the stream answers, and only the far mesh, once per model. Then every craft is drawn,
+ /// each boat on the open sea (the heightmap's 0 m), its hull passing SeaCraft's own clearance (open sea round it, clear of
+ /// the harbour works and of SeaCraft's boats and each other) and at least SeaCraft.OffshoreNearM out from its shore point
+ /// (past the surf), its waterline on the surface; the C-54 on land by the airport, its wheels on the ground, off every kit
+ /// and with no kit tree drawn under it. Every
+ /// craft keeps its prefab's rotation under a quarter turn (upright, as #979), lies with its longer side east-west, and is
+ /// drawn at its size. Rebuilding gives the same spots.</summary>
+ [Test]
+ public void TheCraftStreamInAndFloatUprightClearOfTheSurfTheHarbourWorksAndTheOtherBoats()
+ {
+ var map = OpenMap();
+ var ground = new KitGround(map.Terrain, map.Frame, map.Hexes, map.ElevMinM);
+ var kitBoats = map.KitStats!.Crafts; var works = map.KitStats.HarbourWorks;
+ Assert.Greater(kitBoats.Count, 0, "SeaCraft's boats are there to keep clear of");
+ Assert.Greater(works.Count, 0, "the harbour works are there to keep clear of");
+ bool first = true;
+ foreach (var date in new[] { new DateTime(1948, 6, 15), new DateTime(1949, 8, 15) })
+ {
+ var layer = SeaAirCollection.ShowAt(map, date, Array.Empty<Placement>(), C)!;
+ if (first) CollectionAssert.IsEmpty(layer.Placed, "nothing before the stream answers");
+ first = false;
+ Assert.IsTrue(asked.All(a => a.detail == CollectionDetail.Far), "the far mesh only");
+ Assert.AreEqual(asked.Count, asked.Select(a => a.id).Distinct().Count(), "each model once");
+ AnswerAll();
+ CollectionAssert.IsEmpty(layer.Missing, "every craft found a spot on " + date.ToString("d MMM yyyy"));
+ Assert.AreEqual(4, layer.Placed.Count);
+ var spots = layer.Placed.Select(p => p.At).ToArray();
+ SeaAirCollection.ShowAt(map, date.AddMonths(1), Array.Empty<Placement>(), C); AnswerAll();
+ SeaAirCollection.ShowAt(map, date, Array.Empty<Placement>(), C); AnswerAll();
+ CollectionAssert.AreEqual(spots, layer.Placed.Select(p => p.At).ToArray(), "the same spots again");
+ var boats = layer.Placed.Where(p => p.Model != SeaAirCollection.C54).ToList();
+ foreach (var (key, model, at) in layer.Placed)
+ {
+ var child = layer.transform.Find(key)!; var prefab = Far(model);
+ var turned = new[] { 0f, 90f }.Min(y => Quaternion.Angle(layer.transform.rotation * Quaternion.Euler(0f, y, 0f) * prefab.transform.localRotation, child.rotation));
+ Assert.Less(turned, 0.01f, key + " keeps its prefab's rotation (upright) under a yaw of 0 or 90");
+ var b = WorldBounds(child.gameObject);
+ Assert.GreaterOrEqual(b.size.x, b.size.z, key + " lies east-west, side-on to the camera");
+ Assert.AreEqual(SeaAirCollection.SizeOf(model), b.size.x, 1f, key + " is drawn at its size");
+ Assert.AreEqual(at.y, b.min.y, 1f, key + " stands on the surface under it");
+ Assert.AreEqual(ground.Y(at.x, at.z), at.y, 0.5f);
+ var p = new Vector2(at.x, at.z);
+ if (model == SeaAirCollection.C54)
+ {
+ Assert.IsFalse(ground.Water(p.x, p.y), "the C-54 stands on land");
+ var lod = map.Frame.ToWorld(SeaAirCollection.LodLon, SeaAirCollection.LodLat, 0);
+ Assert.Less((p - new Vector2(lod.x, lod.z)).magnitude, 3f * SeaAirCollection.SizeOf(model), "by Lod Airport");
+ foreach (var f in map.KitFootprints)
+ Assert.GreaterOrEqual((p - f.centre).magnitude, f.radius + 0.5f * SeaAirCollection.SizeOf(model) - 1f, $"the C-54 on {f.id}'s kit");
+ var veg = map.GetComponentInChildren<VegetationLayer>(true);
+ Assert.IsNotNull(veg);
+ foreach (var (kind, m) in veg.Drawable())
+ {
+ var t = (Vector3)m.GetColumn(3);
+ Assert.GreaterOrEqual((new Vector2(t.x, t.z) - p).magnitude, 0.5f * SeaAirCollection.SizeOf(model) + VegetationLayer.CrownRadius(kind, m) - 1f,
+ "no kit tree drawn under the C-54");
+ }
+ continue;
+ }
+ Assert.LessOrEqual(Mathf.Abs(ground.ElevM(p.x, p.y)), MapBuilder.SeaToleranceM + 0.5f, key + " lies on the open sea");
+ float len = SeaAirCollection.SizeOf(model);
+ var others = kitBoats.Concat(boats.Where(o => o.Key != key)
+ .Select(o => new SeaCraft.Craft(SeaCraft.Kind.Steamer, new Vector2(o.At.x, o.At.z), 0f, SeaAirCollection.SizeOf(o.Model), ""))).ToList();
+ Assert.IsTrue(SeaCraft.Clear(new SeaCraft.Craft(SeaCraft.Kind.Steamer, p, 0f, len, ""), ground, works.ToList(), others, 0.5f * len),
+ key + " passes SeaCraft's clearance: open sea round it, off the harbour works and every other boat");
+ var w = SeaAirCollection.Wants(date, C).Single(x => x.Key == key);
+ var coast = SeaCraft.Coasts.Single(c => c.place == w.Place);
+ var shoreAt = map.Frame.ToWorld(coast.lon, coast.lat, 0);
+ var shore = SeaCraft.FirstWater(new Vector2(shoreAt.x, shoreAt.z), coast.seaward, ground, 20000f)!.Value;
+ Assert.GreaterOrEqual(Vector2.Dot(p - shore, coast.seaward), SeaCraft.OffshoreNearM * KitScale.Landmarks / 60f - 1f, key + " lies past the surf");
+ }
+ }
+ }
+
+ /// <summary>The C-54 keeps off the player's placements: a hex placed at the airport moves it to the next free ground.</summary>
+ [Test]
+ public void TheC54KeepsOffAPlacedHex()
+ {
+ var map = OpenMap();
+ var date = new DateTime(1949, 8, 15);
+ var layer = SeaAirCollection.ShowAt(map, date, Array.Empty<Placement>(), C)!; AnswerAll();
+ var first = layer.Placed.Single(p => p.Model == SeaAirCollection.C54).At;
+ var hex = C.Hexes.OrderBy(h => { var w = map.Frame.ToWorld(h.Lon, h.Lat, 0); return (new Vector2(w.x, w.z) - new Vector2(first.x, first.z)).sqrMagnitude; }).First();
+ var placed = new[] { new Placement(MapActions.TransitCamp, hex.Q, hex.R, date) };
+ SeaAirCollection.ShowAt(map, date, placed, C); AnswerAll();
+ var moved = layer.Placed.Single(p => p.Model == SeaAirCollection.C54).At;
+ var c = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);
+ Assert.GreaterOrEqual((new Vector2(moved.x, moved.z) - new Vector2(c.x, c.z)).magnitude,
+ 500f * map.Hexes.hex_size_km + 0.5f * SeaAirCollection.SizeOf(SeaAirCollection.C54) - 1f, "off the placed hex");
+ }
+
+ /// <summary>The owner (18 October 2026, #1033): "Train scale for all ambient life". Each craft's long side as drawn
+ /// (its renderers' world box, seen from above) is inside its band of the steam train's locomotive car (about 204 m:
+ /// MATKOT's locomotive and tender at RouteTrain.Scale x ServiceTrain.ModelSize / ServiceTrain.Cars), the band about its
+ /// real size at the one world scale (SettlementKits.ModelScale, 24x: an 8.5 m house is one car): the Altalena, a 100 m
+ /// LST, about 11.8 cars; the 80 m steamer about 9.4; the 10 m fishing boat about 1.2; the C-54's 35.8 m wingspan about
+ /// 4.2. No ship dwarfs its town: each is shorter than its port's kit footprint is across and than a whole-town model
+ /// (TownLandmarks.SizeM).</summary>
+ [Test]
+ public void EveryCraftIsAtTheTrainScaleAndNoShipDwarfsItsTown()
+ {
+ var map = OpenMap();
+ float loco = Statecraft.Game.Map.Routes.RouteTrain.ModelRealLengthM * Statecraft.Game.Map.Routes.RouteTrain.Scale
+ * Statecraft.Game.Map.Routes.ServiceTrain.ModelSize / Statecraft.Game.Map.Routes.ServiceTrain.Cars;
+ Assert.AreEqual(204f, loco, 1f, "the locomotive's car");
+ Assert.AreEqual(24f, SettlementKits.ModelScale, 0.01f, "the one world scale (#1030)");
+ var bands = new Dictionary<string, (float lo, float hi)>
+ {
+ [SeaAirCollection.Altalena] = (11f, 12.5f), [SeaAirCollection.Steamer] = (8f, 11f),
+ [SeaAirCollection.FishingBoat] = (0.9f, 1.5f), [SeaAirCollection.C54] = (3.9f, 4.5f),
+ };
+ var seen = new HashSet<string>();
+ var bad = new List<string>();
+ foreach (var date in new[] { new DateTime(1948, 6, 15), new DateTime(1949, 8, 15) })
+ {
+ var layer = SeaAirCollection.ShowAt(map, date, Array.Empty<Placement>(), C)!; AnswerAll();
+ Assert.AreEqual(layer.Placed.Count, layer.KeepClear.Count, "the labels keep clear of every drawn craft");
+ foreach (var (key, model, _) in layer.Placed)
+ {
+ var b = WorldBounds(layer.transform.Find(key)!.gameObject);
+ float side = Mathf.Max(b.size.x, b.size.z), cars = side / loco;
+ seen.Add(model);
+ TestContext.WriteLine($"{key}: {side:0} m long, {cars:0.00} locomotive cars, {b.size.y:0} m tall");
+ var (lo, hi) = bands[model];
+ if (cars < lo || cars > hi) bad.Add($"{key}: {side:0} m, {cars:0.00} locomotive cars (band {lo}-{hi})");
+ if (model == SeaAirCollection.C54) continue;
+ var place = SeaAirCollection.Wants(date, C).Single(w => w.Key == key).Place;
+ var town = map.KitFootprints.FirstOrDefault(f => f.id == place);
+ Assert.IsNotNull(town.id, place + " has a kit footprint");
+ TestContext.WriteLine($" {place}'s kit footprint {2f * town.radius:0} m across");
+ if (side >= 2f * town.radius) bad.Add($"{key}: {side:0} m against {place}'s {2f * town.radius:0} m");
+ if (side >= TownLandmarks.SizeM) bad.Add($"{key}: {side:0} m against a {TownLandmarks.SizeM:0} m whole-town model");
+ }
+ }
+ CollectionAssert.AreEquivalent(bands.Keys, seen, "every model measured");
+ CollectionAssert.IsEmpty(bad, string.Join("\n", bad));
+ }
+
+ /// <summary>The craft keep clear of the other 1948 Collection layers already on main: the whole-town models (#994), the
+ /// civilians (#1023), the farm life (#1029), the wildlife (#1022) and the Tegart fort, barracks and factory (#1031). On
+ /// both dated turns, every craft's box, seen from above, meets none of their renderers' boxes.</summary>
+ [Test]
+ public void TheCraftKeepClearOfTheOtherCollectionLayers()
+ {
+ var map = OpenMap();
+ Action<string, CollectionDetail, Action<GameObject?>> now = (id, d, done) => done(AssetDatabase.LoadAssetAtPath<GameObject>(CollectionCatalog.PrefabPath(id, d)));
+ var savedSeams = (TownLandmarks.Request, CivilianPeople.Request, RuralLife.Request, WildlifeLayer.Request, SpecialBuildingModels.Request);
+ TownLandmarks.Request = CivilianPeople.Request = RuralLife.Request = WildlifeLayer.Request = SpecialBuildingModels.Request = now;
+ try
+ {
+ int others = 0, checkedCraft = 0;
+ foreach (var date in new[] { new DateTime(1948, 6, 15), new DateTime(1949, 8, 15) })
+ {
+ var none = Array.Empty<Placement>();
+ var layers = new MonoBehaviour?[]
+ {
+ TownLandmarks.ShowAt(map, date, none, C), CivilianPeople.ShowAt(map, date, none, C), RuralLife.Show(map),
+ WildlifeLayer.Show(map), SpecialBuildingModels.ShowAt(map, date),
+ };
+ var boxes = layers.Where(l => l != null).SelectMany(l => l!.GetComponentsInChildren<Renderer>(true).Select(r => (l!.GetType().Name, r.bounds))).ToList();
+ others = Math.Max(others, boxes.Count);
+ var craft = SeaAirCollection.ShowAt(map, date, none, C)!; AnswerAll();
+ foreach (Transform t in craft.transform)
+ {
+ var b = WorldBounds(t.gameObject); checkedCraft++;
+ foreach (var (owner, o) in boxes)
+ Assert.IsFalse(b.min.x < o.max.x && o.min.x < b.max.x && b.min.z < o.max.z && o.min.z < b.max.z,
+ $"{t.name} meets {owner}'s model at {o.center} on {date:d MMM yyyy}");
+ }
+ }
+ Assert.Greater(others, 0, "the other layers drew");
+ Assert.AreEqual(8, checkedCraft, "every craft checked, four on each turn");
+ }
+ finally
+ {
+ (TownLandmarks.Request, CivilianPeople.Request, RuralLife.Request, WildlifeLayer.Request, SpecialBuildingModels.Request) = savedSeams;
+ }
+ }
+
+ /// <summary>Fails open: a model that does not stream warns once and is not drawn; the other craft draw and the map runs on.</summary>
+ [Test]
+ public void AModelThatDoesNotStreamWarnsAndTheOthersDraw()
+ {
+ var map = OpenMap(); var layer = SeaAirCollection.ShowAt(map, new DateTime(1949, 1, 15), Array.Empty<Placement>(), C)!;
+ var failed = asked.Single(x => x.id == SeaAirCollection.Steamer);
+ LogAssert.Expect(LogType.Warning, new Regex("^SEA/AIR: the model vehicle-immigrant-steamer-1948-v2wl did not stream"));
+ failed.done(null);
+ foreach (var a in asked.Where(x => x.id != SeaAirCollection.Steamer).ToList()) a.done(Far(a.id));
+ CollectionAssert.AreEquivalent(new[] { "jaffa-fishing", "acre-fishing" }, layer.Placed.Select(p => p.Key));
+ CollectionAssert.AreEqual(new[] { "haifa-steamer" }, layer.Missing);
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs.meta b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs.meta
new file mode 100644
index 000000000..15eb855de
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 4eb6d82c998d4d128dc0d8f93d102f24