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.

Units: figures and badge readable at the gameplay zoom, a tighter base (Refs #2430) (#2880)

Eyal Golanc4da9fec9bf6
diff --git a/changelog.d/2430-unit-readability.md b/changelog.d/2430-unit-readability.md
new file mode 100644
index 000000000..e80327d65
--- /dev/null
+++ b/changelog.d/2430-unit-readability.md
@@ -0,0 +1,2 @@
+### Changed
+- Units read better at the gameplay zoom: a unit's badge stays smaller than its figures, the figures and flag grow by up to 30% between 45 and 60 km, and the base sits closer round the figures. In a town, a unit's three figures no longer merge into one shape (Refs #2430).
diff --git a/docs/units.md b/docs/units.md
index 2ca99d8c0..6c36e18e4 100644
--- a/docs/units.md
+++ b/docs/units.md
@@ -465,10 +465,15 @@ and a unit the sim moves is placed without the control layer.
camera before the names are placed, and each token's keep-clear boxes follow (`UnitLayer.KeepClear`). A fixed box round
every place the camera's yaw could take the badge, about 3.7 km across, pushed Tel Aviv's name off its kit at gameplay03
(`MapLabelTests.PillsKeepClearOfTheUnitTokens`; test `TheKeepClearBoxesFollowTheBadgeAndTheFlagAsTheCameraTurns`).
- Up close the badge is capped on the screen (owner, 31 October 2026: "Shrink up close (Recommended)"): from about 30 km
- out it keeps its 1.4 km width, and a nearer camera draws it no taller than `UnitBadge.MaxScreenShare` of the screen's
+ Up close the badge is capped on the screen (owner, 31 October 2026: "Shrink up close (Recommended)"): from about 60 km
+ out it keeps its 1.4 km width (#2430: about 30 km until then, where the plate was nearly as wide as the figures are tall), and a
+ nearer camera draws it no taller than `UnitBadge.MaxScreenShare` of the screen's
height, shrinking about its lower edge, which stays clear of the flag (test `UnitBadgeScreenCapTests`).
- **Ring:** the white ring appears only on selection.
+- **Far zoom (#2430):** a token's figures and flag keep `UnitShowcase.FigureScale` up to 45 km (`TownModelLayer.CloseExitM`,
+ where the close building models have gone), grow to 1.3 times it at 60 km and stay there (`UnitShowcase.ZoomScale`), so a
+ figure stays near promo 03's size on the screen. The constant does not change, the figures keep their spots and the base
+ keeps its size. Only the game camera sets it (`UnitLayer.FaceCamera`). The showcase trio does not grow.
- **Base and flag (demo2 T29, refs #197).** An army token's figures stand shoulder to shoulder on one round earth base
ringed by a bright white rim (`UnitPlinth`), and the side's flag flies on a pole at the base's back edge (`UnitFlags`).
See "The base and the flag".
@@ -635,8 +640,10 @@ figures tall standing at the base's back edge. `UnitPlinth` and `UnitFlags` draw
- **Figures:** drawn at `UnitShowcase.DrawSpread` (0.19 of a hex's circumradius between neighbours), shoulder to
shoulder, the trio about 1.15 figure heights wide. The placer still checks a spot at `TrioSpread`, so no spot moved.
The showcase trio stands the same way.
-- **Base:** one draped earth disc per army token (see "Slopes"), its ring 1.45 times the full trio's width across
- (`UnitPlinth.BaseToTrio`; 1.42–1.44 measured on the built tokens, pinned to 1.3–1.7 by `TheBaseHugsTheTrioAsInT29`).
+- **Base:** one draped earth disc per army token (see "Slopes"), its ring 1.34 times the full trio's width across
+ (`UnitPlinth.BaseToTrio`, 1.45 until #2430; pinned to 1.3–1.7 by `TheBaseHugsTheTrioAsInT29`). A compact token's figures
+ stand at 0.6 of the spacing (`UnitShowcase.CompactSpread`; half until #2430 merged them into one shape), and its ring
+ still fits its town's clearing (#588).
The earth is the palette's `Earth`, dark and warm as T29's, mottled by smooth value noise over the world in its shade
rows (no texture). Owner, 2026-10-15: this base (earth 0.45, 0.33, 0.22), the lighter of the two rendered, over a
darker one (0.38, 0.28, 0.18) that brought the ring nearer T29's contrast but left the figures lighter than their base.
diff --git a/unity/Assets/Scripts/Map/Units/UnitBadge.cs b/unity/Assets/Scripts/Map/Units/UnitBadge.cs
index a27b9ea48..bd196eab4 100644
--- a/unity/Assets/Scripts/Map/Units/UnitBadge.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitBadge.cs
@@ -10,13 +10,15 @@ namespace Statecraft.Game.Map.Units
/// glyph says the service: two figures for a brigade, an aircraft for the squadron, a ship for the navy.</summary>
public sealed class UnitBadge : MonoBehaviour
{
- /// <summary>The plate's width at map scale (m): about a third of a figure's height, as in the promo.</summary>
+ /// <summary>The plate's width at map scale (m) from a far camera; nearer it is capped on the screen
+ /// (<see cref="MaxScreenShare"/>).</summary>
public const float SizeM = 1400f;
/// <summary>The largest share of the screen's height a plate is drawn at (owner, 31 October 2026, "Shrink up close
- /// (Recommended)"): a badge as big as it is in a 30 km view keeps <see cref="SizeM"/>; a nearer camera draws it smaller,
- /// so it never grows past this. Just over the largest a plate is drawn from 30 km out (0.142, 154 of 1080 pixels, at the
- /// view's lower edge; UnitBadgeScreenCapTests), so every view from there out is unchanged.</summary>
- public const float MaxScreenShare = 0.15f;
+ /// (Recommended)": a nearer camera draws it smaller, so it never grows past this). #2430: 0.15 left the plate nearly
+ /// as wide as the figures are tall at 31 km, the darkest thing on the token, where promo 03's is about half their
+ /// height. DESIGN VALUE 0.055, 59 of 1080 pixels; from about 60 km out a plate is <see cref="SizeM"/> wide and no taller than
+ /// this, and the plate, not the figures, is what reads (UnitBadgeScreenCapTests).</summary>
+ public const float MaxScreenShare = 0.055f;
/// <summary>Clearance (m) between the token's top and the plate's lower edge.</summary>
public const float LiftM = 1300f;
/// <summary>A rifleman's height (m, real) and the corvette's mast top (m, real): the token's top before scaling.</summary>
diff --git a/unity/Assets/Scripts/Map/Units/UnitLayer.cs b/unity/Assets/Scripts/Map/Units/UnitLayer.cs
index dbfe5a625..31abfc293 100644
--- a/unity/Assets/Scripts/Map/Units/UnitLayer.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitLayer.cs
@@ -130,6 +130,9 @@ namespace Statecraft.Game.Map.Units
new List<(Vector3, float, float, (Transform, Vector3, float)[], MeshFilter[])>();
/// <summary>The camera yaw the trios were last turned to: a pan or a zoom keeps the yaw, so it moves no figure.</summary>
float? turnedFor;
+ /// <summary>The figures' and flags' share of their scale now (<see cref="UnitShowcase.ZoomScale"/>, #2430): only the game
+ /// camera sets it, as it turns them, and only a new value touches them.</summary>
+ float zoomShown = 1f;
/// <summary>A badge sits this share of its token's base radius behind the trio, seen from the camera, and
/// <see cref="BadgeAsideM"/> to the side away from its flag's pole on screen (a compact token's pole cannot stand
/// further out than its base's edge).</summary>
@@ -320,6 +323,9 @@ namespace Statecraft.Game.Map.Units
bool turn = cam == Camera.main && turnedFor != yaw;
if (turn) turnedFor = yaw;
var turning = Quaternion.Euler(0f, turnedFor ?? 0f, 0f); // as the figures stand now (yaw 0 until first turned)
+ float zoom = cam == Camera.main ? UnitShowcase.ZoomScale(Kits.TownModelLayer.ViewDistance(cam)) : zoomShown;
+ bool rescale = zoom != zoomShown;
+ zoomShown = zoom;
for (int i = 0; i < badges.Count; i++)
{
var b = badges[i]; if (b == null) continue;
@@ -328,6 +334,11 @@ namespace Statecraft.Game.Map.Units
var slide = b.parent.position;
var (home, back, pole, flag, standing, parkedAircraft) = badgeHomes[i];
var (centre, radius, lift, figures, meshes) = trios[i];
+ if (rescale && figures.Length > 0)
+ {
+ foreach (var (figure, _, _) in figures) figure.localScale = Vector3.one * (UnitShowcase.FigureScale * zoom);
+ if (flag != null) flag.transform.localScale = Vector3.one * (UnitBadge.FigureHeightM * UnitShowcase.FigureScale * zoom);
+ }
if (turn && figures.Length > 0)
{
float highest = float.MinValue;
@@ -350,6 +361,8 @@ namespace Statecraft.Game.Map.Units
if (figures.Length > 0) pole = turning * pole; // where the pole stands now, for the badge's side
var aside = pole == Vector3.zero ? Vector3.zero : (Vector3.Dot(pole, right) > 0f ? -right : right) * BadgeAsideM;
var at = home + away * back + aside + slide;
+ if (figures.Length > 0 && flag != null) // the badge stays over the flag's top as the flag grows
+ at += Vector3.up * ((zoomShown - 1f) * UnitFlags.PoleHeight * UnitBadge.FigureHeightM * UnitShowcase.FigureScale);
// Owner, 31 October 2026 ("Shrink up close"): a near camera draws the plate no taller than a 30 km view does.
// It shrinks about its lower edge (the plate faces the camera, so its edges run along the camera's up), which
// stays where the full plate's is, clear of the flag and the figures; that move keeps the plate's depth.
@@ -449,7 +462,7 @@ namespace Statecraft.Game.Map.Units
float DisplayReach(AnchorSpot spot) => Mathf.Max(ground.RingRadius(spot.Compact),
UnitPlinth.Radius(UnitPlinth.TrioWidth(UnitShowcase.FigureOffsets(3),
- UnitShowcase.DrawSpread * ground.HexSizeM * Scale(spot))) * UnitPlinth.RimOuter);
+ UnitShowcase.DrawSpread * ground.HexSizeM * Spread(spot))) * UnitPlinth.RimOuter);
bool DisplayOverlap(AnchorSpot a, AnchorSpot b)
{
@@ -652,6 +665,9 @@ namespace Statecraft.Game.Map.Units
static float Scale(AnchorSpot s) => s.Compact ? UnitGround.CompactScale : 1f;
+ /// <summary>The share of <see cref="UnitShowcase.DrawSpread"/> a token's figures stand at.</summary>
+ static float Spread(AnchorSpot s) => s.Compact ? UnitShowcase.CompactSpread : 1f;
+
Vector3 Centre(AnchorSpot s) => UnitShowcase.Ground(map, new Vector3((float)s.X, 0f, (float)s.Z));
/// <summary>The ground the units are placed on (footprints, routes, land) for a built map.</summary>
@@ -757,7 +773,7 @@ namespace Statecraft.Game.Map.Units
drawnSims.Clear();
foreach (var p in placed) drawnSims.Add(p.Token.StateUnit?.Id ?? -1);
badges.Clear(); badgeHomes.Clear(); facedFor = null;
- trios.Clear(); turnedFor = null; // the new figures stand as at yaw 0
+ trios.Clear(); turnedFor = null; zoomShown = 1f; // the new figures stand as at yaw 0, at their own scale
treeHoles.Clear();
keepClear = new List<Bounds[]>(); // a new list, so the labels see the change
keepClearSpare = new List<Bounds[]>(); slid = false; // and a spare no label pass has seen
@@ -776,7 +792,7 @@ namespace Statecraft.Game.Map.Units
case UnitData.Army:
// Demo2 T29's token: the figures stand shoulder to shoulder on one earth base with a bright white
// rim, under the side's flag (refs #197). The base fits the full trio, whatever the call-up.
- float k = UnitShowcase.DrawSpread * hex * Scale(p.Spot);
+ float k = UnitShowcase.DrawSpread * hex * Spread(p.Spot);
plinth = UnitPlinth.Radius(UnitPlinth.TrioWidth(UnitShowcase.FigureOffsets(3), k));
foot.y = UnitPlinth.Build(map, go.transform, centre, plinth, t.Unit.Side, TokenMesh, MeshFor, paint, rim, FlagCloth);
treeHoles.Add((new Vector2(centre.x, centre.z), plinth * UnitPlinth.RimOuter));
@@ -855,7 +871,7 @@ namespace Statecraft.Game.Map.Units
if (t.Unit.Service == UnitData.Army && go.transform.Find(UnitPlinth.FlagName) != null)
lift = Mathf.Max(lift, UnitFlags.PoleHeight * UnitBadge.FigureHeightM * UnitShowcase.FigureScale + UnitBadge.SizeM / 2f + BadgeOverFlagM);
var home = foot + Vector3.up * lift;
- float back = t.Unit.Service == UnitData.Army ? BadgeBackShare * UnitPlinth.Radius(UnitPlinth.TrioWidth(UnitShowcase.FigureOffsets(3), UnitShowcase.DrawSpread * hex * Scale(p.Spot))) : 0f;
+ float back = t.Unit.Service == UnitData.Army ? BadgeBackShare * UnitPlinth.Radius(UnitPlinth.TrioWidth(UnitShowcase.FigureOffsets(3), UnitShowcase.DrawSpread * hex * Spread(p.Spot))) : 0f;
badge.transform.position = home + Vector3.forward * back;
badge.transform.localScale = Vector3.one * UnitBadge.SizeM;
badge.AddComponent<UnitBadge>();
diff --git a/unity/Assets/Scripts/Map/Units/UnitPlinth.cs b/unity/Assets/Scripts/Map/Units/UnitPlinth.cs
index 13a0479c8..7fa1572c7 100644
--- a/unity/Assets/Scripts/Map/Units/UnitPlinth.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitPlinth.cs
@@ -18,8 +18,10 @@ namespace Statecraft.Game.Map.Units
{
public const string PlinthName = "Plinth", LipName = "PlinthLip", RimName = "PlinthRim", FlagName = "Flag";
/// <summary>The ring's outer edge over the trio's width (the outer figures' outer edges), T29's measure: 1.41, 1.62
- /// and 1.71 on three of its tokens (4x crops of the 1:12 frame).</summary>
- public const float BaseToTrio = 1.45f;
+ /// and 1.71 on three of its tokens (4x crops of the 1:12 frame). #2430 tightens it from 1.45 to the bottom of the band
+ /// pinned to T29 (1.3, TheBaseHugsTheTrioAsInT29, measured on the drawn meshes): a DESIGN VALUE that leaves room for the
+ /// figures at <see cref="UnitShowcase.ZoomScaleMax"/>.</summary>
+ public const float BaseToTrio = 1.34f;
/// <summary>Half a figure's width (m, real size: the Ready pose's rifle across the body is the widest).</summary>
public const float FigureHalfWidthM = 0.35f;
/// <summary>The base's top over the ground under it, as a share of its radius (about 100 m): T29's base is a slab
diff --git a/unity/Assets/Scripts/Map/Units/UnitShowcase.cs b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs
index 94b169293..e97434753 100644
--- a/unity/Assets/Scripts/Map/Units/UnitShowcase.cs
+++ b/unity/Assets/Scripts/Map/Units/UnitShowcase.cs
@@ -24,6 +24,18 @@ namespace Statecraft.Game.Map.Units
/// showcase trio at close30 (T54 audit), so 1400x (refs #197). The aircraft and the ship are sized against him, as
/// Civ draws them, not against each other.</summary>
public const float FigureScale = 1400f;
+ /// <summary>DESIGN VALUES (#2430, the owner judges them on the captures): a token's figures and flag from a far camera, as a
+ /// share of <see cref="FigureScale"/>. Up to <see cref="ZoomScaleFromM"/>, the far edge of the close switch's hysteresis
+ /// (TownModelLayer.CloseExitM), they keep FigureScale, so T29's ratio to a house holds wherever a close building model
+ /// draws, and SpecialBuildingModels.FigureShadowM's reach holds wherever a workshop does. From there they grow to <see cref="ZoomScaleMax"/> at
+ /// <see cref="ZoomScaleToM"/> and stay there: a figure at 60 km was about 57 px of 1080, and this holds it near promo 03's
+ /// about 71 px. The token's base does not grow: the figures keep their spacing and <see cref="UnitPlinth.BaseToTrio"/> leaves
+ /// them room on it. The constant stays: spacing elsewhere (CivilianPeople) derives from it.</summary>
+ public const float ZoomScaleFromM = Kits.TownModelLayer.CloseExitM, ZoomScaleToM = 60000f, ZoomScaleMax = 1.3f;
+ /// <summary>The share of <see cref="FigureScale"/> a token's figures draw at for a camera at <paramref name="viewM"/>
+ /// (TownModelLayer.ViewDistance).</summary>
+ public static float ZoomScale(float viewM) =>
+ Mathf.Lerp(1f, ZoomScaleMax, Mathf.InverseLerp(ZoomScaleFromM, ZoomScaleToM, viewM));
/// <summary>The house T29's ratio is measured against at close30, as the T54 audit did: the White City block beside
/// the showcase trio, the kit's seven-storey heart block (7 x 3.3 m at <see cref="Kits.KitScale.DefaultCityBlocks"/>;
/// measured on the close30 render at about 1,300 m). A two-storey village house is about half of it.</summary>
@@ -175,6 +187,10 @@ namespace Statecraft.Game.Map.Units
/// across; ours 1.15 too: 2 x 950 m between the outer figures' centres plus a figure's width, against a 2.5 km man).
/// Narrower than <see cref="TrioSpread"/>, so the drawn figures stand inside the ground the placer checked.</summary>
public const float DrawSpread = 0.19f;
+ /// <summary>The share of <see cref="DrawSpread"/> a compact token's figures stand at (#2430): at the compact ring's half
+ /// (UnitGround.CompactScale) three figures merged into one shape. DESIGN VALUE: wider and the base's ring runs into the
+ /// selection ring, which stands at the town clearing's radius (UnitGround.RingRadius, #588).</summary>
+ public const float CompactSpread = 0.6f;
/// <summary>How far (in hexes) from <see cref="TrioAt"/> the showcase trio may move to stand clear of the kits and
/// the routes (<see cref="TrioSpot"/>).</summary>
public const float SpotSearchHexes = 2.2f;
diff --git a/unity/Assets/Tests/EditMode/UnitBadgeScreenCapTests.cs b/unity/Assets/Tests/EditMode/UnitBadgeScreenCapTests.cs
index 1bc64dac5..f4e95da18 100644
--- a/unity/Assets/Tests/EditMode/UnitBadgeScreenCapTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitBadgeScreenCapTests.cs
@@ -10,7 +10,8 @@ using UnityEditor.SceneManagement;
using UnityEngine;
/// <summary>The owner, 31 October 2026, asked "Should badges shrink when you're close?": "Shrink up close (Recommended)". A
-/// unit badge's plate keeps its world size (UnitBadge.SizeM) from a 30 km view out, and a nearer camera draws it no taller
+/// unit badge's plate keeps its world size (UnitBadge.SizeM) from far (#2430: from a 90 km view out, the 30 km of #2077 left it
+/// as wide as the figures are tall), and a nearer camera draws it no taller
/// than UnitBadge.MaxScreenShare of the screen (at 12 km over Gaza the Egyptian force's plate was about 700 of 1080 px).
/// Each view renders the units of the first turn at 1920x1080 with no top bar (the inset only moves the view's lower edge
/// further out, where badges are smaller), the look-at point swept from the token past the view's lower edge.</summary>
@@ -67,16 +68,19 @@ public class UnitBadgeScreenCapTests
}
Vector3 LowerEdge(Transform badge) => badge.position - badge.up * (0.5f * badge.lossyScale.y);
- // From 30 km out every plate on the screen is today's: SizeM wide, and so no taller than the cap.
- float largest = 0f; int seen = 0; var changed = new List<string>();
+ // Where each plate's lower edge stands in a 30 km view, which nearer views keep.
var lowerAt30 = new Dictionary<(int, float), Vector3>();
- foreach (var distance in new[] { 30000f, 45000f, 60000f })
+ foreach (var yaw in Yaws)
+ for (int i = 0; i < badges.Count; i++) { Look(i, 30000f, yaw, 0f); lowerAt30[(i, yaw)] = LowerEdge(badges[i]); }
+
+ // From 90 km out every plate on the screen is SizeM wide, and so no taller than the cap.
+ float largest = 0f; int seen = 0; var changed = new List<string>();
+ foreach (var distance in new[] { 90000f, 120000f, 250000f })
foreach (var yaw in Yaws)
for (int i = 0; i < badges.Count; i++)
foreach (var ahead in Ahead)
{
Look(i, distance, yaw, ahead);
- if (distance == 30000f && ahead == 0f) lowerAt30[(i, yaw)] = LowerEdge(badges[i]);
for (int j = 0; j < badges.Count; j++)
{
var (share, shown) = Drawn(badges[j]);
@@ -86,14 +90,14 @@ public class UnitBadgeScreenCapTests
changed.Add($"{distance / 1000f:0} km, yaw {yaw}, {ahead / 1000f:0} km beyond {badges[i].parent.name}: {badges[j].parent.name}'s plate is {badges[j].lossyScale.x:0} m ({share * 1080f:0} px of 1080)");
}
}
- Debug.Log($"BADGECAP from 30 km out: the largest plate on the screen is {largest:0.0000} of its height ({largest * 1080f:0} px of 1080), over {seen} plates; the cap is {UnitBadge.MaxScreenShare}");
- Assert.Greater(seen, 1000, "plates seen from 30 km out");
- Assert.IsEmpty(changed, $"from 30 km out every plate keeps its size; {changed.Count} did not, first: {string.Join("; ", changed.Take(5))}");
+ Debug.Log($"BADGECAP from 90 km out: the largest plate on the screen is {largest:0.0000} of its height ({largest * 1080f:0} px of 1080), over {seen} plates; the cap is {UnitBadge.MaxScreenShare}");
+ Assert.Greater(seen, 1000, "plates seen from 90 km out");
+ Assert.IsEmpty(changed, $"from 90 km out every plate keeps its size; {changed.Count} did not, first: {string.Join("; ", changed.Take(5))}");
// Nearer, no plate on the screen is taller than the cap; it shrinks about its lower edge, which stays where it
// was at 30 km (the camera's yaw alone places it), clear of the flag and the figures; clicks follow the plate.
int capped = 0;
- foreach (var distance in new[] { CameraController.MinDistance, 8000f, 12000f, 20000f })
+ foreach (var distance in new[] { CameraController.MinDistance, 8000f, 12000f, 20000f, 30000f })
foreach (var yaw in Yaws)
for (int i = 0; i < badges.Count; i++)
foreach (var ahead in Ahead)
@@ -119,6 +123,42 @@ public class UnitBadgeScreenCapTests
}
Assert.Greater(capped, 100, "nearer views shrink the plates");
+ // The gameplay band (#2430): the design's cap, as a literal, holds at 45 and 60 km. The plate's lower edge stands where it did at 30 km, raised with the flag: nothing at 45 km,
+ // the grown flag's 0.3 of a pole at 60 km (UnitShowcase.ZoomScale; the sweep above cannot assert this, its views
+ // are all below the ramp). A click on a plate still picks its unit.
+ const float DesignCap = 0.055f;
+ float pole = UnitFlags.PoleHeight * UnitBadge.FigureHeightM * UnitShowcase.FigureScale;
+ int cappedAt45 = 0, seenInBand = 0;
+ foreach (var (distance, grown) in new[] { (45000f, 0f), (60000f, 0.3f) })
+ foreach (var yaw in Yaws)
+ for (int i = 0; i < badges.Count; i++)
+ foreach (var ahead in Ahead)
+ {
+ Look(i, distance, yaw, ahead);
+ for (int j = 0; j < badges.Count; j++)
+ {
+ var (share, shown) = Drawn(badges[j]);
+ if (!shown) continue;
+ seenInBand++;
+ Assert.LessOrEqual(share, DesignCap + 1e-4f, $"{distance / 1000f:0} km, yaw {yaw}, {ahead / 1000f:0} km beyond {badges[i].parent.name}: {badges[j].parent.name}'s plate is {share * 1080f:0} px of 1080");
+ if (distance == 45000f && badges[j].lossyScale.x < UnitBadge.SizeM - 1f) cappedAt45++;
+ }
+ if (ahead != 0f) continue;
+ var b = badges[i]; var token = b.parent;
+ // The cap, not the raise, takes the "keeps its size" check off this band: it acts on a plate nearer than
+ // about 40 km to the camera, the 45 km views have many (BADGECAP below), and at 60 km a plate low on the screen stands
+ // near that depth (estimated). So the every-plate check starts at 90 km, and 60 km pins the plate in the view's centre.
+ if (grown > 0f) Assert.AreEqual(UnitBadge.SizeM, b.lossyScale.x, 1e-2f, $"{distance / 1000f:0} km, yaw {yaw}, {token.name}: the plate in the view's centre keeps its size");
+ float raise = token.Find(UnitPlinth.FlagName) != null ? grown * pole : 0f;
+ Assert.Less((LowerEdge(b) - (lowerAt30[(i, yaw)] + Vector3.up * raise)).magnitude, 1f, $"{distance / 1000f:0} km, yaw {yaw}, {token.name}: the plate's lower edge rises only with the flag");
+ var centre = cam.WorldToScreenPoint(b.position);
+ if (centre.z > 0f)
+ Assert.AreEqual(token.name, layer.TokenAtScreen(cam, centre)?.Token.Unit.Id, $"{distance / 1000f:0} km, yaw {yaw}: a click on {token.name}'s plate picks its unit");
+ }
+ Debug.Log($"BADGECAP gameplay band: {seenInBand} plates, {cappedAt45} capped at 45 km");
+ Assert.Greater(seenInBand, 1000, "plates seen in the gameplay band");
+ Assert.Greater(cappedAt45, 0, "the cap still acts at 45 km");
+
// The QA view of 31 October (v0.3.2, turn1-gaza-12km): the Egyptian plate low on the screen at 12 km, as low as
// it stays whole.
float low = new[] { 6000f, 5000f, 4000f, 3000f, 2000f, 0f }.First(a => { Look(egypt, 12000f, 0f, a); return Drawn(badges[egypt]).shown; });
diff --git a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs b/unity/Assets/Tests/EditMode/UnitPlinthTests.cs
index df9368c7e..babc35e93 100644
--- a/unity/Assets/Tests/EditMode/UnitPlinthTests.cs
+++ b/unity/Assets/Tests/EditMode/UnitPlinthTests.cs
@@ -1154,8 +1154,9 @@ public class UnitPlinthTests
layer.FaceCamera(cam);
var boxes = layer.KeepClear[i]; var badge = token.Find("Badge");
Assert.Less((boxes[0].center - badge.position).magnitude, 1f, $"yaw {yaw} {token.name}: the badge's box is round the badge as drawn");
- Assert.AreEqual(UnitBadge.SizeM, boxes[0].size.x, 1f, $"yaw {yaw} {token.name}: the badge's box is its own width");
- Assert.AreEqual(UnitBadge.SizeM, boxes[0].size.z, 1f, $"yaw {yaw} {token.name}: the badge's box is its own depth");
+ Assert.LessOrEqual(badge.lossyScale.x, UnitBadge.SizeM + 1e-2f, $"yaw {yaw} {token.name}: the plate is never wider than SizeM");
+ Assert.AreEqual(badge.lossyScale.x, boxes[0].size.x, 1f, $"yaw {yaw} {token.name}: the badge's box is its own width");
+ Assert.AreEqual(badge.lossyScale.x, boxes[0].size.z, 1f, $"yaw {yaw} {token.name}: the badge's box is its own depth");
var flag = token.Find(UnitPlinth.FlagName); if (flag == null) continue;
var grown = boxes[1]; grown.Expand(1f);
var m = flag.localToWorldMatrix;
@@ -1292,4 +1293,133 @@ public class UnitPlinthTests
}
finally { UnityEngine.Object.DestroyImmediate(map.gameObject); }
}
+
+ // ---- Readable at the gameplay zoom (#2430) ----------------------------------------------------------------------
+
+ /// <summary>The game camera's pose at <paramref name="viewM"/> over <paramref name="ground"/>, as CameraRig.Apply sets it.</summary>
+ static void Aim(Camera cam, Vector3 ground, float viewM)
+ {
+ cam.fieldOfView = CameraRig.Fov; cam.aspect = 16f / 9f; cam.farClipPlane = 1000000f;
+ cam.transform.rotation = Quaternion.Euler(CameraRig.Pitch, 0f, 0f);
+ ground.y = 0f;
+ cam.transform.position = ground - cam.transform.forward * viewM;
+ }
+
+ /// <summary>Up to the far edge of the close switch a figure keeps UnitShowcase.FigureScale, so the house ratio of #197 holds
+ /// wherever a close building model draws and SpecialBuildingModels.FigureShadowM wherever a workshop does; from there it
+ /// grows, and stops at the 60 km view.</summary>
+ [Test]
+ public void AFiguresScaleHoldsUpCloseAndGrowsToTheFarBand()
+ {
+ foreach (var near in new[] { CameraController.MinDistance, 12000f, CameraRig.StartDistance, Statecraft.Game.Map.Kits.TownModelLayer.CloseEnterM, Statecraft.Game.Map.Kits.TownModelLayer.CloseExitM })
+ Assert.AreEqual(1f, UnitShowcase.ZoomScale(near), 1e-6f, $"{near} m");
+ Assert.AreEqual(1.3f, UnitShowcase.ZoomScale(60000f), 1e-6f, "the 60 km view");
+ Assert.AreEqual(1.3f, UnitShowcase.ZoomScale(CameraController.MaxDistance), 1e-6f, "and it stops there");
+ Assert.AreEqual(1.3f, UnitShowcase.ZoomScale(float.PositiveInfinity), 1e-6f, "a camera that sees no ground");
+ Assert.That(UnitShowcase.ZoomScale(52500f), Is.InRange(1.1f, 1.2f), "between the two it ramps, with no step");
+ }
+
+ /// <summary>The token as a far camera draws it: figures and flag at the zoom's scale, on the same spots on the same base,
+ /// the badge over the grown flag, and the click and the names' boxes round the figures as drawn. A closer camera gives
+ /// the figures back their scale, and a rebuild made from far draws the new tokens at the far scale.</summary>
+ [Test]
+ public void AFarCameraGrowsTheFiguresAndFlagOnTheirBase()
+ {
+ var map = BuildMap();
+ try
+ {
+ var cam = Camera.main;
+ var layer = UnitLayer.Create(map, UnitData.Parse(CommittedYaml), C.Hexes, still: true);
+ layer.Show(C, StateAt(Dates[0]));
+ var tokensRoot = map.Terrain.transform.Find(UnitLayer.RootName).Find("Tokens");
+ var token = tokensRoot.Cast<Transform>().First(t => t.Cast<Transform>().Count(f => f.name.StartsWith("Rifleman")) == 3);
+ int index = layer.Tokens.ToList().FindIndex(t => t.Token.Unit.Id == token.name);
+ var plinth = token.Find(UnitPlinth.PlinthName); var centre = plinth.position;
+ float flagSize = UnitBadge.FigureHeightM * UnitShowcase.FigureScale;
+
+ Aim(cam, centre, CameraRig.StartDistance); layer.FaceCamera(cam);
+ var figures = token.Cast<Transform>().Where(f => f.name.StartsWith("Rifleman")).ToList();
+ var flag = token.Find(UnitPlinth.FlagName);
+ var spots = figures.Select(f => f.position).ToList();
+ var baseParts = new[] { UnitPlinth.PlinthName, UnitPlinth.LipName, UnitPlinth.RimName }.Select(n => token.Find(n)).ToList();
+ var baseScales = baseParts.Select(p => p.localScale).ToList(); // as the opening view draws them
+ float baseRadius = plinth.localScale.x;
+ Assert.AreEqual(UnitShowcase.FigureScale, figures[0].localScale.x, 1e-2f, "the opening view keeps the ruled scale");
+ Assert.AreEqual(flagSize, flag.localScale.x, 1e-2f);
+
+ Aim(cam, centre, 60000f); layer.FaceCamera(cam);
+ foreach (var f in figures) Assert.AreEqual(1.3f * UnitShowcase.FigureScale, f.localScale.x, 1e-2f, $"{f.name} at 60 km");
+ Assert.AreEqual(1.3f * flagSize, flag.localScale.x, 1e-2f, "the flag grows with them");
+ for (int i = 0; i < figures.Count; i++) Assert.Less((figures[i].position - spots[i]).magnitude, 1f, $"{figures[i].name} stays on its spot");
+ for (int i = 0; i < baseParts.Count; i++) Assert.AreEqual(baseScales[i], baseParts[i].localScale, $"{baseParts[i].name} keeps its size at 60 km");
+ float boots = 0.2f * 1.3f * UnitShowcase.FigureScale;
+ foreach (var f in figures)
+ Assert.Less((new Vector2(f.position.x, f.position.z) - new Vector2(centre.x, centre.z)).magnitude + boots, baseRadius, $"{f.name}'s boots stay on the base");
+
+ var badge = token.Find("Badge");
+ float flagTop = flag.position.y + UnitFlags.PoleHeight * flag.localScale.y;
+ Assert.Greater(badge.position.y - 0.5f * badge.lossyScale.y, flagTop, "the badge clears the grown flag's top");
+ var head = figures[1].position + Vector3.up * (1.3f * flagSize * 0.95f);
+ Assert.IsTrue(layer.KeepClear[index][1].Contains(head), "the names' and the click's box holds the grown figure's head");
+ float farTop = layer.KeepClear[index][1].max.y;
+ Assert.AreEqual(token.name, layer.TokenAtScreen(cam, cam.WorldToScreenPoint(head))?.Token.Unit.Id, "a click on the head picks the unit");
+
+ Aim(cam, centre, CameraRig.StartDistance); layer.FaceCamera(cam);
+ foreach (var f in figures) Assert.AreEqual(UnitShowcase.FigureScale, f.localScale.x, 1e-2f, $"{f.name} back at the opening view");
+ Assert.AreEqual(flagSize, flag.localScale.x, 1e-2f, "and the flag");
+ Assert.Less(layer.KeepClear[index][1].max.y, farTop - 0.2f * flagSize, "and the box shrinks back with them");
+
+ Aim(cam, centre, 60000f); layer.FaceCamera(cam);
+ Assert.IsTrue(layer.Show(C, StateAt(Dates[1])), "the roster changes");
+ var rebuilt = tokensRoot.Cast<Transform>().First(t => t.Cast<Transform>().Any(f => f.name.StartsWith("Rifleman")));
+ Assert.AreEqual(1.3f * UnitShowcase.FigureScale, rebuilt.Cast<Transform>().First(f => f.name.StartsWith("Rifleman")).localScale.x, 1e-2f,
+ "a rebuild from far draws the new tokens at the far scale");
+ }
+ finally { UnityEngine.Object.DestroyImmediate(map.gameObject); }
+ }
+
+ /// <summary>The badge is a small marker over the figures at the gameplay zoom, as in promo 03, not the token's largest dark
+ /// shape: at the opening view it is well under a figure's height on the screen, and from far it keeps its map size.</summary>
+ [Test]
+ public void TheBadgeStaysSmallerThanTheFiguresAtTheGameplayZoom()
+ {
+ float m11 = 1f / Mathf.Tan(0.5f * CameraRig.Fov * Mathf.Deg2Rad), depth = CameraRig.StartDistance;
+ float plate = UnitBadge.SizeFor(depth, m11, false) * m11 / (2f * depth);
+ float figure = UnitBadge.FigureHeightM * UnitShowcase.FigureScale * Mathf.Cos(CameraRig.Pitch * Mathf.Deg2Rad) * m11 / (2f * depth);
+ Assert.Less(plate, 0.7f * figure, $"the plate is {plate * 1080f:0} px of 1080, a figure {figure * 1080f:0} px");
+ Assert.AreEqual(UnitBadge.SizeM, UnitBadge.SizeFor(120000f, m11, false), 1e-2f, "at 120 km the plate keeps its map size");
+ }
+
+ /// <summary>A compact token's three figures stand apart enough to read as three (at the compact ring's half spacing they
+ /// merged into one shape), and its ring stays clear inside the selection ring, which stands at the radius of the clearing a
+ /// town keeps for it (#588), so a selected token shows two rings.</summary>
+ [Test]
+ public void ACompactTokensFiguresReadAsThreeAndItsRingFitsTheClearing()
+ {
+ var map = BuildMap();
+ try
+ {
+ var layer = UnitLayer.Create(map, UnitData.Parse(CommittedYaml), C.Hexes, still: true);
+ float hex = map.Hexes.hex_size_km * 1000f, clearing = UnitShowcase.RingRadius * hex * UnitGround.CompactScale;
+ float selectionInner = clearing - 0.5f * UnitShowcase.RingWidth * clearing / UnitShowcase.RingRadius;
+ float width = 2f * UnitPlinth.FigureHalfWidthM * UnitShowcase.FigureScale;
+ int seen = 0;
+ foreach (var date in Dates)
+ {
+ layer.Show(C, StateAt(date));
+ foreach (var p in layer.Tokens.Where(t => t.Spot.Compact && t.Token.Unit.Service == UnitData.Army))
+ {
+ var token = map.Terrain.transform.Find(UnitLayer.RootName).Find("Tokens").Find(p.Token.Unit.Id);
+ var plinth = token.Find(UnitPlinth.PlinthName);
+ Assert.Less(plinth.localScale.x * UnitPlinth.RimOuter, selectionInner - 50f, $"{token.name}: the ring clear inside the selection ring");
+ var figures = token.Cast<Transform>().Where(f => f.name.StartsWith("Rifleman") || f.name.StartsWith("Figure")).ToList();
+ for (int i = 0; i + 1 < figures.Count; i++)
+ Assert.Greater((figures[i].position - figures[i + 1].position).magnitude, 0.5f * width, $"{token.name}: figures {i} and {i + 1} stand apart");
+ seen++;
+ }
+ }
+ Assert.Greater(seen, 0, "compact tokens were found (not a vacuous pass)");
+ }
+ finally { UnityEngine.Object.DestroyImmediate(map.gameObject); }
+ }
}
diff --git a/unity/Assets/Tests/EditMode/UnitScaleShots.cs b/unity/Assets/Tests/EditMode/UnitScaleShots.cs
new file mode 100644
index 000000000..33cdb8e9e
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitScaleShots.cs
@@ -0,0 +1,251 @@
+#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.Map.Units;
+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 #2430 (unit figure scale and base size at the gameplay zoom) to
+/// `.superpowers/shots-2430/&lt;SHOTS_TAG&gt;/` at the repository root (local, not committed; SHOTS_TAG from the environment,
+/// "untagged" when unset). It uses only calls main has, so the same file gives both sides from the same state and camera. Each
+/// still is the game's camera at 1920x1080 with the game's UI drawn over it (CivMovementShots.Shot's composite): the opening
+/// view, then one army token of each side at 12, 31, 45 and 60 km (the rig's distance, yaw 10 as PromoPose.Gameplay03), then a
+/// town's token and the selected and focused token; DatedTokens adds the Lebanese Army and a token with vehicles. Every figure, weapon and town model is answered from the
+/// AssetDatabase, so the stills show what a player gets once the models have streamed. Explicit, so it does not run with the
+/// checks. Run (Unity, the unity/ project):
+/// <code>SHOTS_TAG=after &lt;Unity&gt; -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter UnitScaleShots</code></summary>
+[Explicit("writes stills for a pull request, not a check")]
+public class UnitScaleShots
+{
+ const int Width = 1920, Height = 1080;
+ static readonly string[] Sides = { "israel", "egypt", "syria", "jordan", "iraq", "lebanon" };
+ static readonly float[] Km = { 12f, 31f, 45f, 60f };
+ string shotDir = "", saveDir = "";
+ RenderTexture? rt; PanelSettings? ps;
+ GameRoot root = null!;
+ VisualElement ui = null!;
+ Func<string, CollectionDetail, Action<GameObject?>, IDisposable>? savedTown;
+ Action<string, CollectionDetail, Action<GameObject?>>? savedFigures;
+ Action<string, Action<GameObject?>>? savedWeapons;
+
+ 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>();
+
+ [SetUp]
+ public void Prepare()
+ {
+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");
+ shotDir = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", ".superpowers", "shots-2430", string.IsNullOrEmpty(tag) ? "untagged" : tag));
+ Directory.CreateDirectory(shotDir);
+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-unit-scale-shots-" + Guid.NewGuid().ToString("N"));
+ savedTown = TownModelLayer.ModelAcquire; savedFigures = UnitFigures.Source; savedWeapons = UnitWeapons.Source;
+ TownModelLayer.ModelAcquire = (id, detail, done) => { done(Prefab(id, detail)); return new NoLease(); };
+ UnitFigures.Forget();
+ UnitFigures.Source = (id, detail, done) => done(Prefab(id, detail));
+ UnitWeapons.Source = (id, done) => done(id == CollectionCatalog.C06PointFire ? null : Prefab(id, CollectionDetail.Far));
+ }
+
+ [TearDown]
+ public void DiscardScene()
+ {
+ TownModelLayer.ModelAcquire = savedTown!; UnitFigures.Source = savedFigures; UnitWeapons.Source = savedWeapons; UnitFigures.Forget();
+ 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);
+ }
+
+ /// <summary>CivMovementShots.Boot at this rig's size.</summary>
+ IEnumerator Boot()
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var doc = Object.FindFirstObjectByType<UIDocument>();
+ ShotCamera.Configure(Camera.main, Width, Height); // CameraRig.Apply freezes the projection at the camera's own aspect: a
+ // batch run's default is 4:3, which drew every still 1.33 times too wide
+ rt = new RenderTexture(Width, Height, 24, RenderTextureFormat.ARGB32);
+ ps = Object.Instantiate(doc.panelSettings);
+ ps.targetTexture = rt; ps.clearColor = true; ps.colorClearValue = Color.clear;
+ doc.panelSettings = ps;
+ Scene.Build(MapFocusTests.Inputs.Map);
+ root = Object.FindFirstObjectByType<GameRoot>();
+ root.Store = new SaveStore(saveDir);
+ root.Begin(MapFocusTests.Inputs, 0);
+ 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);
+ }
+
+ 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>Settles the near models and the labels on the camera, then writes the composite.</summary>
+ IEnumerator Shot(string name)
+ {
+ var cam = Camera.main; var units = root.Units!;
+ for (int i = 0; i < 8; i++)
+ {
+ units.FaceCamera(cam); UnitFlagFacing.FaceAll(cam.transform.position);
+ foreach (var a in units.GetComponentsInChildren<Animator>(true)) { a.cullingMode = AnimatorCullingMode.AlwaysAnimate; if (a.isActiveAndEnabled) a.Update(0f); }
+ cam.Render();
+ yield return null;
+ }
+ var frame = new RenderTexture(Width, Height, 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(Width, Height, TextureFormat.RGB24, false);
+ tex.SetPixels(outPx); tex.Apply();
+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());
+ Object.DestroyImmediate(tex);
+ Debug.Log(FormattableString.Invariant($"SHOT {name}: rig {cam.GetComponent<CameraRig>().Distance:F0} m, aspect {cam.aspect:F3}, m00/m11 {cam.projectionMatrix[0, 0] / cam.projectionMatrix[1, 1]:F3}"));
+ }
+
+ static void Aim(Vector3 at, float distance, float yaw = 10f)
+ {
+ var rig = Camera.main.GetComponent<CameraRig>();
+ rig.LookAt = at; rig.Distance = distance; rig.Yaw = yaw; rig.Apply();
+ }
+
+ /// <summary>A token's ground point, its base and its figures' screen height on the current camera.</summary>
+ static string Measure(PlacedToken p)
+ {
+ var map = Scene; var cam = Camera.main;
+ var token = map.Terrain.transform.Find(UnitLayer.RootName + "/Tokens/" + p.Token.Unit.Id);
+ var plinth = token.Find(UnitPlinth.PlinthName);
+ var at = UnitShowcase.Ground(map, new Vector3((float)p.Spot.X, 0f, (float)p.Spot.Z));
+ float Px(Vector3 a, Vector3 b) => (cam.WorldToScreenPoint(a) - cam.WorldToScreenPoint(b)).magnitude * Height / cam.pixelHeight;
+ var box = token.GetComponentsInChildren<Renderer>(true).Where(r => r.name.StartsWith("Figure") || r.name.StartsWith("Rifleman") || r.transform.parent.name == UnitFigures.ModelName).Select(r => r.bounds).ToList();
+ float tall = box.Count == 0 ? 0f : box.Max(b => b.size.y);
+ float wide = plinth == null ? 0f : 2f * plinth.localScale.x * UnitPlinth.RimOuter;
+ return FormattableString.Invariant($"{p.Token.Unit.Id} ({p.Token.Unit.Side}, compact={p.Spot.Compact}, figures={p.Token.Figures}): figure {tall:F0} m = {Px(at, at + Vector3.up * tall):F0} px; ring {wide:F0} m = {Px(at, at + cam.transform.right * wide):F0} px");
+ }
+
+ [UnityTest]
+ public IEnumerator Zooms()
+ {
+ yield return Boot();
+ var units = root.Units!;
+ var map = Scene; var cam = Camera.main;
+ Debug.Log("SHOT tokens: " + string.Join(", ", units.Tokens.Select(t => $"{t.Token.Unit.Id}/{t.Token.Unit.Side}/{t.Token.Unit.Service}")));
+ yield return Shot("opening");
+ foreach (var side in Sides)
+ {
+ var hit = units.Tokens.Where(t => t.Token.Unit.Side == side && t.Token.Unit.Service == UnitData.Army).OrderBy(t => t.Token.Unit.Id, StringComparer.Ordinal).ToList();
+ if (hit.Count == 0) { Debug.LogWarning($"SHOT {side}: no army token at the opening"); continue; }
+ var p = hit[0];
+ var at = UnitShowcase.Ground(map, new Vector3((float)p.Spot.X, 0f, (float)p.Spot.Z));
+ foreach (var km in Km)
+ {
+ Aim(at, km * 1000f);
+ var name = FormattableString.Invariant($"{side}-{km:0}km");
+ yield return Shot(name);
+ Debug.Log($"SHOT {name}: " + Measure(p));
+ }
+ }
+ // A token with vehicles on its base, if the opening has one.
+ var wheels = units.Tokens.Where(t => t.Token.Vehicles.Count > 0).OrderBy(t => t.Token.Unit.Id, StringComparer.Ordinal).ToList();
+ Debug.Log("SHOT vehicles: " + string.Join(", ", wheels.Select(t => t.Token.Unit.Id)));
+ if (wheels.Count > 0)
+ {
+ var at = UnitShowcase.Ground(map, new Vector3((float)wheels[0].Spot.X, 0f, (float)wheels[0].Spot.Z));
+ foreach (var km in new[] { 12f, 31f, 60f }) { Aim(at, km * 1000f); yield return Shot(FormattableString.Invariant($"vehicles-{km:0}km")); }
+ }
+ // A token in a town (compact, #588), selected, with the map's keyboard stop focused on it.
+ var town = units.Tokens.Where(t => t.Spot.Compact && t.Token.Unit.Service == UnitData.Army).OrderBy(t => t.Token.Unit.Id, StringComparer.Ordinal).FirstOrDefault();
+ if (town.Token != null)
+ {
+ var at = UnitShowcase.Ground(map, new Vector3((float)town.Spot.X, 0f, (float)town.Spot.Z));
+ foreach (var km in new[] { 12f, 31f })
+ {
+ Aim(at, km * 1000f);
+ yield return Shot(FormattableString.Invariant($"town-{km:0}km"));
+ Debug.Log("SHOT town: " + Measure(town));
+ units.Select(town.Token.Unit.Id);
+ ui.Q("map-focus").Focus();
+ yield return Frames(3);
+ yield return Shot(FormattableString.Invariant($"town-selected-{km:0}km"));
+ units.Select(null);
+ }
+ }
+ }
+
+ /// <summary>The tokens the opening does not have: the Lebanese Army's and a token with vehicles on its base, on the legacy
+ /// dated roster (Generated1948Characters.CampaignStage, the map without the UI), the first date each stands.</summary>
+ [UnityTest]
+ public IEnumerator DatedTokens()
+ {
+ var generated = Type.GetType("Statecraft.Game.EditorTools.Generated1948Characters, Assembly-CSharp-Editor")!;
+ const System.Reflection.BindingFlags Any = System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public;
+ var (map, layer, state) = ((MapScene map, UnitLayer layer, GameState state))generated.GetMethod("CampaignStage", Any)!.Invoke(null, new object[] { new DateTime(1948, 5, 20) });
+ var render = generated.GetMethod("RenderMap", Any)!;
+ var cam = Object.FindFirstObjectByType<CameraRig>().GetComponent<Camera>(); var rig = cam.GetComponent<CameraRig>();
+ ShotCamera.Configure(cam, 1920, 1080); // the size RenderMap renders
+ var todo = new Dictionary<string, Func<PlacedToken, bool>>
+ {
+ ["lebanon"] = t => t.Token.Unit.Side == "lebanon" && t.Token.Unit.Service == UnitData.Army,
+ ["vehicles"] = t => t.Token.Vehicles.Count > 0,
+ };
+ foreach (var date in new[] { new DateTime(1948, 5, 20), new DateTime(1948, 6, 5), new DateTime(1948, 7, 12), new DateTime(1948, 10, 15), new DateTime(1948, 12, 4) })
+ {
+ var s = state.Clone(); s.Date = date; layer.Show(SimBridgeGddTests.Legacy, s);
+ foreach (var key in todo.Keys.ToList())
+ {
+ var hit = layer.Tokens.Where(todo[key]).OrderBy(t => t.Token.Unit.Id, StringComparer.Ordinal).ToList();
+ if (hit.Count == 0) continue;
+ todo.Remove(key);
+ var at = UnitShowcase.Ground(map, new Vector3((float)hit[0].Spot.X, 0f, (float)hit[0].Spot.Z));
+ foreach (var km in new[] { 12f, 31f, 60f })
+ {
+ rig.LookAt = at; rig.Distance = km * 1000f; rig.Yaw = 10f; rig.TopInset = 0f; rig.Apply();
+ for (int i = 0; i < 8; i++)
+ {
+ layer.FaceCamera(cam); UnitFlagFacing.FaceAll(cam.transform.position);
+ foreach (var a in layer.GetComponentsInChildren<Animator>(true)) { a.cullingMode = AnimatorCullingMode.AlwaysAnimate; if (a.isActiveAndEnabled) a.Update(0f); }
+ cam.Render();
+ yield return null;
+ }
+ var name = FormattableString.Invariant($"dated-{key}-{km:0}km");
+ render.Invoke(null, new object[] { cam, Path.Combine(shotDir, name + ".jpg") });
+ Debug.Log(FormattableString.Invariant($"SHOT {name}: {hit[0].Token.Unit.Id} on {date:yyyy-MM-dd}, vehicles {hit[0].Token.Vehicles.Count}"));
+ }
+ }
+ }
+ foreach (var key in todo.Keys) Debug.LogWarning($"SHOT {key}: no token on the dates tried");
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/UnitScaleShots.cs.meta b/unity/Assets/Tests/EditMode/UnitScaleShots.cs.meta
new file mode 100644
index 000000000..6bbfe2578
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/UnitScaleShots.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 51e98a24f6d64e8aa5dde110f33d7f8d
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant: