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: two smaller Dakotas bomb Tel Aviv, flying as the Spitfire does (Refs #2482) (#2490)

Eyal Golan7b6acd9e41a7
diff --git a/ASSETS.yaml b/ASSETS.yaml
index 49b6431d6..f53d95a65 100644
--- a/ASSETS.yaml
+++ b/ASSETS.yaml
@@ -1694,6 +1694,23 @@ rules:
licence: Copernicus-DEM
source: "tools/terrain_bake.py from the Copernicus DEM GLO-30-derived heightmap (unity/Assets/StreamingAssets/map/heightmap.*): AO, curvature, sky-view (Map/terrain_bake.png), coast distance (Map/coast.png) and the AO copy (Map/ao.png); the terrain water's mesh samples (Map/terrain_water.bytes, Editor TerrainWaterBake from the same heightmap); attribution in NOTICE"
status: verified
+ # --- Unity Labs' CC0 VFX flipbooks: the Dakotas' bomb blasts and smoke columns over Tel Aviv (#2490; owner, 4 Nov 2026, "Yes, use Unity's CC0 set (Recommended)") ---
+ - glob: "unity/Assets/Resources/Effects/Explosion01_5x5.png"
+ licence: CC0-1.0
+ ai_generated: false
+ status: verified
+ artist: "Unity Technologies (Unity Labs)"
+ credit: "Unity Technologies (Unity Labs), CC0"
+ source: "Unity Technologies (Unity Labs), 'Free VFX image sequences and flipbooks' by Thomas Iché, 28 November 2016, https://unity.com/blog/engine-platform/free-vfx-image-sequences-flipbooks, which says: 'Today, we release some of these sequences under CC0 license' (linked to https://creativecommons.org/publicdomain/zero/1.0/) and lists this sequence among its downloads. Read and downloaded 2026-11-04 from the page's own link, https://unity3d.com/files/labs/downloads/vfx/assets01/Explosion01/Explosion01-flipbooks.zip (3,001,400 B, SHA-256 496a212733eb4e93c230f654f1fc1460e8a6389d2f1b13f2b945ec124a375742), its Explosion01_5x5.tga (1024x1024 RGBA, 5 x 5 frames, SHA-256 4af82af6311c0fb4d106de7768dda851c26f65cf2c1679938294878c250482ec), converted to PNG with macOS sips, no other change (814,024 B, SHA-256 a75a55de571a47fd05e3add72761cf6d51fe3ed8fe8f4a16d5b35679da5357f5)"
+ note: "Rendered in Houdini by Unity Labs, not AI-generated. The blast of each Dakota bomb (DakotaBombRun). CC0 asks no attribution; the credit is a courtesy."
+ - glob: "unity/Assets/Resources/Effects/Cloud02_8x8.png"
+ licence: CC0-1.0
+ ai_generated: false
+ status: verified
+ artist: "Unity Technologies (Unity Labs)"
+ credit: "Unity Technologies (Unity Labs), CC0"
+ source: "Unity Technologies (Unity Labs), 'Free VFX image sequences and flipbooks' by Thomas Iché, 28 November 2016, https://unity.com/blog/engine-platform/free-vfx-image-sequences-flipbooks, which says: 'Today, we release some of these sequences under CC0 license' (linked to https://creativecommons.org/publicdomain/zero/1.0/) and lists this sequence among its downloads. Read and downloaded 2026-11-04 from the page's own link, https://unity3d.com/files/labs/downloads/vfx/assets01/Cloud02/Cloud02-flipbooks.zip (3,433,127 B, SHA-256 99ce5ed3ec21646dd4a0644c2149978ed4f2fd9ab2ef269b5cfcc89a7a9cc036), its Cloud02_8x8.tga (1024x1024 RGBA, 8 x 8 frames, SHA-256 29081e19dc2d50ae69c019259f8dba3fb2795292a970b95ba49b03b79f125edd), converted to PNG with macOS sips, no other change (979,532 B, SHA-256 b9cb8baf38cfbdecdeab1f10864326ae11c4a217baa509b21c95bf79a66723ff)"
+ note: "Rendered in Houdini by Unity Labs, not AI-generated. The Dakota bombs' dust and the smoke columns over Tel Aviv (DakotaBombRun). CC0 asks no attribution; the credit is a courtesy."
# --- Ben-Gurion's 1948 recording on the start screen (docs/declaration-recording.md; docs/oss/DECISIONS.md D-R) ---
- glob: "unity/Assets/StreamingAssets/audio/declaration-1948-isa-00113hj.wav"
licence: Israel State Archives terms of use
diff --git a/LICENSING.md b/LICENSING.md
index 3eaf22969..be85de20b 100644
--- a/LICENSING.md
+++ b/LICENSING.md
@@ -34,6 +34,7 @@ Different parts of this repository are under different licences. Where a file is
| Fonts | `unity/Assets/UI/Fonts/` | EB Garamond, [SIL Open Font License 1.1](unity/Assets/UI/Fonts/OFL.txt); Frank Ruhl Libre (`FrankRuhlLibre/`), [SIL Open Font License 1.1](unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt) |
| Terrain heightmap | `unity/Assets/StreamingAssets/map/heightmap.*`, `content/map/hexes.json` (elevations) | Derived from Copernicus GLO-30 under the Copernicus DEM licence. Required notice: "produced using Copernicus WorldDEM-30 (c) DLR e.V. 2010-2014 and (c) Airbus Defence and Space GmbH 2014-2018 provided under COPERNICUS by the European Union and ESA; all rights reserved" |
| Derived map bakes | `unity/Assets/Resources/Map/BiomeColours.bytes` (biome colours, #529), `unity/Assets/Resources/Routes/RouteRibbons.bytes` (route ribbons, #436), `unity/Assets/Textures/Map/landuse.png` (land-use texture, `tools/land_bake.py`, #33), `unity/Assets/Resources/Map/MinimapRelief.png` (the minimap's painted relief, `tools/minimap_bake.py`, #398) | Made by the bakes from the map content (`content/map/`, CC BY-SA 4.0) and the Copernicus-derived heightmap. The hexes' biomes come from the Copernicus DEM, CHELSA V2.1 and the IMS station normals. [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), the most restrictive input, by the owner's decision D13 (`docs/oss/DECISIONS.md`); per-file records in `ASSETS.yaml` |
+| Unity Labs VFX flipbooks | `unity/Assets/Resources/Effects/Explosion01_5x5.png`, `unity/Assets/Resources/Effects/Cloud02_8x8.png` (the Dakotas' bomb blasts and smoke, #2490) | [CC0 1.0](LICENSES/CC0-1.0.txt): released by Unity Technologies (Unity Labs) under CC0 in "Free VFX image sequences and flipbooks" (https://unity.com/blog/engine-platform/free-vfx-image-sequences-flipbooks, read 4 November 2026); converted from TGA to PNG only. Credit "Unity Technologies (Unity Labs), CC0" as a courtesy; per-file records in `ASSETS.yaml` |
| Precipitation grid | `content/map/precip_bio12.*` | CHELSA V2.1, CC0 1.0 (Karger et al. 2017, 2021; see `tools/README.md`) |
| Rain-gauge data | `content/map/precip_stations.json` | Israel Meteorological Service, data.gov.il dataset 481, under the licence stated on the dataset ("Other (Open)") |
| Unity engine and packages | `unity/Packages/`, `unity/ProjectSettings/` | Configuration only. The Unity engine and its packages are under Unity's own terms and are not included. Two editor-only packages come from OpenUPM under their own licences and are not included either: `com.ivanmurzak.unity.mcp` (Unity-MCP, Apache-2.0) and its dependency `extensions.unity.playerprefsex` (MIT); see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). No Asset Store content is in this repository. |
diff --git a/NOTICE b/NOTICE
index 2521c2f93..655d8f15f 100644
--- a/NOTICE
+++ b/NOTICE
@@ -26,6 +26,9 @@ Precipitation: CHELSA V2.1 bio12 (1981-2010), CC0 1.0. Karger, D.N., Conrad, O.,
Soria-Auza, R.W., Zimmermann, N.E., Linder, H.P. & Kessler, M. (2021) Climatologies at high resolution for the earth's
land surface areas. EnviDat. https://doi.org/10.16904/envidat.228.v2.1 ; Karger et al. (2017) Scientific Data 4, 170122.
+Bomb blast and smoke flipbooks (unity/Assets/Resources/Effects/): Unity Technologies (Unity Labs), CC0 1.0,
+"Free VFX image sequences and flipbooks", https://unity.com/blog/engine-platform/free-vfx-image-sequences-flipbooks
+
Rain-gauge data: Israel Meteorological Service, meteorological data archive, data.gov.il dataset 481
(https://data.gov.il/dataset/481), licence "Other (Open)" as stated on the dataset.
diff --git a/THIRD-PARTY-NOTICES.md b/THIRD-PARTY-NOTICES.md
index 30b6cb473..847d5657d 100644
--- a/THIRD-PARTY-NOTICES.md
+++ b/THIRD-PARTY-NOTICES.md
@@ -13,6 +13,7 @@ required attribution texts are in [`NOTICE`](NOTICE).
|---|---|---|---|
| Copernicus DEM GLO-30 (derived heightmap, hex elevations) | `unity/Assets/StreamingAssets/map/`, `content/map/hexes.json` | Copernicus DEM licence | Keep the attribution text in `NOTICE` with the data and in any credits |
| CHELSA V2.1 bio12 | `content/map/precip_bio12.*` | CC0 1.0 | None; the citation in `NOTICE` is requested |
+| Unity Labs VFX flipbooks ("Free VFX image sequences and flipbooks", 2016) | `unity/Assets/Resources/Effects/` (in every build) | CC0 1.0 | None; credited "Unity Technologies (Unity Labs), CC0" as a courtesy in `NOTICE` |
| IMS rain-gauge normals (data.gov.il dataset 481) | `content/map/precip_stations.json` | "Other (Open)" (data.gov.il) | Attribution in `NOTICE`; terms under owner review (decision D6) |
| Wikipedia text and coordinates | cited throughout `content/` | CC BY-SA 4.0 | Attribution (source URL per entry); share-alike, which is why `content/` is CC BY-SA 4.0 |
| Portraits (Wikimedia Commons) | `promo/ref/people/`, `unity/Assets/UI/Portraits/` | Public domain, CC0, CC BY 4.0 or CC BY-SA 4.0, per file | Public domain and CC0: none legally. CC BY 4.0 and CC BY-SA 4.0: keep the credit (artist, licence, source) in `NOTICE`; a portrait cropped from a CC BY-SA 4.0 photograph is itself CC BY-SA 4.0. The per-file record in `ASSETS.portraits.yaml` is kept as provenance |
diff --git a/changelog.d/2482-dakota-bombs.md b/changelog.d/2482-dakota-bombs.md
new file mode 100644
index 000000000..b9ecf85f7
--- /dev/null
+++ b/changelog.d/2482-dakota-bombs.md
@@ -0,0 +1,12 @@
+### Changed
+
+- On the 15 May 1948 turn two slightly smaller Egyptian Dakotas now fly a loop together over Tel Aviv instead of one big
+ Dakota off the coast, and drop bombs that flash and smoke on Tel Aviv's hex; their propellers turn, they bank into
+ their turns and cast a shadow on the ground (#2482). Looks only: the game's numbers do not change.
+- With the Dakotas over Tel Aviv, the map's place names now hide only where an aircraft (with its flag) actually covers
+ them, not over the planes' whole loop, so most names round Tel Aviv stay visible (owner chose "Shrink the keep-clear
+ area (Recommended)", 4 November 2026).
+- The Dakotas' bombs now burst in a fireball that swells, burns out into black smoke and fades, and dark smoke columns
+ rise and lean downwind from where they hit, standing over Tel Aviv while the planes fly (owner, 4 November 2026: "the
+ explosions look bad in the screenshot and there is no smoke columns coming up"). The fire and smoke are Unity Labs'
+ free CC0 flipbooks.
diff --git a/unity/Assets/Resources/Effects.meta b/unity/Assets/Resources/Effects.meta
new file mode 100644
index 000000000..eeb704458
--- /dev/null
+++ b/unity/Assets/Resources/Effects.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: fac6c1091f6d4d718ed546465518d966
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Effects/Cloud02_8x8.png b/unity/Assets/Resources/Effects/Cloud02_8x8.png
new file mode 100644
index 000000000..e9d203e15
Binary files /dev/null and b/unity/Assets/Resources/Effects/Cloud02_8x8.png differ
diff --git a/unity/Assets/Resources/Effects/Cloud02_8x8.png.meta b/unity/Assets/Resources/Effects/Cloud02_8x8.png.meta
new file mode 100644
index 000000000..0748ef1f9
--- /dev/null
+++ b/unity/Assets/Resources/Effects/Cloud02_8x8.png.meta
@@ -0,0 +1,130 @@
+fileFormatVersion: 2
+guid: e4c201360c944793bd104b78fdba3160
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 13
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ flipGreenChannel: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ vTOnly: 0
+ ignoreMipmapLimit: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 1024
+ textureSettings:
+ serializedVersion: 2
+ filterMode: 2
+ aniso: 1
+ mipBias: 0
+ wrapU: 1
+ wrapV: 1
+ wrapW: 1
+ nPOTScale: 0
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 0
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 0
+ textureShape: 1
+ singleChannelComponent: 1
+ flipbookRows: 8
+ flipbookColumns: 8
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
+ swizzle: 50462976
+ cookieLightType: 0
+ platformSettings:
+ - serializedVersion: 4
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 1024
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 4
+ buildTarget: Standalone
+ maxTextureSize: 1024
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 4
+ buildTarget: WebGL
+ maxTextureSize: 1024
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ customData:
+ physicsShape: []
+ bones: []
+ spriteID:
+ internalID: 0
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ secondaryTextures: []
+ spriteCustomMetadata:
+ entries: []
+ nameFileIdTable: {}
+ mipmapLimitGroupName:
+ pSDRemoveMatte: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/Effects/Explosion01_5x5.png b/unity/Assets/Resources/Effects/Explosion01_5x5.png
new file mode 100644
index 000000000..63c0708e9
Binary files /dev/null and b/unity/Assets/Resources/Effects/Explosion01_5x5.png differ
diff --git a/unity/Assets/Resources/Effects/Explosion01_5x5.png.meta b/unity/Assets/Resources/Effects/Explosion01_5x5.png.meta
new file mode 100644
index 000000000..e0da7dd99
--- /dev/null
+++ b/unity/Assets/Resources/Effects/Explosion01_5x5.png.meta
@@ -0,0 +1,130 @@
+fileFormatVersion: 2
+guid: 3811283ec9a344489d2d355f7c3d36c9
+TextureImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 13
+ mipmaps:
+ mipMapMode: 0
+ enableMipMap: 1
+ sRGBTexture: 1
+ linearTexture: 0
+ fadeOut: 0
+ borderMipMap: 0
+ mipMapsPreserveCoverage: 0
+ alphaTestReferenceValue: 0.5
+ mipMapFadeDistanceStart: 1
+ mipMapFadeDistanceEnd: 3
+ bumpmap:
+ convertToNormalMap: 0
+ externalNormalMap: 0
+ heightScale: 0.25
+ normalMapFilter: 0
+ flipGreenChannel: 0
+ isReadable: 0
+ streamingMipmaps: 0
+ streamingMipmapsPriority: 0
+ vTOnly: 0
+ ignoreMipmapLimit: 0
+ grayScaleToAlpha: 0
+ generateCubemap: 6
+ cubemapConvolution: 0
+ seamlessCubemap: 0
+ textureFormat: 1
+ maxTextureSize: 1024
+ textureSettings:
+ serializedVersion: 2
+ filterMode: 2
+ aniso: 1
+ mipBias: 0
+ wrapU: 1
+ wrapV: 1
+ wrapW: 1
+ nPOTScale: 0
+ lightmap: 0
+ compressionQuality: 50
+ spriteMode: 0
+ spriteExtrude: 1
+ spriteMeshType: 1
+ alignment: 0
+ spritePivot: {x: 0.5, y: 0.5}
+ spritePixelsToUnits: 100
+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+ spriteGenerateFallbackPhysicsShape: 1
+ alphaUsage: 1
+ alphaIsTransparency: 1
+ spriteTessellationDetail: -1
+ textureType: 0
+ textureShape: 1
+ singleChannelComponent: 1
+ flipbookRows: 5
+ flipbookColumns: 5
+ maxTextureSizeSet: 0
+ compressionQualitySet: 0
+ textureFormatSet: 0
+ ignorePngGamma: 0
+ applyGammaDecoding: 0
+ swizzle: 50462976
+ cookieLightType: 0
+ platformSettings:
+ - serializedVersion: 4
+ buildTarget: DefaultTexturePlatform
+ maxTextureSize: 1024
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 4
+ buildTarget: Standalone
+ maxTextureSize: 1024
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ - serializedVersion: 4
+ buildTarget: WebGL
+ maxTextureSize: 1024
+ resizeAlgorithm: 0
+ textureFormat: -1
+ textureCompression: 1
+ compressionQuality: 50
+ crunchedCompression: 0
+ allowsAlphaSplitting: 0
+ overridden: 0
+ ignorePlatformSupport: 0
+ androidETC2FallbackOverride: 0
+ forceMaximumCompressionQuality_BC6H_BC7: 0
+ spriteSheet:
+ serializedVersion: 2
+ sprites: []
+ outline: []
+ customData:
+ physicsShape: []
+ bones: []
+ spriteID:
+ internalID: 0
+ vertices: []
+ indices:
+ edges: []
+ weights: []
+ secondaryTextures: []
+ spriteCustomMetadata:
+ entries: []
+ nameFileIdTable: {}
+ mipmapLimitGroupName:
+ pSDRemoveMatte: 0
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs b/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs
index b6cc62363..e65bad788 100644
--- a/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs
+++ b/unity/Assets/Scripts/Map/Collection/DakotaLoop.cs
@@ -1,35 +1,64 @@
#nullable enable
+using System;
+using System.Collections.Generic;
+using Statecraft.Game.Map.Units;
+using Statecraft.HexTiles;
using UnityEngine;
+using UnityEngine.Rendering;
namespace Statecraft.Game.Map.Collection
{
- /// <summary>Flies Tal Heuberger's Egyptian Dakota round its loop off Tel Aviv (SeaAirCollection.DakotaLoopOffset; owner, 2
- /// November 2026: "A slow loop over Tel Aviv on those turns, like the Spitfire's loop, with the Egyptian flag; purely
- /// visual"), level, nose along the path, Egypt's flag floating over its tail (owner on #2260, "Smaller flag, no pole").
- /// Presentation only: it reads the map's animation clock (SpitfireLoop.Clock, Time.time), sets two transforms a frame and
- /// allocates nothing. It lives on the aircraft's own object, so it stops when the layer drops the aircraft. Editor renders
- /// and screenshots (`?shot` / `-shot`) hold the loop's start, as the train and the Spitfire do (RouteLayer.ModeFor).</summary>
+ /// <summary>Flies one of Tal Heuberger's two Egyptian Dakotas round their loop over Tel Aviv (SeaAirCollection.DakotaLoopOffset;
+ /// owner, 4 November 2026, #2482: "1 + make the visual 2 slightly smaller planes and not 0ne big one", option 1: "On the
+ /// bombing turns it flies over Tel Aviv (not just off the coast) and drops bombs with flashes and smoke on the city"), its
+ /// own clock <see cref="Lag"/> behind the loop's (the wing trails the lead), nose along the path, banked into the turns
+ /// (SeaAirCollection.DakotaBankDegrees), a propeller turning at each engine, its shadow on the ground, Egypt's flag
+ /// floating over its tail (owner on #2260, "Smaller flag, no pole") and its bombs falling on Tel Aviv
+ /// (<see cref="DakotaBombRun"/>), as the Spitfire flies (SpitfireLoop; owner, before the ruling: "it also doesnt look like
+ /// its flying"). Presentation only: it reads the map's animation clock (SpitfireLoop.Clock, Time.time), sets a few
+ /// transforms a frame and allocates nothing. It lives on the aircraft's own object, so it stops when the layer drops the
+ /// aircraft. Editor renders and screenshots (`?shot` / `-shot`) hold the loop's start, as the train and the Spitfire do
+ /// (RouteLayer.ModeFor).</summary>
public sealed class DakotaLoop : MonoBehaviour
{
/// <summary>DESIGN VALUE: the gap (m) between the aircraft's box top and the flag's lower edge, as #2260's
/// SpitfireLoop.FlagClearM.</summary>
public const float FlagClearM = 150f;
- Vector3 centre, offset, half; Quaternion level; bool still; Transform? flag; float flagHalf;
+ Vector3 centre, offset, half; Quaternion level; bool still; float lag;
+ Transform[] props = Array.Empty<Transform>(); Transform? shadow, flag; Terrain? ground; Vector2 shadowHalf; float flagHalf, seaY;
+ DakotaBombRun? bombs;
/// <summary>True when the aircraft holds the loop's start (edit mode, screenshots).</summary>
public bool Still => still;
+ /// <summary>How far (s) this aircraft's clock is behind the loop's: 0 for the lead, SeaAirCollection.DakotaTrailSeconds
+ /// for its wing.</summary>
+ public float Lag => lag;
+
+ /// <summary>The loop clock's seconds where <see cref="Place"/> last put it (the labels' keep-clear box follows it,
+ /// SeaAirCollection.DakotaKeepBox).</summary>
+ public float PlacedAt { get; private set; }
+
/// <summary>The flag that floats over the tail, or null.</summary>
public Transform? Flag => flag;
+ /// <summary>The aircraft's bombs, or null.</summary>
+ internal DakotaBombRun? Bombs => bombs;
+
/// <summary><paramref name="centre"/>: the loop's centre in the air. <paramref name="level"/>: the model's rotation with
/// its nose east. <paramref name="offset"/>: its drawn centre from its pivot at that rotation. <paramref name="half"/>: half
- /// its box at that rotation (half its length, height and span).</summary>
- internal void Configure(Vector3 centre, Quaternion level, Vector3 offset, Vector3 half, Transform? flag, bool still)
+ /// its box at that rotation (half its length, height and span). <paramref name="lag"/>: its clock behind the loop's. The
+ /// propeller discs (children of its mesh), the shadow and the flag (beside it), the terrain the shadow lies on and the
+ /// shadow's half size across and along the heading, the sea's surface (world y), and its bombs.</summary>
+ internal void Configure(Vector3 centre, Quaternion level, Vector3 offset, Vector3 half, float lag, Transform[] props, Transform? shadow,
+ Transform? flag, Terrain? ground, Vector2 shadowHalf, float seaY, DakotaBombRun? bombs, bool still)
{
- this.centre = centre; this.level = level; this.offset = offset; this.half = half; this.flag = flag; this.still = still;
+ this.centre = centre; this.level = level; this.offset = offset; this.half = half; this.lag = lag; this.props = props;
+ this.shadow = shadow; this.flag = flag; this.ground = ground; this.shadowHalf = shadowHalf; this.seaY = seaY; this.bombs = bombs; this.still = still;
flagHalf = flag != null ? flag.GetComponent<MeshFilter>().sharedMesh.bounds.extents.y * flag.localScale.y : 0f;
+ var cam = Camera.main;
+ if (cam != null) bombs?.Face(cam.transform.rotation);
// Where the clock puts it now: a component added mid-frame gets no Update that frame.
Place(still ? 0f : SpitfireLoop.Clock());
}
@@ -39,18 +68,371 @@ namespace Statecraft.Game.Map.Collection
if (!still) Place(SpitfireLoop.Clock());
}
- /// <summary>Puts the aircraft where it is <paramref name="seconds"/> into its loop: its drawn centre on the path, its nose
- /// along the path's tangent; the flag over its tail, its lower edge <see cref="FlagClearM"/> over the aircraft's top.</summary>
+ void OnEnable() => RenderPipelineManager.beginCameraRendering += Face;
+ void OnDisable() => RenderPipelineManager.beginCameraRendering -= Face;
+
+ /// <summary>Turns the flashes and the smoke to the camera about to render, as UnitGunFire.Face does the gun's.</summary>
+ void Face(ScriptableRenderContext _, Camera cam)
+ {
+ if (cam.cameraType == CameraType.Preview || cam.cameraType == CameraType.Reflection) return;
+ bombs?.Face(cam.transform.rotation);
+ }
+
+ /// <summary>Puts the aircraft where it is <paramref name="seconds"/> into the loop's clock (its own, <see cref="Lag"/>
+ /// less): its drawn centre on the path, its nose along the path's tangent, rolled into the turn about that tangent; the
+ /// propellers at their angle then (by the loop's clock, so a held shot holds them); the flag over its tail, its lower edge
+ /// <see cref="FlagClearM"/> over the top of its box at this bank; the shadow where the sun's ray through it meets the
+ /// ground; and its bombs, flashes and smoke as they are then.</summary>
public void Place(float seconds)
{
- var at = SeaAirCollection.DakotaLoopOffset(seconds); var heading = SeaAirCollection.DakotaLoopHeading(seconds);
+ PlacedAt = seconds;
+ float u = seconds - lag;
+ var at = SeaAirCollection.DakotaLoopOffset(u); var heading = SeaAirCollection.DakotaLoopHeading(u);
+ var forward = new Vector3(heading.x, 0f, heading.y);
// A turn about the vertical from east (+x) to the heading; Unity's yaw turns +x toward -z.
var yaw = Quaternion.Euler(0f, -Mathf.Atan2(heading.y, heading.x) * Mathf.Rad2Deg, 0f);
- transform.localRotation = yaw * level;
+ // The loop turns left (anticlockwise seen from above): a positive turn about the heading lowers the left wing.
+ float bank = SeaAirCollection.DakotaBankDegrees(u);
+ var turn = Quaternion.AngleAxis(bank, forward) * yaw;
+ transform.localRotation = turn * level;
var drawn = centre + new Vector3(at.x, 0f, at.y);
- transform.position = drawn - yaw * offset;
- if (flag != null)
- flag.position = drawn - new Vector3(heading.x, 0f, heading.y) * half.x + Vector3.up * (half.y + FlagClearM + flagHalf);
+ transform.position = drawn - turn * offset;
+ // The angle in double, as the Spitfire's (review of #2260: a float product with the clock loses whole degrees).
+ var spin = Quaternion.AngleAxis(-(float)((double)seconds * SpitfireLoop.PropDegreesPerSecond % 360.0), Vector3.up);
+ for (int i = 0; i < props.Length; i++) props[i].localRotation = spin;
+ if (flag != null) flag.position = drawn - forward * half.x + Vector3.up * (SpitfireLoop.TopOver(half, bank) + FlagClearM + flagHalf);
+ // Cut the sun's ray to convergence: the shadow falls up the rising ground east of Tel Aviv, where the Spitfire's two
+ // fixed-point steps miss by about 200 m (SpitfireLoop.LayShadow).
+ if (shadow != null && ground != null) SpitfireLoop.LayShadow(shadow, ground, seaY, shadowHalf, drawn, forward, bank, converge: true);
+ bombs?.Sample(u);
+ }
+ }
+
+ /// <summary>One Dakota's bombs on Tel Aviv (#2482, option 1: "drops bombs with flashes and smoke on the city. Looks only; no
+ /// change to the game's numbers."): its releases (<see cref="Drops"/>, found once by SeaAirCollection.DakotaBombs: every
+ /// SeaAirCollection.DakotaBombIntervalS of the loop whose release and impact are both on Tel Aviv's hex), a small pool
+ /// of bombs, flashes, blasts and dust puffs, as many as can show at once, and its share of the smoke columns. The whole
+ /// run is a pure function of the aircraft's loop time (<see cref="Sample"/>), as UnitGunFire's shot is of its time, so a
+ /// held shot repeats exactly. A bomb falls under the aircraft's track (its horizontal speed is the aircraft's), faster as
+ /// it falls (its drop grows with the square of the time). At the impact the gun's flash (UnitGunFire.Flash, its texture,
+ /// HexMaterials.AttackGlow) marks the instant, while the blast, Unity Labs' CC0 explosion flipbook (owner, 4 November
+ /// 2026, after "the explosions look bad in the screenshot and there is no smoke columns coming up" and "it needs to look
+ /// top quality"), swells from the ground, burns out into black smoke and fades; dust puffs (the smoke flipbook, the
+ /// muzzle smoke's curves, UnitGunFire.Puff) rise and thin after it; and from the first hit on each of its column sites a
+ /// smoke column rises and leans downwind for as long as the aircraft flies (SeaAirCollection.DakotaColumns). All of it is
+ /// drawn on camera-facing quads (no lights, no particle system): a flipbook frame is a quad mesh whose UVs cover that
+ /// frame (the URP particle shaders ignore the material's tiling), made once per run. Every renderer is made once, hidden
+ /// until used, and its materials and meshes are owned by the run's object, so they go with the aircraft; sampling
+ /// allocates nothing.</summary>
+ internal sealed class DakotaBombRun
+ {
+ /// <summary>A release: <see cref="At"/> seconds into the aircraft's loop, from <see cref="From"/> (its belly) to
+ /// <see cref="To"/> (the ground).</summary>
+ internal readonly struct Drop
+ {
+ public readonly float At; public readonly Vector3 From, To;
+ public Drop(float at, Vector3 from, Vector3 to) { At = at; From = from; To = to; }
+ }
+
+ /// <summary>The run's textures: the gun's flash, the blast flipbook (<see cref="BlastGrid"/> frames each way) and the
+ /// smoke flipbook (<see cref="SmokeGrid"/> each way). A grid of 1 is a single picture.</summary>
+ internal readonly struct Looks
+ {
+ public readonly Texture2D Flash, Blast, Smoke; public readonly int BlastGrid, SmokeGrid;
+ public Looks(Texture2D flash, Texture2D blast, int blastGrid, Texture2D smoke, int smokeGrid)
+ { Flash = flash; Blast = blast; BlastGrid = blastGrid; Smoke = smoke; SmokeGrid = smokeGrid; }
+ }
+
+ static readonly int BaseColor = Shader.PropertyToID("_BaseColor"), BaseMap = Shader.PropertyToID("_BaseMap"), Cull = Shader.PropertyToID("_Cull");
+ /// <summary>DESIGN VALUES: the flash the gun's colour; the dust a dusty grey-brown (a bomb's burst raises dust and
+ /// rubble), thinning paler as it rises; the puffs drift a little east, each its own way. The blast keeps the
+ /// flipbook's own fire and smoke colours, its smoke a touch warmer (dust). The columns are dark grey-brown at the foot,
+ /// paler grey aloft, as the under-attack look's smoke (HexUnderAttackLook: 0.13 to 0.40) but browner for the burning
+ /// city's dust. The smoke flipbook's grey averages 0.44 where it is opaque (measured on its pixels), so these tints
+ /// are about twice the shade drawn: the columns run from about 0.14 to 0.38, the dust from 0.27 to 0.42.</summary>
+ static readonly Color FlashColour = new Color(1f, 0.85f, 0.5f), SmokeFresh = new Color(0.62f, 0.56f, 0.48f), SmokeThin = new Color(0.95f, 0.92f, 0.86f);
+ static readonly Color BlastTint = new Color(1f, 0.95f, 0.88f), ColumnFoot = new Color(0.32f, 0.27f, 0.22f), ColumnTop = new Color(0.86f, 0.80f, 0.72f);
+ static readonly float[] PuffSide = { -0.07f, 0.03f, 0.08f }, PuffSpin = { 20f, 140f, 260f };
+ /// <summary>DESIGN VALUE: a column puff's alpha at its densest.</summary>
+ const float ColumnAlpha = 0.95f;
+
+ readonly List<Drop> drops;
+ readonly int[] entry; // the drop at each release slot of the loop, or -1
+ readonly int slots;
+ readonly Transform[] bombT, flashT, blastT, puffT, columnT;
+ readonly Renderer[] bomb, flash, blast, puff, column;
+ readonly MeshFilter[] blastF, puffF, columnF;
+ readonly Material[] flashMat, blastMat, puffMat, columnMat;
+ readonly Mesh[] blastFrames, smokeFrames;
+ readonly Vector3[] columnAt; // each column's foot (an impact point)
+ readonly double[] columnFrom; // the loop time of its first hit
+ Quaternion view = Quaternion.identity;
+
+ /// <summary>The releases, in loop order.</summary>
+ internal IReadOnlyList<Drop> Drops => drops;
+ /// <summary>The pool's renderers (tests): the bombs, the flashes, the blasts, the dust puffs and the column puffs
+ /// (<see cref="ColumnSites"/> x SeaAirCollection.DakotaColumnPuffs, column by column).</summary>
+ internal IReadOnlyList<Renderer> Bombs => bomb;
+ internal IReadOnlyList<Renderer> Flashes => flash;
+ internal IReadOnlyList<Renderer> Blasts => blast;
+ internal IReadOnlyList<Renderer> Smoke => puff;
+ internal IReadOnlyList<Renderer> Columns => column;
+ /// <summary>Each of this aircraft's columns' foot and the loop time (s) of its first hit (tests).</summary>
+ internal IReadOnlyList<Vector3> ColumnSites => columnAt;
+ internal double ColumnFrom(int c) => columnFrom[c];
+ /// <summary>The flipbook frame a blast or column renderer shows (tests): the index of its frame mesh.</summary>
+ internal int BlastFrame(int s) => Array.IndexOf(blastFrames, blastF[s].sharedMesh);
+ internal int ColumnFrame(int i) => Array.IndexOf(smokeFrames, columnF[i].sharedMesh);
+ /// <summary>A pool renderer's own material colour now (tests).</summary>
+ internal static Color Colour(Renderer r) => r.sharedMaterial.GetColor(BaseColor);
+
+ /// <summary>The run of <paramref name="drops"/> among the loop's <paramref name="releases"/> release slots, drawn under
+ /// <paramref name="parent"/>: the bombs with <paramref name="bombMesh"/> and <paramref name="bombMaterial"/> (shared), the
+ /// flashes, blasts, puffs and columns with <paramref name="looks"/> (shared) on materials of their own, owned by
+ /// <paramref name="parent"/>. Aircraft <paramref name="plane"/> of <paramref name="planes"/> takes every
+ /// <paramref name="planes"/>-th of the pair's evenly spaced column sites, starting at its own index.</summary>
+ internal DakotaBombRun(Transform parent, List<Drop> drops, int releases, Mesh bombMesh, Material bombMaterial, Looks looks, int plane, int planes)
+ {
+ this.drops = drops;
+ entry = new int[releases];
+ for (int i = 0; i < releases; i++) entry[i] = -1;
+ for (int k = 0; k < drops.Count; k++) entry[Mathf.RoundToInt(drops[k].At / SeaAirCollection.DakotaBombIntervalS) % releases] = k;
+ // Every release whose bomb, flash, blast or dust can still show: its fall, then the longer of the blast and the
+ // last puff's start and life.
+ float life = SeaAirCollection.DakotaBombFallS + Mathf.Max(SeaAirCollection.DakotaBlastS,
+ (SeaAirCollection.DakotaPuffs - 1) * SeaAirCollection.DakotaPuffGapS + SeaAirCollection.DakotaSmokeS);
+ slots = Mathf.CeilToInt(life / SeaAirCollection.DakotaBombIntervalS) + 1;
+ var owned = parent.GetComponent<MapRuntimeAssets>(); // not ??: a missing component is Unity's fake null in the editor
+ if (owned == null) owned = parent.gameObject.AddComponent<MapRuntimeAssets>();
+ var quad = Resources.GetBuiltinResource<Mesh>("Quad.fbx");
+ blastFrames = Frames(owned, looks.BlastGrid); smokeFrames = Frames(owned, looks.SmokeGrid);
+ Material Mat(string template, Texture2D texture)
+ {
+ var m = owned.Own(HexMaterials.New(template)); m.SetTexture(BaseMap, texture); m.SetFloat(Cull, (float)CullMode.Off); return m;
+ }
+ bombT = new Transform[slots]; bomb = new Renderer[slots]; flashT = new Transform[slots]; flash = new Renderer[slots]; flashMat = new Material[slots];
+ blastT = new Transform[slots]; blast = new Renderer[slots]; blastF = new MeshFilter[slots]; blastMat = new Material[slots];
+ int puffs = slots * SeaAirCollection.DakotaPuffs;
+ puffT = new Transform[puffs]; puff = new Renderer[puffs]; puffF = new MeshFilter[puffs]; puffMat = new Material[puffs];
+ for (int s = 0; s < slots; s++)
+ {
+ (bombT[s], bomb[s], _) = Part(parent, "Bomb", bombMesh, bombMaterial);
+ bombT[s].localScale = SeaAirCollection.DakotaBombLengthM * Vector3.one;
+ var fm = flashMat[s] = owned.Own(HexMaterials.New(HexMaterials.AttackGlow)); fm.SetTexture(BaseMap, looks.Flash);
+ (flashT[s], flash[s], _) = Part(parent, "BombFlash", quad, fm);
+ // The blast is unlit and alpha-blended (the border's material): its fire glows by its own colours, its smoke
+ // stays dark, where an additive glow would wash out over the light sand.
+ (blastT[s], blast[s], blastF[s]) = Part(parent, "BombBlast", blastFrames[0], blastMat[s] = Mat(HexMaterials.AttackBorder, looks.Blast));
+ for (int p = 0; p < SeaAirCollection.DakotaPuffs; p++)
+ {
+ int i = s * SeaAirCollection.DakotaPuffs + p;
+ (puffT[i], puff[i], puffF[i]) = Part(parent, "BombSmoke", smokeFrames[0], puffMat[i] = Mat(HexMaterials.AttackSmoke, looks.Smoke));
+ }
+ }
+ (columnAt, columnFrom) = ColumnSitesOf(drops, releases * SeaAirCollection.DakotaBombIntervalS, plane, planes);
+ int n = columnAt.Length * SeaAirCollection.DakotaColumnPuffs;
+ columnT = new Transform[n]; column = new Renderer[n]; columnF = new MeshFilter[n]; columnMat = new Material[n];
+ for (int i = 0; i < n; i++) (columnT[i], column[i], columnF[i]) = Part(parent, "BombColumn", smokeFrames[0], columnMat[i] = Mat(HexMaterials.AttackSmoke, looks.Smoke));
+ }
+
+ /// <summary>Aircraft <paramref name="plane"/>'s column sites among <paramref name="drops"/> on a loop of
+ /// <paramref name="period"/> seconds: the impacts in the order of the pass over Tel Aviv (each impact's time put in the
+ /// half loop either side of the loop's start, where the pass is), the pair's SeaAirCollection.DakotaColumns x
+ /// <paramref name="planes"/> (or every impact, if fewer) evenly spaced along it, and of those every
+ /// <paramref name="planes"/>-th from <paramref name="plane"/>. Each site's first hit is its impact's time in that
+ /// pass (negative for the impacts before the loop's start: an editor shot, held at the start, shows those columns rising).</summary>
+ static (Vector3[] at, double[] from) ColumnSitesOf(List<Drop> drops, float period, int plane, int planes)
+ {
+ int n = drops.Count;
+ var hit = new double[n]; var order = new int[n];
+ for (int k = 0; k < n; k++)
+ {
+ double t = drops[k].At + SeaAirCollection.DakotaBombFallS;
+ hit[k] = t - period * Math.Floor(t / period + 0.5); order[k] = k;
+ }
+ Array.Sort(order, (a, b) => hit[a].CompareTo(hit[b]));
+ int total = Mathf.Min(SeaAirCollection.DakotaColumns * planes, n);
+ var at = new List<Vector3>(); var from = new List<double>();
+ for (int i = plane; i < total; i += planes)
+ {
+ int k = order[total == 1 ? 0 : Mathf.RoundToInt(i * (n - 1f) / (total - 1f))];
+ at.Add(drops[k].To); from.Add(hit[k]);
+ }
+ return (at.ToArray(), from.ToArray());
+ }
+
+ /// <summary>One quad mesh per frame of a <paramref name="grid"/> x <paramref name="grid"/> flipbook, its UVs on that
+ /// frame (frame 0 top left, then along the rows, as Unity's texture sheet animation), facing -z as the built-in quad,
+ /// white (the particle shaders multiply the vertex colour).</summary>
+ static Mesh[] Frames(MapRuntimeAssets owned, int grid)
+ {
+ var frames = new Mesh[grid * grid];
+ float k = 1f / grid;
+ var v = new[] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f), new Vector3(0.5f, 0.5f, 0f) };
+ var normals = new[] { Vector3.back, Vector3.back, Vector3.back, Vector3.back };
+ var white = new Color32[] { new Color32(255, 255, 255, 255), new Color32(255, 255, 255, 255), new Color32(255, 255, 255, 255), new Color32(255, 255, 255, 255) };
+ var tris = new[] { 0, 3, 1, 3, 0, 2 };
+ for (int f = 0; f < frames.Length; f++)
+ {
+ float u0 = (f % grid) * k, v0 = 1f - (f / grid + 1) * k;
+ var uv = new[] { new Vector2(u0, v0), new Vector2(u0 + k, v0), new Vector2(u0, v0 + k), new Vector2(u0 + k, v0 + k) };
+ var m = new Mesh { name = $"dakota-frame-{grid}x{grid}-{f}", vertices = v, normals = normals, colors32 = white, uv = uv, triangles = tris };
+ m.RecalculateBounds();
+ frames[f] = owned.Own(m);
+ }
+ return frames;
+ }
+
+ static (Transform, Renderer, MeshFilter) Part(Transform parent, string name, Mesh mesh, Material material)
+ {
+ var go = new GameObject(name, typeof(MeshFilter), typeof(MeshRenderer));
+ go.transform.SetParent(parent, false);
+ var filter = go.GetComponent<MeshFilter>(); filter.sharedMesh = mesh;
+ var r = go.GetComponent<MeshRenderer>();
+ r.sharedMaterial = material; r.enabled = false;
+ r.shadowCastingMode = ShadowCastingMode.Off; r.receiveShadows = false;
+ r.lightProbeUsage = LightProbeUsage.Off; r.reflectionProbeUsage = ReflectionProbeUsage.Off;
+ return (go.transform, r, filter);
+ }
+
+ static int Mod(int a, int n) { int m = a % n; return m < 0 ? m + n : m; }
+
+ /// <summary>A pseudo-random share in [0, 1) for <paramref name="seed"/>, as HexUnderAttackLook's per-puff seed.</summary>
+ static float Own(float seed) => HexUnderAttack.Frac(Mathf.Sin(seed * 12.9898f) * 43758.547f);
+
+ /// <summary>DESIGN VALUE: a column puff's turn (degrees) for its share <paramref name="own"/>: within 25 degrees either
+ /// way, so the flipbook's sunlit side stays roughly up.</summary>
+ static float Spin(float own) => (own - 0.5f) * 50f;
+
+ /// <summary>The run as it is <paramref name="u"/> seconds into the aircraft's loop: each slot shows the latest release that
+ /// maps to it (release j at j x the interval, the loop's slot j mod its releases), if that slot drops a bomb; each
+ /// column as it is that long after its first hit. The same time gives the same frame. No allocation.</summary>
+ internal void Sample(float u)
+ {
+ float every = SeaAirCollection.DakotaBombIntervalS;
+ int newest = (int)Math.Floor((double)u / every);
+ for (int k = 0; k < slots; k++)
+ {
+ int j = newest - k;
+ int d = entry[Mod(j, entry.Length)];
+ Show(Mod(j, slots), d < 0 ? (Drop?)null : drops[d], (float)((double)u - (double)j * every));
+ }
+ for (int c = 0; c < columnAt.Length; c++) ShowColumn(c, (double)u - columnFrom[c]);
+ }
+
+ void Show(int s, Drop? drop, float age)
+ {
+ float fall = SeaAirCollection.DakotaBombFallS, after = age - fall;
+ bool falling = drop.HasValue && age >= 0f && age < fall;
+ bomb[s].enabled = falling;
+ if (falling)
+ {
+ var d = drop!.Value; float f = age / fall, drop2 = d.From.y - d.To.y;
+ var at = Vector3.Lerp(d.From, d.To, f); at.y = d.From.y - drop2 * f * f;
+ var velocity = new Vector3((d.To.x - d.From.x) / fall, -2f * drop2 * f / fall, (d.To.z - d.From.z) / fall);
+ bombT[s].SetPositionAndRotation(at, Quaternion.FromToRotation(Vector3.up, velocity));
+ }
+ bool flashing = drop.HasValue && after >= 0f && after < SeaAirCollection.DakotaFlashS;
+ flash[s].enabled = flashing;
+ if (flashing)
+ {
+ var d = drop!.Value;
+ float grow = 0.7f + 0.3f * Mathf.Clamp01(after / (0.25f * SeaAirCollection.DakotaFlashS));
+ flashT[s].SetPositionAndRotation(d.To + Vector3.up * (0.3f * SeaAirCollection.DakotaFlashM), view * Quaternion.Euler(0f, 0f, 37f));
+ flashT[s].localScale = Vector3.one * (SeaAirCollection.DakotaFlashM * grow);
+ var c = FlashColour; c.a = UnitGunFire.Flash(after * UnitGunFire.FlashS / SeaAirCollection.DakotaFlashS); flashMat[s].SetColor(BaseColor, c);
+ }
+ bool blasting = drop.HasValue && after >= 0f && after < SeaAirCollection.DakotaBlastS;
+ blast[s].enabled = blasting;
+ if (blasting)
+ {
+ float b = after / SeaAirCollection.DakotaBlastS;
+ blastF[s].sharedMesh = blastFrames[Mathf.Min((int)(b * blastFrames.Length), blastFrames.Length - 1)];
+ float size = SeaAirCollection.DakotaBlastM * BlastSwell(b);
+ // Its foot on the ground: the flipbook's cloud fills about the middle four fifths of its frame.
+ blastT[s].SetPositionAndRotation(drop!.Value.To + Vector3.up * (0.4f * size), view);
+ blastT[s].localScale = Vector3.one * size;
+ var c = BlastTint; c.a = BlastAlpha(b); blastMat[s].SetColor(BaseColor, c);
+ }
+ for (int p = 0; p < SeaAirCollection.DakotaPuffs; p++)
+ {
+ int i = s * SeaAirCollection.DakotaPuffs + p;
+ float v = (after - p * SeaAirCollection.DakotaPuffGapS) / SeaAirCollection.DakotaSmokeS;
+ bool on = drop.HasValue && v > 0f && v < 1f;
+ puff[i].enabled = on;
+ if (!on) continue;
+ UnitGunFire.Puff(v, out _, out float rise, out float radius, out float alpha);
+ float size = SeaAirCollection.DakotaSmokeM;
+ puffF[i].sharedMesh = smokeFrames[Mathf.Min((int)(v * smokeFrames.Length), smokeFrames.Length - 1)];
+ puffT[i].SetPositionAndRotation(drop!.Value.To + Vector3.up * (rise * size) + Vector3.right * (PuffSide[p] * v * size),
+ view * Quaternion.Euler(0f, 0f, PuffSpin[p]));
+ puffT[i].localScale = Vector3.one * (2.6f * radius * size);
+ var c = Color.Lerp(SmokeFresh, SmokeThin, v); c.a = alpha; puffMat[i].SetColor(BaseColor, c);
+ }
+ }
+
+ /// <summary>The blast's size over SeaAirCollection.DakotaBlastM at <paramref name="b"/> of its life: from
+ /// SeaAirCollection.DakotaBlastOpenShare, swelling fast (easing out) to the full size by a quarter of its life, then
+ /// spreading a little more as its smoke drifts.</summary>
+ internal static float BlastSwell(float b)
+ {
+ float open = 1f - Mathf.Clamp01(b / 0.25f);
+ return Mathf.Lerp(SeaAirCollection.DakotaBlastOpenShare, 1f, 1f - open * open) + 0.12f * Mathf.Clamp01((b - 0.25f) / 0.75f);
+ }
+
+ /// <summary>The blast's alpha at <paramref name="b"/> of its life: whole, then fading over the last
+ /// SeaAirCollection.DakotaBlastFadeShare of it to nothing at its end.</summary>
+ internal static float BlastAlpha(float b)
+ {
+ float fade = SeaAirCollection.DakotaBlastFadeShare;
+ return 1f - Mathf.SmoothStep(0f, 1f, (b - (1f - fade)) / fade);
+ }
+
+ /// <summary>Column <paramref name="c"/>, <paramref name="age"/> seconds after its first hit (hidden before it): a stream
+ /// of SeaAirCollection.DakotaColumnPuffs puffs, each born every SeaAirCollection.DakotaColumnLifeS, a puff's share of
+ /// a life apart, and only those born since the first hit, so the column grows from the ground over its first life and
+ /// then stands. A puff rises SeaAirCollection.DakotaColumnM over its life, widening from the column's foot to its top
+ /// width, leaning downwind, darkest and densest low, thinning paler aloft, its smoke boiling through the flipbook.</summary>
+ void ShowColumn(int c, double age)
+ {
+ int P = SeaAirCollection.DakotaColumnPuffs;
+ float life = SeaAirCollection.DakotaColumnLifeS;
+ for (int i = 0; i < P; i++)
+ {
+ int k = c * P + i;
+ double lives = age / life - (double)i / P;
+ float v = (float)(lives - Math.Floor(lives));
+ bool on = age >= 0.0 && v * life <= age;
+ column[k].enabled = on;
+ if (!on) continue;
+ float own = Own(c * 7.31f + i * 1.93f + 0.5f);
+ float size = Mathf.Lerp(SeaAirCollection.DakotaColumnFootM, SeaAirCollection.DakotaColumnTopM, Mathf.Sqrt(v)) * (0.85f + 0.3f * own);
+ var wobble = new Vector3(Mathf.Sin(own * 19f + v * 5f), 0f, Mathf.Cos(own * 13f + v * 4f)) * (60f * Mathf.Sqrt(v));
+ // Its centre 0.45 of its size up: tilted to the board camera (50 degrees down), its lower edge stays over the ground.
+ var at = columnAt[c] + Vector3.up * (0.45f * size + v * SeaAirCollection.DakotaColumnM)
+ + HexUnderAttack.Smoke.Wind * (SeaAirCollection.DakotaColumnLeanM * Mathf.Pow(v, 1.4f)) + wobble;
+ float spin = Spin(own);
+ columnT[k].SetPositionAndRotation(at, view * Quaternion.Euler(0f, 0f, spin));
+ columnT[k].localScale = Vector3.one * size;
+ int frames = smokeFrames.Length;
+ columnF[k].sharedMesh = smokeFrames[Mod((int)Math.Floor(((double)v * life * SeaAirCollection.DakotaColumnFps) + own * frames), frames)];
+ var colour = Color.Lerp(ColumnFoot, ColumnTop, Mathf.SmoothStep(0f, 1f, v / 0.8f));
+ colour.a = ColumnAlpha * Mathf.SmoothStep(0f, 1f, v / 0.06f) * (1f - Mathf.SmoothStep(0f, 1f, (v - 0.6f) / 0.4f));
+ columnMat[k].SetColor(BaseColor, colour);
+ }
+ }
+
+ /// <summary>Turns the flashes, blasts and puffs showing to a camera with rotation <paramref name="camera"/>, and keeps it
+ /// for the next samples (edit mode and shots face the main camera from the start).</summary>
+ internal void Face(Quaternion camera)
+ {
+ view = camera;
+ for (int s = 0; s < flash.Length; s++) if (flash[s].enabled) flashT[s].rotation = view * Quaternion.Euler(0f, 0f, 37f);
+ for (int s = 0; s < blast.Length; s++) if (blast[s].enabled) blastT[s].rotation = view;
+ for (int i = 0; i < puff.Length; i++) if (puff[i].enabled) puffT[i].rotation = view * Quaternion.Euler(0f, 0f, PuffSpin[i % SeaAirCollection.DakotaPuffs]);
+ int P = SeaAirCollection.DakotaColumnPuffs;
+ for (int i = 0; i < column.Length; i++)
+ if (column[i].enabled) columnT[i].rotation = view * Quaternion.Euler(0f, 0f, Spin(Own(i / P * 7.31f + i % P * 1.93f + 0.5f)));
}
}
}
diff --git a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs
index c3256f978..1b0b2ab4b 100644
--- a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs
+++ b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.Dakota.cs
@@ -2,186 +2,415 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Statecraft.Game.Map.Kits;
using Statecraft.Game.Map.Units;
using UnityEngine;
using UnityEngine.Rendering;
namespace Statecraft.Game.Map.Collection
{
- /// <summary>Tal Heuberger's Egyptian Dakota C-47 (owner, 2 November 2026, "Over Tel Aviv, 15 May-11 Jun (Recommended)": "A
- /// slow loop over Tel Aviv on those turns, like the Spitfire's loop, with the Egyptian flag; purely visual"; on #2274, "Off the coast is fine (Recommended)": its loop is just off the city, over the sea). It follows the
- /// Spitfire's path in this layer: the far mesh streamed after the first frame, drawn in flight at the unit tokens' aircraft
- /// scale and altitude, never on a hex or an airfield, with Egypt's flag as the owner ruled for the Spitfire on #2260
- /// ("Smaller flag, no pole": a small flag floating over the tail).</summary>
+ /// <summary>Tal Heuberger's Egyptian Dakota C-47, two of them, bombing Tel Aviv on the turns of the first bombing period. The
+ /// owner, 2 November 2026, "Over Tel Aviv, 15 May-11 Jun (Recommended)": "A slow loop over Tel Aviv on those turns, like the
+ /// Spitfire's loop, with the Egyptian flag; purely visual"; on #2274, "Off the coast is fine (Recommended)", so #2274 drew one
+ /// Dakota looping just off the city, over the sea. On #2482 (4 November 2026), asked how far the bombing should go, the owner
+ /// chose option 1 and added: "1 + make the visual 2 slightly smaller planes and not 0ne big one". Option 1 read: "On the
+ /// bombing turns it flies over Tel Aviv (not just off the coast) and drops bombs with flashes and smoke on the city. Looks
+ /// only; no change to the game's numbers." Before that the owner said: "we need the egyptian dakota to bomb tel aviv. it
+ /// also doesnt look like its flying". So the 2 November off-the-coast placement gives way: two Dakotas, each
+ /// <see cref="DakotaScale"/> of #2274's size, fly one loop as a pair, its pass in from the sea over Tel Aviv's hex, dropping
+ /// bombs that flash and smoke on that hex only; and they fly as the Spitfire does (#2260): turning propellers, here on both
+ /// engines, a bank into their turns (<see cref="SeaAirCollection.BankFor"/>), a shadow on the ground and Egypt's flag over
+ /// each tail (owner on #2260, "Smaller flag, no pole"). Never on a hex or an airfield: in flight at the unit tokens' aircraft
+ /// scale and altitude, the far mesh streamed after the first frame. Presentation only: no sim, content or hash change.</summary>
public sealed partial class SeaAirCollection
{
- /// <summary>The Dakota's object key.</summary>
+ /// <summary>The Dakotas' object keys are made from this.</summary>
public const string DakotaKey = "tel-aviv-dakota";
- /// <summary>The first Egyptian bombing period over Tel Aviv: "תקופת ההפצצות הראשונה נמשכה מ-15 במאי ועד כניסת ההפוגה
- /// הראשונה לתוקפה ב-11 ביוני. שיטת התקיפה המצרית הייתה בדרך כלל גיחה של שני מטוסי הפצצה, בדרך כלל מטוסי דקוטה" (he.wiki
- /// "הפצצת תל אביב במלחמת העצמאות", revision 43856594; agent-read 2 November 2026, a person's check pending; the paragraph
- /// has no footnote of its own). On 3 June 1948 two Egyptian C-47s that bombed Tel Aviv were shot down (en.wiki "Modi
- /// Alon", revision 1375428559; he.wiki "מודי אלון", revision 43744773; both agent-read 2 November 2026). On the game's
- /// monthly turns (the 15th) it shows on the 15 May 1948 turn only.</summary>
+ /// <summary>The two Dakotas' keys, the lead first, then its wing, which trails it round the loop
+ /// (<see cref="DakotaTrailSeconds"/>). Two, for the owner's "2 slightly smaller planes" (#2482) and the sourced sortie of
+ /// two bombers (<see cref="DakotaFrom"/>).</summary>
+ public static readonly string[] DakotaKeys = { DakotaKey + "-lead", DakotaKey + "-wing" };
+
+ /// <summary>The first Egyptian bombing period over Tel Aviv, he.wiki "הפצצת תל אביב במלחמת העצמאות", revision 43856594,
+ /// section "תקופת ההפצצות הראשונה", two paragraphs, neither with a footnote of its own: "תקופת ההפצצות הראשונה נמשכה
+ /// מ-15 במאי ועד כניסת ההפוגה הראשונה לתוקפה ב-11 ביוני." and "שיטת התקיפה המצרית הייתה בדרך כלל גיחה של שני מטוסי
+ /// הפצצה, בדרך כלל מטוסי דקוטה, שלוו במטוס קרב אחד או שניים מדגם ספיטפייר." (agent-read 2 November 2026 and re-read 4
+ /// November 2026, still the current revision; a person's check pending). The same article: "ב-3 ביוני אחר הצהריים פגעו
+ /// הפצצות המצריות בכיכר מסריק" and Modi Alon shot down "שני מטוסי דקוטה מצרים ששימשו כמפציצים". he.wiki "מודי אלון",
+ /// revision 43744773, calls them "זוג מטוסי DC-3 דקוטה מצריים"; en.wiki "Modi Alon", revision 1375428559, "a pair of
+ /// Egyptian C-47s and their two Spitfire escorts" (all agent-read 4 November 2026). On the game's monthly turns (the
+ /// 15th) the Dakotas show on the 15 May 1948 turn only.</summary>
public static readonly DateTime DakotaFrom = new DateTime(1948, 5, 15), DakotaTo = new DateTime(1948, 6, 11);
/// <summary>The C-47's wingspan, 95 ft 6 in (29.11 m): en.wiki "Douglas C-47 Skytrain", Specifications (C-47B-DK),
/// revision 1383378030, agent-read 2 November 2026. At the unit tokens' aircraft scale (420x, as the Spitfire, #2014)
- /// it is 12.2 km across.</summary>
+ /// it is 12.2 km across; each of the two is drawn at <see cref="DakotaScale"/> of that.</summary>
public const float DakotaSpanM = 95.5f * FootM;
- /// <summary>The settlement it loops by: Tel Aviv's row in content/map/settlements_1948.yaml.</summary>
+ /// <summary>DESIGN VALUE: each Dakota's size over #2274's one (the unit tokens' aircraft scale): the owner's "2 slightly
+ /// smaller planes and not 0ne big one" (#2482). 0.8 makes each 9.8 km across, still more than twice the Spitfire's 4.7 km.</summary>
+ public const float DakotaScale = 0.8f;
+
+ /// <summary>The settlement they bomb: Tel Aviv's row in content/map/settlements_1948.yaml, and its hex in
+ /// content/map/settlement_hexes.yaml.</summary>
public const string DakotaTown = "tel_aviv";
- /// <summary>DESIGN VALUES: the Dakota's loop, the Spitfire's ellipse (<see cref="SpitfireLoopHalfLengthM"/> by
- /// <see cref="SpitfireLoopHalfWidthM"/>, "like the Spitfire's loop"), flown once every 60 s, half again the Spitfire's
- /// period: a slower aircraft, about 430 m/s of map. In east along its southern side, then anticlockwise, as the
- /// Spitfire's.</summary>
- public const float DakotaLoopSeconds = 60f;
+ /// <summary>DESIGN VALUES: the Dakotas' loop is the Spitfire's ellipse ("like the Spitfire's loop", 2 November) at
+ /// <see cref="DakotaLoopScale"/> times its size, 15 km each way east-west and 9 km each way north-south, flown once every
+ /// <see cref="DakotaLoopSeconds"/>, about 640 m/s of map, the Spitfire's own speed. #2274's one Dakota flew the
+ /// Spitfire's own 10 by 6 km loop, smaller than the aircraft itself; two 9.8 km aircraft on one track need room to fly it
+ /// apart (<see cref="DakotaTrailSeconds"/>). The unit tokens' own aircraft fly a 16 km radius (UnitShowcase.LoopRadiusM),
+ /// so this is their size of loop. In east along its southern side, then anticlockwise, as the Spitfire's.</summary>
+ public const float DakotaLoopScale = 3f, DakotaLoopSeconds = 120f;
+ public const float DakotaLoopHalfLengthM = DakotaLoopScale * SpitfireLoopHalfLengthM, DakotaLoopHalfWidthM = DakotaLoopScale * SpitfireLoopHalfWidthM;
- /// <summary>DESIGN VALUE: how far apart (m) the candidate loop centres are, in rings round Tel Aviv and in bearings of 10
- /// degrees, nearest first (<see cref="DakotaSpot"/>).</summary>
- public const float DakotaSearchStepM = 1000f;
- const int DakotaSearchRings = 90, DakotaSearchBearings = 36;
+ /// <summary>DESIGN VALUE: the wing trails the lead by this share of the loop (26.4 s), on the same track. Seen from above,
+ /// every point of a Dakota lies within <see cref="DakotaReachShare"/> of its span of its centre, so two never meet while
+ /// their centres are more than 2 x 0.54 x 9.8 = 10.6 km apart; at 0.22 of the loop the closest they come, in the turns at
+ /// the ends, is 11.5 km (sampled along this ellipse), and on the passes they fly about 15 km apart, the wing's nose 7 km
+ /// behind the lead's tail: close enough to read as a pair, never across the loop from each other.</summary>
+ public const float DakotaTrailShare = 0.22f, DakotaTrailSeconds = DakotaTrailShare * DakotaLoopSeconds;
+
+ /// <summary>DESIGN VALUE, from the model's FBX vertices (generated-1948-16-egyptian-dakota-c47-compatibility.fbx, read 4
+ /// November 2026): seen from above, the farthest points from the model's middle are its wingtips, at 0.53 of its span.</summary>
+ public const float DakotaReachShare = 0.54f;
/// <summary>DESIGN VALUE: the flag's size over the tokens' flag size, as #2260's SpitfireFlagScale (0.5).</summary>
public const float DakotaFlagScale = 0.5f;
- /// <summary>The flag object beside the aircraft (it does not turn with it): the aircraft's key and this.</summary>
- public const string DakotaMarksSuffix = "-marks", DakotaFlagName = "Flag";
+ /// <summary>The object beside each aircraft (it neither banks nor turns with it) that holds its flag, its shadow and its
+ /// bombs: the aircraft's key and this. The propeller discs, children of the aircraft's mesh.</summary>
+ public const string DakotaMarksSuffix = "-marks", DakotaFlagName = "Flag", DakotaShadowName = SpitfireShadowName, DakotaPropellerName = SpitfirePropellerName;
+
+ /// <summary>DESIGN VALUES for the two propeller discs on the fused mesh, from the model's FBX vertices (read 4 November
+ /// 2026; the mesh's -y is its nose, +z up, x across): the fuselage's nose is the front-most point, on the centre line;
+ /// each engine nacelle's front (its spinner) stands 0.131 of the length behind it, its vertices centred 0.128 of the span
+ /// either side of the centre line and 0.40 of the height up, and its still blades reach about 0.06 of the span round it
+ /// (the nacelle's front vertices run 0.07 to 0.20 of the span out). Each disc's centre stands
+ /// <see cref="DakotaPropBehindNoseShare"/> of the length behind the front, just behind its spinner over the blades' roots,
+ /// <see cref="DakotaPropRadiusShare"/> of the span in radius, inside the airframe's box at every angle.</summary>
+ public const float DakotaEngineAcrossShare = 0.128f, DakotaPropBehindNoseShare = 0.145f, DakotaPropUpShare = 0.40f, DakotaPropRadiusShare = 0.06f;
+
+ /// <summary>DESIGN VALUES for the bombs (option 1: "drops bombs with flashes and smoke on the city"). Each Dakota releases
+ /// one every <see cref="DakotaBombIntervalS"/> of its loop while over Tel Aviv's hex, where it also lands on that hex at
+ /// least <see cref="DakotaBombMarginM"/> inside its edge (so the smoke's drift stays on it); each falls for
+ /// <see cref="DakotaBombFallS"/> (a real fall from 4,200 m takes about 29 s: shortened, as the map's speeds are), under
+ /// the aircraft's track, faster as it falls. The interval divides the loop, so the same releases repeat every loop.</summary>
+ public const float DakotaBombIntervalS = 1f, DakotaBombFallS = 2f, DakotaBombMarginM = 600f;
+
+ /// <summary>DESIGN VALUES for the impact, sized to read at the gameplay zoom beside a 9.8 km aircraft and a 4.4 km hex: a
+ /// flash <see cref="DakotaFlashM"/> across for <see cref="DakotaFlashS"/>, then <see cref="DakotaPuffs"/> puffs of smoke
+ /// <see cref="DakotaPuffGapS"/> apart, each rising and thinning for <see cref="DakotaSmokeS"/>, the muzzle smoke's curves
+ /// (UnitGunFire.Flash, UnitGunFire.Puff) at <see cref="DakotaSmokeM"/> for the gun's length. A bomb is a dark spindle
+ /// <see cref="DakotaBombLengthM"/> long.</summary>
+ public const float DakotaFlashS = 0.5f, DakotaFlashM = 1500f, DakotaSmokeS = 4f, DakotaPuffGapS = 0.25f, DakotaSmokeM = 1600f, DakotaBombLengthM = 400f;
+ public const int DakotaPuffs = 3;
+
+ /// <summary>DESIGN VALUES for the blast (owner, 4 November 2026, on the 15 May captures: "the explosions look bad in
+ /// the screenshot and there is no smoke columns coming up", then "it needs to look top quality"): Unity Labs' CC0
+ /// explosion flipbook (<see cref="DakotaBlastTexture"/>, 5 x 5 frames: a fireball that burns out into black smoke) on a
+ /// camera-facing quad, played once over <see cref="DakotaBlastS"/> from the impact. It opens at
+ /// <see cref="DakotaBlastOpenShare"/> of <see cref="DakotaBlastM"/> across and swells to the full size in the first
+ /// quarter of its life, its foot on the ground; it fades over the last <see cref="DakotaBlastFadeShare"/> of it. The
+ /// gun's flash (<see cref="DakotaFlashM"/>) still marks the first instant.</summary>
+ public const float DakotaBlastS = 2.4f, DakotaBlastM = 2200f, DakotaBlastOpenShare = 0.45f, DakotaBlastFadeShare = 0.35f;
+ public const int DakotaBlastGrid = 5;
- /// <summary>Where the Dakota is from its loop's centre (world x, z, m), <paramref name="seconds"/> into its loop: at 0 due
- /// south of the centre flying east, then anticlockwise seen from above.</summary>
+ /// <summary>DESIGN VALUES for the smoke columns (owner, 4 November 2026: "there is no smoke columns coming up"): each
+ /// Dakota lights <see cref="DakotaColumns"/> columns, at evenly spaced impacts of its pass (the lead and its wing take
+ /// turns, so the pair lights at most 2 x <see cref="DakotaColumns"/> over Tel Aviv). From its first hit a column is a
+ /// stream of <see cref="DakotaColumnPuffs"/> puffs of Unity Labs' CC0 smoke flipbook (<see cref="DakotaSmokeTexture"/>,
+ /// 8 x 8 frames, boiling at <see cref="DakotaColumnFps"/>), each rising <see cref="DakotaColumnM"/> over
+ /// <see cref="DakotaColumnLifeS"/>, widening from <see cref="DakotaColumnFootM"/> to <see cref="DakotaColumnTopM"/>
+ /// across and leaning <see cref="DakotaColumnLeanM"/> downwind (east, a little north, as the under-attack look's smoke,
+ /// HexUnderAttack.Smoke.Wind), less than <see cref="DakotaBombMarginM"/>, so a column stays over Tel Aviv's hex. It
+ /// grows from the ground over its first <see cref="DakotaColumnLifeS"/> and then burns for as long as the Dakotas fly.</summary>
+ public const int DakotaColumns = 3, DakotaColumnPuffs = 10, DakotaSmokeGrid = 8;
+ public const float DakotaColumnLifeS = 14f, DakotaColumnM = 3600f, DakotaColumnFootM = 700f, DakotaColumnTopM = 2300f,
+ DakotaColumnLeanM = 450f, DakotaColumnFps = 6f;
+
+ /// <summary>The two Unity Labs flipbooks (Resources, "Free VFX image sequences and flipbooks", CC0; ASSETS.yaml).</summary>
+ public const string DakotaBlastTexture = "Effects/Explosion01_5x5", DakotaSmokeTexture = "Effects/Cloud02_8x8";
+
+ /// <summary>Where a Dakota is from its loop's centre (world x, z, m), <paramref name="seconds"/> into its loop: at 0 due
+ /// south of the centre flying east (over Tel Aviv, <see cref="DakotaSpot"/>), then anticlockwise seen from above.</summary>
public static Vector2 DakotaLoopOffset(float seconds)
{
float a = DakotaLoopAngle(seconds);
- return new Vector2(SpitfireLoopHalfLengthM * Mathf.Sin(a), -SpitfireLoopHalfWidthM * Mathf.Cos(a));
+ return new Vector2(DakotaLoopHalfLengthM * Mathf.Sin(a), -DakotaLoopHalfWidthM * Mathf.Cos(a));
}
- /// <summary>The Dakota's direction of travel there (world x, z; unit length): the loop's tangent.</summary>
+ /// <summary>A Dakota's direction of travel there (world x, z; unit length): the loop's tangent.</summary>
public static Vector2 DakotaLoopHeading(float seconds)
{
float a = DakotaLoopAngle(seconds);
- return new Vector2(SpitfireLoopHalfLengthM * Mathf.Cos(a), SpitfireLoopHalfWidthM * Mathf.Sin(a)).normalized;
+ return new Vector2(DakotaLoopHalfLengthM * Mathf.Cos(a), DakotaLoopHalfWidthM * Mathf.Sin(a)).normalized;
}
static float DakotaLoopAngle(float seconds) => 2f * Mathf.PI * Mathf.Repeat(seconds, DakotaLoopSeconds) / DakotaLoopSeconds;
- /// <summary>The Dakota's farthest point from its centre, seen from above, at any heading: half the diagonal of a square
- /// as wide as its wingspan (its fuselage is shorter than its span).</summary>
+ /// <summary>The loop's curvature (1/m) <paramref name="seconds"/> into it, as <see cref="LoopCurvature"/> for this ellipse.</summary>
+ public static float DakotaLoopCurvature(float seconds)
+ {
+ float t = DakotaLoopAngle(seconds), a = DakotaLoopHalfLengthM, b = DakotaLoopHalfWidthM;
+ float c = Mathf.Cos(t), s = Mathf.Sin(t);
+ return a * b / Mathf.Pow(a * a * c * c + b * b * s * s, 1.5f);
+ }
+
+ /// <summary>A Dakota's bank <paramref name="seconds"/> into its loop (degrees, its inner wing down; #2482 "a bank into their
+ /// turns"): <see cref="BankFor"/> the curvature at the Spitfire's scale. The loop is the Spitfire's shape at
+ /// <see cref="DakotaLoopScale"/>, so its curvature there is the Spitfire's over that scale, and this is the Spitfire's own
+ /// bank at the same point of its loop: level on the passes (the bomb run among them), the tokens' 28 degrees at the ends.</summary>
+ public static float DakotaBankDegrees(float seconds) => BankFor(DakotaLoopScale * DakotaLoopCurvature(seconds));
+
+ /// <summary>A Dakota's farthest point from its centre, seen from above, at any heading, on the safe side for the board:
+ /// half the diagonal of a square as wide as its wingspan.</summary>
public static float DakotaReach => 0.5f * Mathf.Sqrt(2f) * SizeOf(Dakota);
- /// <summary>Half the box (world x, z, m) the Dakota flies through about its loop's centre: the loop and its reach.</summary>
- public static Vector2 DakotaSweptHalf => new Vector2(SpitfireLoopHalfLengthM + DakotaReach, SpitfireLoopHalfWidthM + DakotaReach);
-
- /// <summary>The Dakota's loop centre (on the ground, world x, z): the nearest to Tel Aviv whose whole swept box
- /// (<see cref="DakotaSweptHalf"/>) is over the board and clear of every unit token present in its window (their rings
- /// and town clearings), every settlement's and town's kit footprint, and every map label's point (the settlements, the
- /// 1948 localities and the map locations), so it hides no token and no name. Over the city itself it cannot be: Kiryati's
- /// token stands on Tel Aviv from 15 May 1948 (content/map/units_1948.yaml), and at 420x the aircraft is 12 km across.
- /// Rings of <see cref="DakotaSearchStepM"/> round Tel Aviv, nearest first, each from due west (the sea) turning both ways.
- /// On the map that is 22 km due west of Tel Aviv's point, over the sea; the owner reviewed it on #2274 (2 November 2026):
- /// "Off the coast is fine (Recommended)". Null when none is clear.</summary>
+ /// <summary>Half the box (world x, z, m) the Dakotas fly through about their loop's centre: the loop and their reach.</summary>
+ public static Vector2 DakotaSweptHalf => new Vector2(DakotaLoopHalfLengthM + DakotaReach, DakotaLoopHalfWidthM + DakotaReach);
+
+ /// <summary>The Dakotas' loop centre (on the ground, world x, z): <see cref="DakotaLoopHalfWidthM"/> due north of Tel Aviv's
+ /// hex centre, so the loop's southern pass, flown level and due east in from the sea, crosses the middle of Tel Aviv's
+ /// hex at the loop's start (#2482, option 1: "it flies over Tel Aviv (not just off the coast)"); edit mode and shots hold
+ /// the lead there. #2274 searched instead for the nearest centre whose whole loop cleared every unit token, kit and map
+ /// name, which put it 22 km out to sea (owner on #2274, 2 November 2026: "Off the coast is fine (Recommended)"); over the
+ /// city no loop can clear Kiryati's token on Tel Aviv (content/map/units_1948.yaml), so those ground clearances go. The
+ /// clearance of the aircraft at altitude stays: the map names keep clear of each aircraft where it is now
+ /// (<see cref="FlyDakota"/>, <see cref="DakotaKeepBox"/>; owner, 4 November 2026, on #2490, "Shrink the keep-clear area
+ /// (Recommended)", where they had kept clear of its whole loop as of the Spitfire's), and the whole loop is over the board. Null when Tel Aviv has no hex
+ /// or the loop would leave the board.</summary>
internal static Vector2? DakotaSpot(MapScene map, Statecraft.Sim.Content? content)
{
- var town = map.Settlements.FirstOrDefault(s => s.Id == DakotaTown);
- if (town == null) return null;
- var w = map.Frame.ToWorld(town.Lon, town.Lat, 0); var origin = new Vector2(w.x, w.z);
var ground = PlacementLayer.CampGround(map);
+ var targets = DakotaTargets(ground, content);
+ if (targets.Count == 0) return null;
+ var c = targets[0] - DakotaLoopOffset(0f);
var half = DakotaSweptHalf;
- var discs = new List<(Vector2 centre, float radius)>();
- foreach (var kv in map.UnitSpots)
- {
- if (UnitData.Day(kv.Key.From) > DakotaTo || UnitData.Day(kv.Key.To) <= DakotaFrom) continue;
- var c = new Vector2((float)kv.Value.X, (float)kv.Value.Z);
- discs.Add((c, TokenRadius(map, c, kv.Value.InTown)));
- }
- foreach (var (c, r, _) in map.KitFootprints) discs.Add((c, r));
- var points = new List<Vector2>();
- void Point(double lon, double lat) { var p = map.Frame.ToWorld(lon, lat, 0); points.Add(new Vector2(p.x, p.z)); }
- foreach (var s in map.Settlements) Point(s.Lon, s.Lat);
- foreach (var l in map.Localities) Point(l.Settlement.Lon, l.Settlement.Lat);
- if (content != null) foreach (var l in content.MapLocations) Point(l.Lon, l.Lat);
- bool Free(Vector2 c)
- {
- if (!ground.Inside(c.x - half.x, c.y - half.y) || !ground.Inside(c.x + half.x, c.y + half.y)) return false;
- foreach (var p in points) if (Mathf.Abs(p.x - c.x) <= half.x && Mathf.Abs(p.y - c.y) <= half.y) return false;
- foreach (var (d, r) in discs)
- {
- float dx = Mathf.Max(Mathf.Abs(d.x - c.x) - half.x, 0f), dz = Mathf.Max(Mathf.Abs(d.y - c.y) - half.y, 0f);
- if (dx * dx + dz * dz <= r * r) return false;
- }
- return true;
- }
- for (int k = 0; k <= DakotaSearchRings; k++)
- for (int i = 0; i < (k == 0 ? 1 : DakotaSearchBearings); i++)
+ return ground.Inside(c.x - half.x, c.y - half.y) && ground.Inside(c.x + half.x, c.y + half.y) ? c : (Vector2?)null;
+ }
+
+ /// <summary>The centres (world x, z) of Tel Aviv's hexes (content/map/settlement_hexes.yaml), on the hex grid the board
+ /// draws (HexGrid, as KitGround reads it).</summary>
+ internal static List<Vector2> DakotaTargets(KitGround ground, Statecraft.Sim.Content? content)
+ {
+ var list = new List<Vector2>();
+ if (content == null) return list;
+ foreach (var h in content.SettlementHexes)
+ if (h.Id == DakotaTown)
{
- int step = (i + 1) / 2 * (i % 2 == 1 ? 1 : -1); // 0, +1, -1, +2, -2 ... bearings from due west
- float a = Mathf.PI + 2f * Mathf.PI * step / DakotaSearchBearings;
- var c = origin + new Vector2(Mathf.Cos(a), Mathf.Sin(a)) * (k * DakotaSearchStepM);
- if (Free(c)) return c;
+ var w = HexGrid.ToWorld(HexGrid.Centre(h.Q, h.R, ground.HexSizeM), ground.TerrainOrigin, ground.Length);
+ list.Add(new Vector2(w.x, w.z));
}
- return null;
+ return list;
}
- /// <summary>The ring (out of town) or clearing (in a town) a unit token holds at <paramref name="c"/>, as MapScene placed
- /// it; the largest of either when none matches.</summary>
- static float TokenRadius(MapScene map, Vector2 c, bool inTown)
+ /// <summary>True when <paramref name="p"/> (world x, z) is on one of <paramref name="targets"/>' hexes, at least
+ /// <see cref="DakotaBombMarginM"/> inside its edge.</summary>
+ internal static bool OnDakotaTarget(KitGround ground, List<Vector2> targets, Vector2 p)
{
- if (inTown) { foreach (var (k, r) in map.UnitClearings) if ((k - c).sqrMagnitude < 1f) return r; }
- else foreach (var (k, r, _) in map.UnitTokens) if ((k - c).sqrMagnitude < 1f) return r;
- float most = 0f;
- foreach (var (_, r) in map.UnitClearings) most = Mathf.Max(most, r);
- foreach (var (_, r, _) in map.UnitTokens) most = Mathf.Max(most, r);
- return most;
+ var g = HexGrid.FromWorld(new Vector3(p.x, 0f, p.y), ground.TerrainOrigin, ground.Length);
+ if (HexGrid.EdgeDistance(g, ground.HexSizeM) < DakotaBombMarginM) return false;
+ var w = HexGrid.ToWorld(HexGrid.NearestCentre(g, ground.HexSizeM), ground.TerrainOrigin, ground.Length);
+ foreach (var t in targets) if ((new Vector2(w.x, w.z) - t).sqrMagnitude < 1f) return true;
+ return false;
}
bool dakotaSearched; Vector2? dakotaCentre;
- /// <summary><see cref="DakotaSpot"/> for this map, found once (the map's tokens and labels do not move).</summary>
+ /// <summary><see cref="DakotaSpot"/> for this map, found once the content is known (the map's hexes do not move).</summary>
Vector2? DakotaCentre()
{
- if (!dakotaSearched && map != null) { dakotaSearched = true; dakotaCentre = DakotaSpot(map, content); }
+ if (!dakotaSearched && map != null && content != null) { dakotaSearched = true; dakotaCentre = DakotaSpot(map, content); }
return dakotaCentre;
}
- /// <summary>The Dakota in level flight round its loop about <paramref name="at"/> (<see cref="DakotaLoop"/>), wingspan at
- /// its map size, UnitShowcase.AltitudeM (4,200 m) above the highest ground under its loop, as the Spitfire (#2014). Its
- /// model's nose is its mesh's -y, as the Spitfire's (the FBX's wings lie forward of its middle, its tailplane at +y), so
- /// the same yaw points it east. Egypt's flag floats over its tail. The labels keep clear of the whole box it and its flag
- /// fly through.</summary>
- void FlyDakota(GameObject go, GameObject prefab, Vector2 at)
+ /// <summary>Dakota number <paramref name="plane"/> (0 the lead, 1 its wing, <see cref="DakotaKeys"/>) in flight round the
+ /// loop about <paramref name="at"/> (<see cref="DakotaLoop"/>), the wing <see cref="DakotaTrailSeconds"/> behind, wingspan
+ /// at its map size, UnitShowcase.AltitudeM (4,200 m) above the highest ground under the loop, as the Spitfire (#2014).
+ /// Its model's nose is its mesh's -y, as the Spitfire's, so the same yaw points it east. Beside it, in its marks object
+ /// (they go with it when its dates end): Egypt's flag over its tail, its shadow and its bombs. A turning disc at each
+ /// engine. The labels keep clear of the box it and its flag fill now, banked or not (<see cref="DakotaKeepBox"/>), not of its
+ /// whole loop (owner, 4 November 2026, on #2490: "Shrink the keep-clear area (Recommended)").</summary>
+ void FlyDakota(GameObject go, GameObject prefab, Vector2 at, KitGround ground, int plane)
{
var level = Quaternion.Euler(0f, SpitfireNoseEastYaw, 0f) * prefab.transform.localRotation;
go.transform.localRotation = level;
- var b = Bounds(go); float span = b.size.z;
- go.transform.localScale *= span > 1e-3f ? SizeOf(Dakota) / span : 1f;
- var centre = new Vector3(at.x, UnitShowcase.LoopFloor(map!, new Vector3(at.x, 0f, at.y), SpitfireLoopHalfLengthM + SizeOf(Dakota))
+ var b = Bounds(go); float span = b.size.z, size = SizeOf(Dakota);
+ go.transform.localScale *= span > 1e-3f ? size / span : 1f;
+ var centre = new Vector3(at.x, UnitShowcase.LoopFloor(map!, new Vector3(at.x, 0f, at.y), DakotaLoopHalfLengthM + size)
+ UnitShowcase.AltitudeM, at.y);
go.transform.position = centre; b = Bounds(go);
foreach (var r in go.GetComponentsInChildren<Renderer>(true)) r.shadowCastingMode = ShadowCastingMode.On;
- // The flag stands beside the aircraft in this layer, so it does not turn with it, and goes with it (its model's
- // originals) when its dates end.
var marks = new GameObject(go.name + DakotaMarksSuffix);
marks.transform.SetParent(transform, false);
originals[Dakota].Add(marks);
var flag = DakotaFlag(marks.transform);
var half = 0.5f * b.size; // nose east: half its length (x), its height and its span (z)
- go.AddComponent<DakotaLoop>().Configure(centre, level, b.center - go.transform.position, half, flag,
- !Application.isPlaying || VisualShots.Requested());
+ var props = DakotaPropellers(go);
+ var bombs = DakotaBombs(marks.transform, centre, half, ground, plane);
+ var loop = go.AddComponent<DakotaLoop>();
+ loop.Configure(centre, level, b.center - go.transform.position, half, plane * DakotaTrailSeconds, props, Shadow(marks.transform), flag,
+ map!.Terrain, 0.5f * ShadowShare * new Vector2(size, b.size.x), ground.SeaLevelY, bombs, !Application.isPlaying || VisualShots.Requested());
var cam = Camera.main;
if (flag != null && cam != null) UnitFlagFacing.Face(flag, cam.transform.position);
Placed.Add((go.name, Dakota, centre));
- float reach = 0.5f * new Vector2(b.size.x, b.size.z).magnitude + 1f, up = half.y + 1f;
+ // At any heading and bank the aircraft lies within half its box's diagonal of its centre; the flag floats over its
+ // tail, at most the steepest bank's box top over the centre (SpitfireLoop.TopOver), as the Spitfire's (Fly).
+ float reach = 0.5f * b.size.magnitude + 1f, up = reach, round = reach;
if (flag != null)
{
var f = flag.GetComponent<MeshFilter>().sharedMesh.bounds; float k = flag.lossyScale.y;
- up = Mathf.Max(up, half.y + DakotaLoop.FlagClearM + 2f * f.extents.y * k + 1f);
+ up = Mathf.Max(up, SpitfireLoop.TopOver(half, UnitShowcase.BankDegrees) + DakotaLoop.FlagClearM + 2f * f.extents.y * k + 1f);
+ round = Mathf.Max(round, half.x + new Vector2(f.extents.x, f.extents.z).magnitude * k + 1f);
+ }
+ // The labels keep clear of where it is now, not of its whole loop (owner, 4 November 2026, on #2490: "Shrink the
+ // keep-clear area (Recommended)"): its box follows it a DakotaKeepStepS step of the loop at a time (FollowDakotas).
+ var follow = new DakotaKeep(go, loop, centre, reach, up, round);
+ dakotaKeeps.Add(follow);
+ follow.Step = DakotaKeepStep(loop.PlacedAt);
+ Keep(go, DakotaKeepBox(centre, loop.Lag, follow.Step, reach, up, round));
+ }
+
+ /// <summary>DESIGN VALUE: the labels' keep-clear box for a Dakota covers its flight over one step of this many seconds of
+ /// the loop's clock (about 650 m of map at its speed, against a 9.8 km aircraft), and moves on a step at a time: the
+ /// labels re-place themselves at most once a step while the Dakotas fly, not every frame.</summary>
+ public const float DakotaKeepStepS = 1f;
+
+ /// <summary>The step of the loop's clock that <paramref name="seconds"/> falls in (<see cref="DakotaKeepStepS"/>).</summary>
+ internal static long DakotaKeepStep(float seconds) => (long)Math.Floor((double)seconds / DakotaKeepStepS);
+
+ /// <summary>The box (world) the map names keep clear of for a Dakota whose loop is centred at <paramref name="centre"/> (in
+ /// the air), its clock <paramref name="lag"/> behind the loop's, through the loop's clock step <paramref name="step"/>
+ /// (<see cref="DakotaKeepStepS"/>): the aircraft at every heading and bank (<paramref name="reach"/> round its drawn
+ /// centre, <paramref name="round"/> across with its flag over the tail, <paramref name="up"/> above with its flag) at
+ /// every point of its path in that step, sampled finely enough that the path's bow between samples (under a metre on
+ /// this ellipse) is inside the pad. Owner, 4 November 2026, on #2490: "Shrink the keep-clear area (Recommended)": a name
+ /// hides only where an aircraft and its flag are, not over the whole loop as #2274's box did.</summary>
+ internal static Bounds DakotaKeepBox(Vector3 centre, float lag, long step, float reach, float up, float round)
+ {
+ const int Samples = 4; const float Pad = 10f;
+ var box = new Bounds();
+ for (int i = 0; i <= Samples; i++)
+ {
+ var o = DakotaLoopOffset((float)(step * (double)DakotaKeepStepS + i * (double)DakotaKeepStepS / Samples - lag));
+ var at = centre + new Vector3(o.x, 0f, o.y);
+ var b = new Bounds(); b.SetMinMax(at - new Vector3(round, reach, round), at + new Vector3(round, up, round));
+ if (i == 0) box = b; else box.Encapsulate(b);
+ }
+ box.Expand(2f * Pad);
+ return box;
+ }
+
+ /// <summary>A drawn Dakota whose keep-clear box follows it: its loop, its loop's centre in the air, the box's sizes
+ /// (<see cref="DakotaKeepBox"/>) and the clock step its box now covers.</summary>
+ sealed class DakotaKeep
+ {
+ public readonly GameObject Go; public readonly DakotaLoop Loop; public readonly Vector3 Centre; public readonly float Reach, Up, Round;
+ public long Step;
+ public DakotaKeep(GameObject go, DakotaLoop loop, Vector3 centre, float reach, float up, float round)
+ { Go = go; Loop = loop; Centre = centre; Reach = reach; Up = up; Round = round; }
+ }
+ readonly List<DakotaKeep> dakotaKeeps = new List<DakotaKeep>();
+
+ /// <summary>Moves each drawn Dakota's keep-clear box to the clock step where its loop last placed it
+ /// (DakotaLoop.PlacedAt); when one moves, <see cref="KeepClear"/> becomes a new list, so the labels re-place themselves
+ /// (MapLabelsPresenter re-reads a list only when it is a new one). A held loop (edit mode, shots) never moves. Cheap: a
+ /// comparison an aircraft a call, and a box and a list once a step.</summary>
+ void FollowDakotas()
+ {
+ bool moved = false;
+ for (int i = 0; i < dakotaKeeps.Count; i++)
+ {
+ var d = dakotaKeeps[i];
+ if (d.Go == null || d.Loop == null || !keepOf.ContainsKey(d.Go)) continue;
+ long step = DakotaKeepStep(d.Loop.PlacedAt);
+ if (step == d.Step) continue;
+ d.Step = step;
+ keepOf[d.Go] = new[] { DakotaKeepBox(d.Centre, d.Loop.Lag, step, d.Reach, d.Up, d.Round) };
+ moved = true;
+ }
+ if (moved) RebuildKeepAll();
+ }
+
+ /// <summary>The turning propellers on both engines (#2482: "turning propellers on both engines"; the model is one fused
+ /// mesh, so it cannot turn its own): a disc as the Spitfire's (<see cref="Propeller"/>: the same blur and mesh, made once
+ /// for the layer) at each nacelle's front (<see cref="DakotaEngineAcrossShare"/>, <see cref="DakotaPropBehindNoseShare"/>,
+ /// <see cref="DakotaPropUpShare"/>, <see cref="DakotaPropRadiusShare"/>), a child of the aircraft's mesh, turned by
+ /// DakotaLoop about the mesh's y, the flight axis. Each disc's renderer bounds are the square inside its circle, so its
+ /// box stays inside the airframe's at every angle.</summary>
+ Transform[] DakotaPropellers(GameObject go)
+ {
+ var airframe = go.GetComponentInChildren<MeshFilter>();
+ var mesh = airframe.sharedMesh.bounds;
+ float radius = DakotaPropRadiusShare * mesh.size.x;
+ var discs = new Transform[2];
+ for (int i = 0; i < 2; i++)
+ {
+ var disc = new GameObject(DakotaPropellerName);
+ disc.transform.SetParent(airframe.transform, false);
+ disc.transform.localPosition = new Vector3(mesh.center.x + (i == 0 ? -1f : 1f) * DakotaEngineAcrossShare * mesh.size.x,
+ mesh.min.y + DakotaPropBehindNoseShare * mesh.size.y, mesh.min.z + DakotaPropUpShare * mesh.size.z);
+ disc.transform.localScale = Vector3.one * radius;
+ disc.AddComponent<MeshFilter>().sharedMesh = propMesh != null ? propMesh : propMesh = Own(PropellerDisc());
+ var r = disc.AddComponent<MeshRenderer>();
+ r.sharedMaterial = Blur(); r.shadowCastingMode = ShadowCastingMode.Off; r.receiveShadows = false;
+ r.localBounds = new Bounds(Vector3.zero, new Vector3(Mathf.Sqrt(2f), 2f * PropLayer, Mathf.Sqrt(2f)));
+ discs[i] = disc.transform;
+ }
+ return discs;
+ }
+
+ /// <summary>The bomb run of a Dakota whose loop is centred at <paramref name="centre"/> (in the air) and whose half box is
+ /// <paramref name="half"/>: every <see cref="DakotaBombIntervalS"/> of the loop whose release point (the ground under the
+ /// aircraft) and impact point (the ground under it <see cref="DakotaBombFallS"/> later) are both on Tel Aviv's hex
+ /// (<see cref="OnDakotaTarget"/>), a bomb from its belly. Its bombs, flashes and smoke are drawn under
+ /// <paramref name="parent"/> (DakotaBombRun); the flash and puff textures and the bomb mesh are made once for the layer.</summary>
+ DakotaBombRun DakotaBombs(Transform parent, Vector3 centre, Vector3 half, KitGround ground, int plane)
+ {
+ var targets = DakotaTargets(ground, content);
+ var drops = new List<DakotaBombRun.Drop>();
+ int n = Mathf.RoundToInt(DakotaLoopSeconds / DakotaBombIntervalS);
+ var c = new Vector2(centre.x, centre.z);
+ for (int j = 0; j < n; j++)
+ {
+ float at = j * DakotaBombIntervalS;
+ Vector2 from = c + DakotaLoopOffset(at), to = c + DakotaLoopOffset(at + DakotaBombFallS);
+ if (!OnDakotaTarget(ground, targets, from) || !OnDakotaTarget(ground, targets, to)) continue;
+ drops.Add(new DakotaBombRun.Drop(at, new Vector3(from.x, centre.y - half.y, from.y), new Vector3(to.x, ground.Y(to.x, to.y), to.y)));
+ }
+ if (flashTexture == null) flashTexture = Own(UnitGunFire.FlashTexture());
+ if (puffTexture == null) puffTexture = Own(Statecraft.HexTiles.HexUnderAttackLook.PuffTexture());
+ if (bombMesh == null) bombMesh = Own(BombMesh());
+ // The flipbooks are assets (not owned: Resources keeps them); without them the blast and smoke fall back to the
+ // drawn flash and puff, one frame each.
+ var blast = Resources.Load<Texture2D>(DakotaBlastTexture); var smoke = Resources.Load<Texture2D>(DakotaSmokeTexture);
+ if (blast == null || smoke == null) Debug.LogWarning("SEA/AIR: the Dakotas' explosion or smoke flipbook is missing from Resources/Effects; drawn textures stand in.");
+ var looks = new DakotaBombRun.Looks(flashTexture, blast != null ? blast : flashTexture, blast != null ? DakotaBlastGrid : 1,
+ smoke != null ? smoke : puffTexture, smoke != null ? DakotaSmokeGrid : 1);
+ return new DakotaBombRun(parent, drops, n, bombMesh, Blur(), looks, plane, DakotaKeys.Length);
+ }
+
+ Texture2D? flashTexture, puffTexture; Mesh? bombMesh;
+
+ /// <summary>DESIGN VALUES: a bomb, a dark olive-grey spindle (two cones base to base, six sides), one unit long along y and
+ /// a third of that across, coloured by its vertices for the propeller's blur material (<see cref="Blur"/>).</summary>
+ static Mesh BombMesh()
+ {
+ const int Sides = 6; const float R = 1f / 6f;
+ var v = new Vector3[Sides + 2]; var col = new Color32[v.Length]; var tris = new int[Sides * 6];
+ v[0] = new Vector3(0f, 0.5f, 0f); v[1] = new Vector3(0f, -0.5f, 0f);
+ for (int i = 0; i < Sides; i++) { float a = 2f * Mathf.PI * i / Sides; v[2 + i] = new Vector3(Mathf.Cos(a) * R, 0.1f, Mathf.Sin(a) * R); }
+ for (int i = 0; i < v.Length; i++) col[i] = new Color(0.12f, 0.12f, 0.10f, 1f);
+ for (int i = 0; i < Sides; i++)
+ {
+ int a = 2 + i, b = 2 + (i + 1) % Sides;
+ tris[i * 6] = 0; tris[i * 6 + 1] = b; tris[i * 6 + 2] = a;
+ tris[i * 6 + 3] = 1; tris[i * 6 + 4] = a; tris[i * 6 + 5] = b;
}
- var keep = new Bounds();
- keep.SetMinMax(centre - new Vector3(SpitfireLoopHalfLengthM + reach, half.y + 1f, SpitfireLoopHalfWidthM + reach),
- centre + new Vector3(SpitfireLoopHalfLengthM + reach, up, SpitfireLoopHalfWidthM + reach));
- Keep(go, keep);
+ var mesh = new Mesh { name = "DakotaBomb", vertices = v, colors32 = col, triangles = tris };
+ mesh.RecalculateBounds();
+ return UnitPlinth.Upload(mesh);
}
/// <summary>Egypt's flag as the owner ruled for the Spitfire on #2260 (2 November 2026, "Smaller flag, no pole"): the cloth
diff --git a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs
index ed866ca2a..8fd690e35 100644
--- a/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs
+++ b/unity/Assets/Scripts/Map/Collection/SeaAirCollection.cs
@@ -22,15 +22,16 @@ namespace Statecraft.Game.Map.Collection
/// <item>the Egyptian Spitfire flying a slow loop near the western board edge (about 30 km in) toward el-Arish and back (<see cref="SpitfireLoop"/>),
/// banked into its turns, its propeller turning, its shadow on the ground and a small Egyptian flag over its tail, from 15 May 1948 to 2 January 1949
/// (<see cref="SpitfireFrom"/>, <see cref="SpitfireTo"/>, #1932), never on a hex or an airfield;</item>
- /// <item>the Egyptian Dakota flying a slow loop just off Tel Aviv with Egypt's flag over its tail (<see cref="DakotaLoop"/>)
- /// on the turns of the first bombing period, 15 May to 11 June 1948 (<see cref="DakotaFrom"/>, <see cref="DakotaTo"/>;
- /// SeaAirCollection.Dakota.cs).</item>
+ /// <item>two Egyptian Dakotas, a pair on one loop over Tel Aviv, bombing the city (<see cref="DakotaLoop"/>; owner, 4
+ /// November 2026, #2482: "1 + make the visual 2 slightly smaller planes and not 0ne big one"), banked into their turns,
+ /// their propellers turning, their shadows on the ground and Egypt's flag over each tail, on the turns of the first
+ /// bombing period, 15 May to 11 June 1948 (<see cref="DakotaFrom"/>, <see cref="DakotaTo"/>; SeaAirCollection.Dakota.cs).</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), except the Spitfire at the unit tokens'
- /// aircraft scale (420x, #2014). The C-54 stands on the nearest free ground by the airport, clear of the kits,
+ /// aircraft scale (420x, #2014) and the Dakotas a little under it (<see cref="DakotaScale"/>, #2482). 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
@@ -89,9 +90,11 @@ namespace Statecraft.Game.Map.Collection
/// <summary>The model's long side on the map (m): its real size at the one world scale of every Tal Heuberger 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. The one exception is the
- /// Spitfire, drawn at the unit tokens' aircraft scale (UnitShowcase.AircraftScale, 420x: 4.7 km across), so it reads at strategic zoom (owner ruling, #2014).</summary>
+ /// Spitfire, drawn at the unit tokens' aircraft scale (UnitShowcase.AircraftScale, 420x: 4.7 km across), so it reads at strategic zoom (owner ruling, #2014),
+ /// and the Dakotas, each <see cref="DakotaScale"/> of that (owner, #2482: "2 slightly smaller planes and not 0ne big one").</summary>
public static float SizeOf(string model) =>
- RealLengthM(model) * (model == Spitfire || model == Dakota ? Statecraft.Game.Map.Units.UnitShowcase.AircraftScale : SettlementKits.ModelScale);
+ RealLengthM(model) * (model == Spitfire ? Statecraft.Game.Map.Units.UnitShowcase.AircraftScale
+ : model == Dakota ? Statecraft.Game.Map.Units.UnitShowcase.AircraftScale * DakotaScale : 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
@@ -126,7 +129,7 @@ namespace Statecraft.Game.Map.Collection
wants.Add(new Want("tel-aviv-altalena", Altalena, "tel_aviv"));
if (date >= C54From && date <= C54To) wants.Add(new Want("lod-c54", C54, "lod"));
if (date >= SpitfireFrom && date <= SpitfireTo) wants.Add(new Want("el-arish-spitfire", Spitfire, "el_arish"));
- if (date >= DakotaFrom && date <= DakotaTo) wants.Add(new Want(DakotaKey, Dakota, "tel_aviv"));
+ if (date >= DakotaFrom && date <= DakotaTo) foreach (var key in DakotaKeys) wants.Add(new Want(key, Dakota, DakotaTown));
return wants;
}
@@ -280,9 +283,9 @@ namespace Statecraft.Game.Map.Collection
for (int i = 0; i < wants.Count; i++)
{
var w = wants[i];
- if (w.Model == Dakota) // its anchor is on the ground under its loop's centre; only its distance counts
+ if (w.Model == Dakota) // its anchor is on the ground under its loop's centre, as far out as it flies (#2482)
{
- if (DakotaCentre() is Vector2 d) anchors.Add((w.Key, new Vector3(d.x, 0f, d.y), SizeOf(Dakota)));
+ if (DakotaCentre() is Vector2 d) anchors.Add((w.Key, new Vector3(d.x, 0f, d.y), DakotaSweptHalf.magnitude));
continue;
}
var c = default((string place, double lon, double lat, Vector2 seaward, int boats));
@@ -325,7 +328,7 @@ namespace Statecraft.Game.Map.Collection
}
// Each drawn craft's own keep-clear boxes (the Spitfire's cover its whole loop, its flag included); the Spitfire's
// shadow and flag object has none.
- keepAll = originals.Values.SelectMany(list => list).Where(go => go != null && keepOf.ContainsKey(go)).Select(go => keepOf[go]).ToList();
+ RebuildKeepAll();
return removed;
}
IReadOnlyList<UnityEngine.Object> ClearForRetirement()
@@ -341,7 +344,7 @@ namespace Statecraft.Game.Map.Collection
var old = transform.GetChild(i).gameObject; if (residencyView != null) retired.Add(old);
if (Application.isPlaying) { if (gameObject.activeInHierarchy) old.transform.SetParent(null); Destroy(old); } else DestroyImmediate(old);
}
- Placed.Clear(); Missing.Clear(); keepAll = new List<Bounds[]>(); keepOf.Clear();
+ Placed.Clear(); Missing.Clear(); keepAll = new List<Bounds[]>(); keepOf.Clear(); dakotaKeeps.Clear();
originals.Clear();
if (map != null) Statecraft.Game.Map.Units.UnitShowcase.HideTrees(map, Name, Array.Empty<(Vector2, float)>());
}
@@ -378,8 +381,20 @@ namespace Statecraft.Game.Map.Collection
/// <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;
+ /// labels re-read it only when it changes. The Dakotas' boxes follow them round their loop (FollowDakotas, #2490), so
+ /// while they fly it is a new list once a step (DakotaKeepStepS).</summary>
+ public IReadOnlyList<Bounds[]> KeepClear
+ {
+ get
+ {
+ if (!isActiveAndEnabled) return Array.Empty<Bounds[]>();
+ FollowDakotas();
+ return keepAll;
+ }
+ }
+ /// <summary>A new <see cref="KeepClear"/> list from every drawn craft's own boxes.</summary>
+ void RebuildKeepAll() =>
+ keepAll = originals.Values.SelectMany(list => list).Where(go => go != null && keepOf.ContainsKey(go)).Select(go => keepOf[go]).ToList();
List<Bounds[]> keepAll = new List<Bounds[]>();
readonly Dictionary<GameObject, Bounds[]> keepOf = new Dictionary<GameObject, Bounds[]>();
void Keep(GameObject go, Bounds box) { var boxes = new[] { box }; keepAll.Add(boxes); keepOf[go] = boxes; }
@@ -440,7 +455,7 @@ namespace Statecraft.Game.Map.Collection
if (!originals.TryGetValue(w.Model, out var owned)) originals[w.Model] = owned = new List<GameObject>();
owned.Add(go);
if (w.Model == Spitfire) { Fly(go, prefab!, at.Value, ground); continue; }
- if (w.Model == Dakota) { FlyDakota(go, prefab!, at.Value); continue; }
+ if (w.Model == Dakota) { FlyDakota(go, prefab!, at.Value, ground, Array.IndexOf(DakotaKeys, w.Key)); continue; }
// 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;
diff --git a/unity/Assets/Scripts/Map/Collection/SpitfireLoop.cs b/unity/Assets/Scripts/Map/Collection/SpitfireLoop.cs
index 37023c557..a4ffee398 100644
--- a/unity/Assets/Scripts/Map/Collection/SpitfireLoop.cs
+++ b/unity/Assets/Scripts/Map/Collection/SpitfireLoop.cs
@@ -109,34 +109,81 @@ namespace Statecraft.Game.Map.Collection
// The flag over the tail, its lower edge FlagClearM over the top of the aircraft's box at this bank: clear of the
// airframe at every bank and heading.
if (flag != null) flag.position = drawn - forward * half.x + Vector3.up * (TopOver(half, bank) + FlagClearM + flagHalf * flag.lossyScale.y);
- if (shadow != null && ground != null) PlaceShadow(drawn, forward, bank);
+ if (shadow != null && ground != null) LayShadow(shadow, ground, seaY, shadowHalf, drawn, forward, bank);
}
- /// <summary>The scene sun's ray from <paramref name="drawn"/> to the ground (or the sea's surface), found in two steps (the ground's height where the
- /// ray lands sets how far it travels); the disc flat, turned with the heading, narrowed across by the bank, lifted over
- /// the highest ground under its middle and its four ends.</summary>
- void PlaceShadow(Vector3 drawn, Vector3 forward, float bank)
+ /// <summary>Lays <paramref name="shadow"/> (half <paramref name="shadowHalf"/> across and along the heading) for an
+ /// aircraft drawn at <paramref name="drawn"/>, heading <paramref name="forward"/>, banked <paramref name="bank"/> degrees,
+ /// on <paramref name="ground"/> or the sea's surface <paramref name="seaY"/>: the scene sun's ray from the aircraft to the
+ /// ground (by default in two steps, the ground's height where the ray lands setting how far it travels); the disc flat, turned
+ /// with the heading, narrowed across by the bank, lifted over the highest ground under its middle and its four ends. The
+ /// Spitfire's, and the Dakotas' (DakotaLoop, #2482).
+ ///
+ /// The two steps are a fixed-point guess: each takes the ground's height where the last ray landed. Their miss is the
+ /// height left between the last two guesses times the ray's run per metre of fall (cot of the sun's elevation, 1.73 at
+ /// MapLighting's 30 degrees), and the guess only closes in where the ground under the ray rises more slowly than the ray
+ /// falls (slope x cot(elevation) under 1). That holds on the flat coast by el-Arish where the Spitfire flies, so its
+ /// shadow keeps the two steps (the default). The Dakotas over Tel Aviv cast theirs about 8 km east-south-east, up the
+ /// rising ground toward the hills, where two steps left it about 200 m off the ray (gate H4 on #2490). With
+ /// <paramref name="converge"/> the ray is cut instead by halving: between the aircraft (above the ground) and the point
+ /// where the ray falls to the lowest surface there can be (the sea's, or the terrain's base), so the ground is crossed
+ /// between them whatever its slope or the sun's height; a march in <see cref="ShadowMarchM"/> steps finds the first
+ /// crossing, and each halving halves that step, to under
+ /// <see cref="ShadowConvergeM"/> along the ray, at most <see cref="ShadowConvergeSteps"/> halvings.</summary>
+ internal static void LayShadow(Transform shadow, Terrain ground, float seaY, Vector2 shadowHalf, Vector3 drawn, Vector3 forward, float bank,
+ bool converge = false)
{
var ray = SunNow();
var hit = drawn;
- float floor = Surface(drawn);
- for (int i = 0; i < 2; i++)
+ float floor;
+ if (converge)
{
- hit = drawn + ray * ((drawn.y - floor) / -ray.y);
- floor = Surface(hit);
+ // At s = 0 the ray is at the aircraft, over the ground; at hi it is at the lowest surface there can be, at or
+ // under the ground (Surface is never below the sea's surface or the terrain's base).
+ float lo = 0f, hi = (drawn.y - Mathf.Max(seaY, ground.transform.position.y)) / -ray.y;
+ // The first crossing, not any: march out in ShadowMarchM steps until the ray is at or under the ground, so a
+ // ridge the ray clips puts the shadow on the ridge, not in the valley beyond it (review of #2490).
+ for (float s = ShadowMarchM; s < hi; s += ShadowMarchM)
+ {
+ var q = drawn + ray * s;
+ if (q.y > Surface(ground, seaY, q)) lo = s; else { hi = s; break; }
+ }
+ for (int i = 0; i < ShadowConvergeSteps && hi - lo > ShadowConvergeM; i++)
+ {
+ float mid = 0.5f * (lo + hi);
+ var q = drawn + ray * mid;
+ if (q.y > Surface(ground, seaY, q)) lo = mid; else hi = mid;
+ }
+ hit = drawn + ray * hi;
+ floor = Surface(ground, seaY, hit);
+ }
+ else
+ {
+ floor = Surface(ground, seaY, drawn);
+ for (int i = 0; i < 2; i++)
+ {
+ hit = drawn + ray * ((drawn.y - floor) / -ray.y);
+ floor = Surface(ground, seaY, hit);
+ }
}
var across = new Vector3(forward.z, 0f, -forward.x);
float half = shadowHalf.x * Mathf.Cos(bank * Mathf.Deg2Rad);
float top = floor;
- top = Mathf.Max(top, Surface(hit + across * half));
- top = Mathf.Max(top, Surface(hit - across * half));
- top = Mathf.Max(top, Surface(hit + forward * shadowHalf.y));
- top = Mathf.Max(top, Surface(hit - forward * shadowHalf.y));
- shadow!.SetPositionAndRotation(new Vector3(hit.x, top + ShadowLiftM, hit.z), Quaternion.LookRotation(forward, Vector3.up));
+ top = Mathf.Max(top, Surface(ground, seaY, hit + across * half));
+ top = Mathf.Max(top, Surface(ground, seaY, hit - across * half));
+ top = Mathf.Max(top, Surface(ground, seaY, hit + forward * shadowHalf.y));
+ top = Mathf.Max(top, Surface(ground, seaY, hit - forward * shadowHalf.y));
+ shadow.SetPositionAndRotation(new Vector3(hit.x, top + ShadowLiftM, hit.z), Quaternion.LookRotation(forward, Vector3.up));
shadow.localScale = new Vector3(half, 1f, shadowHalf.y);
}
+ /// <summary>The converging shadow's halvings (<see cref="LayShadow"/>): stop once the bracket along the ray is under
+ /// <see cref="ShadowConvergeM"/> (m), and after <see cref="ShadowConvergeSteps"/> at most. From 4,200 m at a 30 degree
+ /// sun the bracket starts under 10 km; the march (<see cref="ShadowMarchM"/>) leaves one step of it, so about 8 halvings.</summary>
+ internal const float ShadowConvergeM = 1f, ShadowMarchM = 200f;
+ internal const int ShadowConvergeSteps = 24;
+
/// <summary>The ground's height under <paramref name="p"/>, or the sea's surface over the sea.</summary>
- float Surface(Vector3 p) => Mathf.Max(ground!.SampleHeight(p) + ground.transform.position.y, seaY);
+ static float Surface(Terrain ground, float seaY, Vector3 p) => Mathf.Max(ground.SampleHeight(p) + ground.transform.position.y, seaY);
}
}
diff --git a/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs
index 6f92fae4b..bb0057855 100644
--- a/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs
+++ b/unity/Assets/Tests/EditMode/SeaAirCollectionTests.cs
@@ -74,14 +74,15 @@ public class SeaAirCollectionTests
/// <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>
+ /// 1 July 1949 (Magic Carpet's main wave) to 24 September 1950 (its last flights into Lydda). The harbour craft always.
+ /// #2482: the 15 May 1948 turn wants the two Dakotas, lead and wing, where #2274 wanted one.</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", "el-arish-spitfire", "tel-aviv-dakota" }, Keys(new DateTime(1948, 5, 15)));
+ CollectionAssert.AreEqual(new[] { "haifa-steamer", "jaffa-fishing", "acre-fishing", "el-arish-spitfire", "tel-aviv-dakota-lead", "tel-aviv-dakota-wing" }, Keys(new DateTime(1948, 5, 15)));
CollectionAssert.AreEqual(new[] { "haifa-steamer", "jaffa-fishing", "acre-fishing", "tel-aviv-altalena", "el-arish-spitfire" }, 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");
@@ -335,14 +336,27 @@ public class SeaAirCollectionTests
}
}
- // ---- Tal Heuberger's Egyptian Dakota (owner, 2 November 2026: "Over Tel Aviv, 15 May-11 Jun (Recommended)"; on #2274, "Off the coast is fine (Recommended)") ----
+ // ---- Tal Heuberger's Egyptian Dakotas (owner, 2 November 2026: "Over Tel Aviv, 15 May-11 Jun (Recommended)"; on #2274, "Off the coast is fine (Recommended)";
+ // on #2482, 4 November 2026: "1 + make the visual 2 slightly smaller planes and not 0ne big one") ----
/// <summary>The first bombing period, 15 May to 11 June 1948 (he.wiki rev 43856594, agent-read): on the game's monthly turns
- /// the 15 May turn only, at Tel Aviv's place.</summary>
+ /// the 15 May turn only, at Tel Aviv's place. #2482 (owner, 4 November 2026: "make the visual 2 slightly smaller planes and
+ /// not 0ne big one"; the sourced sortie was "גיחה של שני מטוסי הפצצה", two bombers): two Dakotas, each with its own stable
+ /// key made from DakotaKey, the lead first, each slightly smaller than the one 12.2 km Dakota of #2274 (DakotaScale of the
+ /// unit tokens' aircraft scale). Changed from #2274's one-key test: it asserted one want and the full 420x size.</summary>
[Test]
- public void TheDakotaIsWantedOnlyInTheFirstBombingPeriod()
+ public void TheTwoDakotasAreWantedOnlyInTheFirstBombingPeriod()
{
- bool Wanted(DateTime d) => SeaAirCollection.Wants(d, C).Any(w => w.Key == SeaAirCollection.DakotaKey && w.Model == SeaAirCollection.Dakota && w.Place == "tel_aviv");
+ bool Wanted(DateTime d)
+ {
+ var keys = SeaAirCollection.Wants(d, C).Where(w => w.Model == SeaAirCollection.Dakota && w.Place == "tel_aviv").Select(w => w.Key).ToArray();
+ if (keys.Length == 0) return false;
+ CollectionAssert.AreEqual(SeaAirCollection.DakotaKeys, keys, $"both Dakotas, the lead first, on {d:d MMM yyyy}");
+ return true;
+ }
+ Assert.AreEqual(2, SeaAirCollection.DakotaKeys.Length, "two planes, not one");
+ Assert.AreEqual(2, SeaAirCollection.DakotaKeys.Distinct().Count(), "each its own key");
+ foreach (var k in SeaAirCollection.DakotaKeys) StringAssert.StartsWith(SeaAirCollection.DakotaKey + "-", k, "a key made from DakotaKey");
Assert.IsFalse(Wanted(new DateTime(1948, 5, 14)));
Assert.IsTrue(Wanted(new DateTime(1948, 5, 15)));
Assert.IsTrue(Wanted(new DateTime(1948, 6, 3)), "the 3 June raid, when two Egyptian C-47s were shot down over Tel Aviv");
@@ -353,85 +367,252 @@ public class SeaAirCollectionTests
for (var d = C.Rules.Start; d < C.End; d = d.AddMonths(1)) turns.Add(d);
CollectionAssert.AreEqual(new[] { new DateTime(1948, 5, 15) }, turns.Where(Wanted), "the 15 May 1948 turn only");
Assert.AreEqual(29.11f, SeaAirCollection.RealLengthM(SeaAirCollection.Dakota), 0.01f, "95 ft 6 in, en.wiki Douglas C-47 Skytrain");
- Assert.AreEqual(29.11f * Statecraft.Game.Map.Units.UnitShowcase.AircraftScale, SeaAirCollection.SizeOf(SeaAirCollection.Dakota), 5f,
- "at the unit tokens' aircraft scale, as the Spitfire (#2014)");
+ float old = 29.11f * Statecraft.Game.Map.Units.UnitShowcase.AircraftScale; // #2274's one Dakota, 12.2 km across
+ Assert.That(SeaAirCollection.DakotaScale, Is.InRange(0.6f, 0.95f), "slightly smaller, not a different kind of piece");
+ Assert.AreEqual(old * SeaAirCollection.DakotaScale, SeaAirCollection.SizeOf(SeaAirCollection.Dakota), 5f, "the unit tokens' aircraft scale times DakotaScale");
+ Assert.Less(SeaAirCollection.SizeOf(SeaAirCollection.Dakota), old - 1000f, "smaller than the one big Dakota");
}
- (SeaAirCollection layer, Transform plane, DakotaLoop loop, Vector3 centre) DrawnDakota(MapScene map)
+ /// <summary>Both Dakotas on the 15 May 1948 turn: the layer, the two aircraft (lead first), their loops, and their loop's
+ /// centre in the air (one centre: they fly one track).</summary>
+ (SeaAirCollection layer, Transform[] planes, DakotaLoop[] loops, Vector3 centre) DrawnDakotas(MapScene map)
{
var layer = CollectionGeometryFixture.Craft(map, new DateTime(1948, 5, 15), Array.Empty<Placement>(), C)!;
- Assert.AreEqual(1, asked.Count(a => a.id == SeaAirCollection.Dakota && a.detail == CollectionDetail.Far), "the far mesh, once");
+ Assert.AreEqual(1, asked.Count(a => a.id == SeaAirCollection.Dakota && a.detail == CollectionDetail.Far), "the far mesh, once for both");
AnswerAll();
- var plane = layer.transform.Find(SeaAirCollection.DakotaKey)!;
- Assert.IsNotNull(plane, "the Dakota is drawn on 15 May 1948");
- return (layer, plane, plane.GetComponent<DakotaLoop>(), layer.Placed.Single(p => p.Model == SeaAirCollection.Dakota).At);
+ var planes = SeaAirCollection.DakotaKeys.Select(k => layer.transform.Find(k)).ToArray();
+ for (int i = 0; i < planes.Length; i++) Assert.IsNotNull(planes[i], $"{SeaAirCollection.DakotaKeys[i]} is drawn on 15 May 1948");
+ var centres = layer.Placed.Where(p => p.Model == SeaAirCollection.Dakota).Select(p => p.At).ToList();
+ Assert.AreEqual(2, centres.Count, "two Dakotas placed");
+ Assert.Less((centres[0] - centres[1]).magnitude, 1e-3f, "on one loop");
+ return (layer, planes!, planes.Select(p => p!.GetComponent<DakotaLoop>()).ToArray(), centres[0]);
+ }
+
+ /// <summary>World x, z.</summary>
+ static Vector2 Xz(Vector3 v) => new Vector2(v.x, v.z);
+
+ /// <summary>The box the labels keep clear of for <paramref name="plane"/> now (SeaAirCollection.KeepClear, which moves it to
+ /// where its loop last placed it), or null when it has none. Found by object, through the layer's keepOf.</summary>
+ static Bounds? DakotaKeepOf(SeaAirCollection layer, GameObject plane)
+ {
+ var all = layer.KeepClear; // first: it moves the Dakotas' boxes
+ var keepOf = (System.Collections.IDictionary)typeof(SeaAirCollection).GetField("keepOf", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.GetValue(layer)!;
+ if (!keepOf.Contains(plane)) return null;
+ var boxes = (Bounds[])keepOf[plane]!;
+ Assert.IsTrue(all.Any(b => ReferenceEquals(b, boxes)), $"{plane.name}'s box is in the list the labels read");
+ return boxes[0];
+ }
+
+ /// <summary>A 1948 locality's point on the ground (world), from its row (content/map/localities_1948.yaml), as its label marks it.</summary>
+ static Vector3 LocalityAt(MapScene map, string id)
+ {
+ var place = map.Localities.FirstOrDefault(p => p.Settlement.Id == id);
+ Assert.IsNotNull(place, $"premise: {id} is a 1948 locality on the map");
+ return map.Frame.ToWorld(place!.Settlement.Lon, place.Settlement.Lat, 0);
}
- /// <summary>"A slow loop over Tel Aviv": the loop's centre is the nearest to Tel Aviv whose whole swept box is over the
- /// board and clear of every unit token present in the window (rings and town clearings: Kiryati's token stands on Tel Aviv)
- /// and of every map label's point and town footprint, so the aircraft hides no token and no name; it is just off the city.
- /// The aircraft is drawn there at its map size, nose east, at the unit tokens' aircraft altitude, and the labels keep clear of
- /// its whole loop.</summary>
+ /// <summary>How far (m) the ground point <paramref name="p"/> lies outside the box's footprint seen from above (0 inside it).</summary>
+ static float OutsideFootprint(Bounds box, Vector3 p) =>
+ new Vector2(Mathf.Max(0f, box.min.x - p.x, p.x - box.max.x), Mathf.Max(0f, box.min.z - p.z, p.z - box.max.z)).magnitude;
+
+ /// <summary>#2490, owner, 4 November 2026: "Shrink the keep-clear area (Recommended)". On the 15 May 1948 turn the names had
+ /// kept clear of each Dakota's whole loop, which hid 14 names round Tel Aviv (EN 18 to 4 shown, HE 20 to 5); now a name
+ /// keeps clear only of where an aircraft and its flag are. Ramat Gan (34.8235, 32.07) lies under the lead at the loop's
+ /// start (over Tel Aviv's hex), so its box covers it there; at the loop's half (60 s, the lead on the northern pass, the
+ /// wing in the eastern turn) neither box comes within 3 km of Ramat Gan or Herzliya (34.8422, 32.1556), both inside the
+ /// whole loop's box the names kept clear of before. A box always holds its own aircraft, and moves with it.</summary>
[Test]
- public void TheDakotaLoopsJustOffTelAvivInsideTheBoardClearOfTokensAndLabels()
+ public void TheNamesKeepClearOnlyOfWhereEachDakotaIsNow()
{
var map = OpenMap();
- var (layer, plane, loop, at) = DrawnDakota(map);
- var tel = map.Settlements.Single(s => s.Id == "tel_aviv");
- var t3 = map.Frame.ToWorld(tel.Lon, tel.Lat, 0); var telAviv = new Vector2(t3.x, t3.z);
- var centre = new Vector2(at.x, at.z);
- var half = SeaAirCollection.DakotaSweptHalf;
- float fromCity = (centre - telAviv).magnitude;
- TestContext.WriteLine($"Dakota loop centre {fromCity:0} m from Tel Aviv's point; nearest pass {Mathf.Max(Mathf.Abs(centre.x - telAviv.x) - SeaAirCollection.SpitfireLoopHalfLengthM, 0f):0} m east-west");
- Assert.Less(fromCity, 30000f, "by Tel Aviv");
- // The owner on #2274: "Off the coast is fine (Recommended)": the whole loop is over the sea.
- var ground = PlacementLayer.CampGround(map);
- Assert.IsTrue(ground.Water(centre.x, centre.y), "its loop's centre is over the sea");
- for (int i = 0; i < 48; i++)
+ var (layer, planes, loops, at) = DrawnDakotas(map);
+ var ramatGan = LocalityAt(map, "ramat_gan"); var herzliya = LocalityAt(map, "herzliya");
+ // Premise: #2274's whole-loop box (the loop and the aircraft's reach) covered both, so both names were hidden.
+ var swept = SeaAirCollection.DakotaSweptHalf;
+ foreach (var (name, p) in new[] { ("Ramat Gan", ramatGan), ("Herzliya", herzliya) })
+ Assert.IsTrue(Mathf.Abs(p.x - at.x) < swept.x && Mathf.Abs(p.z - at.z) < swept.y, $"premise: {name} is inside the whole loop's box");
+
+ for (int p = 0; p < planes.Length; p++) loops[p].Place(0f);
+ var lead0 = DakotaKeepOf(layer, planes[0].gameObject)!.Value;
+ Assert.AreEqual(0f, OutsideFootprint(lead0, ramatGan), 1e-3f, "at the loop's start the lead is over Ramat Gan: its name keeps clear");
+ foreach (var plane in planes)
{
- var q = centre + SeaAirCollection.DakotaLoopOffset(i * SeaAirCollection.DakotaLoopSeconds / 48f);
- Assert.IsTrue(ground.Water(q.x, q.y), $"its path is over the sea at step {i}");
+ var pb = WorldBounds(plane.gameObject); var keep = DakotaKeepOf(layer, plane.gameObject)!.Value;
+ Assert.IsTrue(keep.Contains(pb.min) && keep.Contains(pb.max), $"{plane.name}'s box holds it at the loop's start");
}
- Assert.IsTrue(ground.Inside(centre.x - half.x, centre.y - half.y) && ground.Inside(centre.x + half.x, centre.y + half.y), "its whole loop over the board");
- foreach (var kv in map.UnitSpots)
+
+ float half = 0.5f * SeaAirCollection.DakotaLoopSeconds;
+ for (int p = 0; p < planes.Length; p++) loops[p].Place(half);
+ foreach (var plane in planes)
+ {
+ var keep = DakotaKeepOf(layer, plane.gameObject)!.Value; var pb = WorldBounds(plane.gameObject);
+ Assert.IsTrue(keep.Contains(pb.min) && keep.Contains(pb.max), $"{plane.name}'s box moved with it to {half:0} s");
+ TestContext.WriteLine($"{plane.name} at {half:0} s: Ramat Gan {OutsideFootprint(keep, ramatGan):0} m out, Herzliya {OutsideFootprint(keep, herzliya):0} m out");
+ Assert.Greater(OutsideFootprint(keep, ramatGan), 3000f, $"{plane.name} is far from Ramat Gan at {half:0} s: its name shows");
+ Assert.Greater(OutsideFootprint(keep, herzliya), 3000f, $"{plane.name} is far from Herzliya at {half:0} s: its name shows");
+ }
+ Assert.Less(DakotaKeepOf(layer, planes[0].gameObject)!.Value.size.x, 0.6f * 2f * swept.x, "much smaller than the whole loop's box");
+ }
+
+ /// <summary>#2490: the Dakotas' keep-clear boxes move a DakotaKeepStepS step at a time, so the labels (which re-place
+ /// themselves only on a new list) re-place at most once a step, never every frame: within one step KeepClear is the
+ /// same list, a step on it is a new one, and the box for a step covers the aircraft through the whole step.</summary>
+ [Test]
+ public void TheDakotasKeepClearMovesAStepAtATime()
+ {
+ var map = OpenMap();
+ var (layer, planes, loops, _) = DrawnDakotas(map);
+ float step = SeaAirCollection.DakotaKeepStepS;
+ Assert.That(step, Is.InRange(0.25f, 2f), "a short step: the box stays near the aircraft, the labels re-place a few times a second at most");
+ for (int p = 0; p < planes.Length; p++) loops[p].Place(10f * step);
+ var first = layer.KeepClear;
+ Assert.AreSame(first, layer.KeepClear, "no new list while nothing moves");
+ for (int p = 0; p < planes.Length; p++) loops[p].Place(10.5f * step);
+ Assert.AreSame(first, layer.KeepClear, "the same list within one step");
+ var box = DakotaKeepOf(layer, planes[0].gameObject)!.Value;
+ for (int i = 0; i <= 8; i++)
{
- if (Statecraft.Game.Map.Units.UnitData.Day(kv.Key.From) > SeaAirCollection.DakotaTo || Statecraft.Game.Map.Units.UnitData.Day(kv.Key.To) <= SeaAirCollection.DakotaFrom) continue;
- var c = new Vector2((float)kv.Value.X, (float)kv.Value.Z);
- float dx = Mathf.Max(Mathf.Abs(c.x - centre.x) - half.x, 0f), dz = Mathf.Max(Mathf.Abs(c.y - centre.y) - half.y, 0f);
- float r = kv.Value.InTown ? map.UnitClearings.Where(x => (x.centre - c).sqrMagnitude < 1f).Select(x => x.radius).DefaultIfEmpty(0f).Max()
- : map.UnitTokens.Where(x => (x.centre - c).sqrMagnitude < 1f).Select(x => x.radius).DefaultIfEmpty(0f).Max();
- Assert.Greater(r, 0f, $"{kv.Key.Place}'s token has its ring or clearing");
- Assert.Greater(Mathf.Sqrt(dx * dx + dz * dz), r, $"clear of the token at {kv.Key.Place} ({kv.Key.From}-{kv.Key.To})");
+ loops[0].Place((10f + i / 8f * 0.999f) * step);
+ var pb = WorldBounds(planes[0].gameObject);
+ Assert.IsTrue(box.Contains(pb.min) && box.Contains(pb.max), $"the step's box holds the lead through the step ({i}/8)");
}
- foreach (var s in map.Settlements)
+ for (int p = 0; p < planes.Length; p++) loops[p].Place(11.5f * step);
+ Assert.AreNotSame(first, layer.KeepClear, "a new list a step on, so the labels re-place");
+ }
+
+
+ /// <summary>The world point is on one of Tel Aviv's hexes (content/map/settlement_hexes.yaml), by the map's own click
+ /// picker (MapPointer.Pick: lon/lat and tools/hexgrid.py's rounding), a different route from the layer's own grid test.</summary>
+ static bool OnTelAviv(MapScene map, Vector3 world)
+ {
+ var (q, r) = MapPointer.Pick(map, world);
+ return C.SettlementHexes.Any(h => h.Id == SeaAirCollection.DakotaTown && h.Q == q && h.R == r);
+ }
+
+ /// <summary>Two Dakotas in the window, none outside it (#2482): on the turns of 14 May, 12 June and 15 June 1948 no Dakota,
+ /// no loop, and no marks object (flag, shadow, bombs) is drawn; on the 15 May turn exactly two looping Dakotas, each at
+ /// the smaller size.</summary>
+ [Test]
+ public void TwoDakotasFlyInTheWindowAndNoneOutsideIt()
+ {
+ var map = OpenMap();
+ foreach (var (date, flying) in new[]
+ {
+ (new DateTime(1948, 5, 14), false), (new DateTime(1948, 5, 15), true), (new DateTime(1948, 6, 11), true),
+ (new DateTime(1948, 6, 12), false), (new DateTime(1948, 6, 15), false),
+ })
{
- var p = map.Frame.ToWorld(s.Lon, s.Lat, 0);
- Assert.IsFalse(Mathf.Abs(p.x - centre.x) <= half.x && Mathf.Abs(p.z - centre.y) <= half.y, $"{s.Id}'s name is not under its loop");
+ var layer = CollectionGeometryFixture.Craft(map, date, Array.Empty<Placement>(), C)!; AnswerAll();
+ Assert.AreEqual(flying ? 2 : 0, layer.Placed.Count(p => p.Model == SeaAirCollection.Dakota), $"the Dakotas on {date:d MMM yyyy}");
+ Assert.AreEqual(flying ? 2 : 0, Object.FindObjectsByType<DakotaLoop>(FindObjectsInactive.Include, FindObjectsSortMode.None).Length, $"the loops on {date:d MMM yyyy}");
+ foreach (var k in SeaAirCollection.DakotaKeys)
+ {
+ Assert.AreEqual(flying, layer.transform.Find(k) != null, $"{k} on {date:d MMM yyyy}");
+ Assert.AreEqual(flying, layer.transform.Find(k + SeaAirCollection.DakotaMarksSuffix) != null, $"{k}'s flag, shadow and bombs on {date:d MMM yyyy}");
+ }
}
- foreach (var (fc, fr, id) in map.KitFootprints)
+ }
+
+ /// <summary>#2482: "on the bombing turns it flies over Tel Aviv (not just off the coast)" (option 1, which the owner chose on
+ /// 4 November 2026). Changed from #2274's TheDakotaLoopsJustOffTelAvivInsideTheBoardClearOfTokensAndLabels, which held the
+ /// whole loop over the sea and its ground box clear of every token, kit and name (the 2 November "Off the coast is fine"
+ /// placement): over the city the loop cannot clear Kiryati's token on Tel Aviv, so those ground clearances go and only the
+ /// clearance of the aircraft at altitude stays. The loop's start (the screenshots' frame) is over Tel Aviv's hex, its path
+ /// crosses the hex and runs out over the sea (in from the sea), the whole loop is over the board, the aircraft fly at the
+ /// unit tokens' aircraft altitude, nose east and wingspan north-south at the start, and the labels keep clear of each
+ /// aircraft at every point of the loop. Changed for #2490 (owner, 4 November 2026: "Shrink the keep-clear area
+ /// (Recommended)"): the box is where the aircraft is now, read after each placing, not one box over its whole loop.</summary>
+ [Test]
+ public void TheDakotasLoopOverTelAvivAtAltitudeInsideTheBoard()
+ {
+ var map = OpenMap();
+ var (layer, planes, loops, at) = DrawnDakotas(map);
+ Assert.Greater(C.SettlementHexes.Count(h => h.Id == SeaAirCollection.DakotaTown), 0, "premise: Tel Aviv has its hex");
+ var centre = Xz(at);
+ var ground = PlacementLayer.CampGround(map);
+ Assert.IsTrue(OnTelAviv(map, new Vector3(centre.x + SeaAirCollection.DakotaLoopOffset(0f).x, 0f, centre.y + SeaAirCollection.DakotaLoopOffset(0f).y)),
+ "the loop's start, held in screenshots, is over Tel Aviv's hex");
+ int over = 0, sea = 0;
+ float period = SeaAirCollection.DakotaLoopSeconds;
+ for (int i = 0; i < 240; i++)
{
- float dx = Mathf.Max(Mathf.Abs(fc.x - centre.x) - half.x, 0f), dz = Mathf.Max(Mathf.Abs(fc.y - centre.y) - half.y, 0f);
- Assert.Greater(dx * dx + dz * dz, fr * fr, $"clear of {id}'s kit");
+ var q = centre + SeaAirCollection.DakotaLoopOffset(i * period / 240f);
+ if (OnTelAviv(map, new Vector3(q.x, 0f, q.y))) over++;
+ if (ground.Water(q.x, q.y)) sea++;
}
- var b = WorldBounds(plane.gameObject);
- Assert.AreEqual(SeaAirCollection.SizeOf(SeaAirCollection.Dakota), b.size.z, 1f, "wingspan north-south at its size: the nose points east");
- Assert.Greater(Vector3.Dot(plane.TransformDirection(Vector3.down), Vector3.right), 0.9f, "the nose (the mesh's -y) points east at the loop's start");
- float floor = Statecraft.Game.Map.Units.UnitShowcase.LoopFloor(map, new Vector3(at.x, 0f, at.z), SeaAirCollection.SpitfireLoopHalfLengthM + SeaAirCollection.SizeOf(SeaAirCollection.Dakota));
+ TestContext.WriteLine($"Dakota loop: {over} of 240 steps over Tel Aviv's hex, {sea} over the sea");
+ Assert.Greater(over, 0, "its path crosses Tel Aviv's hex");
+ Assert.Greater(sea, 0, "and runs out over the sea");
+ var half = SeaAirCollection.DakotaSweptHalf;
+ Assert.IsTrue(ground.Inside(centre.x - half.x, centre.y - half.y) && ground.Inside(centre.x + half.x, centre.y + half.y), "its whole loop over the board");
+ float span = SeaAirCollection.SizeOf(SeaAirCollection.Dakota);
+ float floor = Statecraft.Game.Map.Units.UnitShowcase.LoopFloor(map, new Vector3(at.x, 0f, at.z), SeaAirCollection.DakotaLoopHalfLengthM + span);
Assert.AreEqual(Statecraft.Game.Map.Units.UnitShowcase.AltitudeM, at.y - floor, 1f, "the unit tokens' aircraft altitude, as the Spitfire");
+ loops[0].Place(0f);
+ var b = WorldBounds(planes[0].gameObject);
+ Assert.AreEqual(span, b.size.z, 1f, "wingspan north-south at its size: the nose points east");
+ Assert.Greater(Vector3.Dot(planes[0].TransformDirection(Vector3.down), Vector3.right), 0.9f, "the nose (the mesh's -y) points east at the loop's start");
Assert.Greater(b.min.y, floor, "in flight, never on the ground");
- Assert.IsTrue(loop.Still, "edit mode holds the loop's start");
- var keep = layer.KeepClear.Single(k => k[0].Contains(at))[0];
+ foreach (var loop in loops) Assert.IsTrue(loop.Still, "edit mode holds the loop's start");
+ Assert.AreEqual(2, planes.Count(p => DakotaKeepOf(layer, p.gameObject) != null), "one keep-clear box an aircraft");
for (int i = 0; i < 60; i++)
{
- loop.Place(i * SeaAirCollection.DakotaLoopSeconds / 60f);
- var pb = WorldBounds(plane.gameObject);
- Assert.IsTrue(keep.Contains(pb.min) && keep.Contains(pb.max), $"inside the box the labels keep clear of at step {i}");
- Assert.IsTrue(Mathf.Abs(pb.center.x - centre.x) <= half.x && Mathf.Abs(pb.center.z - centre.y) <= half.y, $"inside its swept box at step {i}");
+ float t = i * period / 60f;
+ for (int p = 0; p < planes.Length; p++)
+ {
+ loops[p].Place(t);
+ var pb = WorldBounds(planes[p].gameObject);
+ var keep = DakotaKeepOf(layer, planes[p].gameObject)!.Value; // the box follows it (#2490: "Shrink the keep-clear area")
+ Assert.IsTrue(keep.Contains(pb.min) && keep.Contains(pb.max), $"{planes[p].name} inside the box the labels keep clear of at {t:0.0} s");
+ Assert.IsTrue(Mathf.Abs(pb.center.x - centre.x) <= half.x && Mathf.Abs(pb.center.z - centre.y) <= half.y, $"{planes[p].name} inside its swept box at {t:0.0} s");
+ Assert.Greater(pb.min.y, floor, $"{planes[p].name} in flight at {t:0.0} s");
+ }
+ }
+ }
+
+ /// <summary>#2482's pair (the sourced "גיחה של שני מטוסי הפצצה", two bombers a sortie): both fly the one track, the wing
+ /// <see cref="SeaAirCollection.DakotaTrailSeconds"/> behind the lead (close behind, not across the loop), at one altitude,
+ /// and they never meet: seen from above, every point of a Dakota lies within DakotaReachShare of its span of its drawn
+ /// centre (read off the mesh here), and their centres stay more than twice that apart at every point of the loop.</summary>
+ [Test]
+ public void TheTwoSmallerDakotasFlyOneTrackAsAPairAndNeverMeet()
+ {
+ var map = OpenMap();
+ var (_, planes, loops, centre) = DrawnDakotas(map);
+ float span = SeaAirCollection.SizeOf(SeaAirCollection.Dakota), period = SeaAirCollection.DakotaLoopSeconds;
+ Assert.AreEqual(0f, loops[0].Lag, 1e-4f, "the lead flies the loop's own clock");
+ Assert.AreEqual(SeaAirCollection.DakotaTrailSeconds, loops[1].Lag, 1e-4f, "the wing trails it");
+ Assert.That(SeaAirCollection.DakotaTrailSeconds, Is.InRange(0.05f * period, 0.3f * period), "close behind: a pair, not opposite sides of the loop");
+ for (int p = 0; p < planes.Length; p++)
+ {
+ loops[p].Place(loops[p].Lag); // each at its own loop's start: level, nose east
+ Assert.AreEqual(span, WorldBounds(planes[p].gameObject).size.z, 1f, $"{planes[p].name} at the smaller size");
+ }
+ loops[0].Place(0f);
+ var mesh = planes[0].GetComponentInChildren<MeshFilter>();
+ var drawn = WorldBounds(planes[0].gameObject).center;
+ float reach = mesh.sharedMesh.vertices.Select(mesh.transform.TransformPoint).Max(v => Xz(v - drawn).magnitude);
+ TestContext.WriteLine($"Dakota reach from above {reach:0} m, {reach / span:0.000} of its span");
+ Assert.LessOrEqual(reach, SeaAirCollection.DakotaReachShare * span, "every point within DakotaReachShare of the span of its centre");
+ float closest = float.MaxValue;
+ for (int i = 0; i < 480; i++)
+ {
+ float t = i * period / 480f;
+ foreach (var loop in loops) loop.Place(t);
+ var a = WorldBounds(planes[0].gameObject).center; var b = WorldBounds(planes[1].gameObject).center;
+ var lag = SeaAirCollection.DakotaLoopOffset(t - SeaAirCollection.DakotaTrailSeconds);
+ Assert.Less((Xz(b) - (Xz(centre) + lag)).magnitude, 1f, $"the wing on the lead's track at {t:0.0} s");
+ Assert.AreEqual(a.y, b.y, 1f, "at one altitude");
+ closest = Mathf.Min(closest, (Xz(a) - Xz(b)).magnitude);
}
+ TestContext.WriteLine($"closest approach {closest:0} m, against {2f * SeaAirCollection.DakotaReachShare * span:0} m");
+ Assert.Greater(closest, 2f * SeaAirCollection.DakotaReachShare * span, "the two never meet");
}
- /// <summary>The loop is closed (a period on, the same place and heading, also long into a session), the aircraft flies it
- /// nose first, level, and the per-frame step allocates nothing.</summary>
+ /// <summary>The loop is closed (a period on, the same place and heading, also long into a session), each aircraft flies it
+ /// nose first with its nose level, and the per-frame step (the aircraft, its propellers, shadow, flag and bombs) allocates
+ /// nothing. Changed from #2274's test: the period may now reach 120 s (the larger loop of #2482 at about the Spitfire's
+ /// speed) and both aircraft are checked, each on its own lagged clock.</summary>
[Test]
public void TheDakotaLoopIsClosedNoseFirstAndAllocatesNothingPerFrame()
{
@@ -445,58 +626,500 @@ public class SeaAirCollectionTests
Assert.Greater(Vector2.Dot(SeaAirCollection.DakotaLoopHeading(t), chord.normalized), 0.999f, $"the heading is the path's tangent at {t} s");
}
var map = OpenMap();
- var (_, plane, loop, centre) = DrawnDakota(map);
- for (int i = 0; i < 24; i++)
- {
- float t = i * period / 24f;
- loop.Place(t);
- var nose = plane.TransformDirection(Vector3.down);
- Assert.AreEqual(0f, nose.y, 1e-3f, "level flight");
- Assert.Greater(Vector2.Dot(new Vector2(nose.x, nose.z).normalized, SeaAirCollection.DakotaLoopHeading(t)), 0.999f, $"nose along the path at {t:0.0} s");
- var b = WorldBounds(plane.gameObject); var at = SeaAirCollection.DakotaLoopOffset(t);
- Assert.AreEqual(centre.x + at.x, b.center.x, 1f); Assert.AreEqual(centre.z + at.y, b.center.z, 1f); Assert.AreEqual(centre.y, b.center.y, 1f);
- }
- for (int i = 0; i < 10; i++) loop.Place(i); // warm up
+ var (_, planes, loops, centre) = DrawnDakotas(map);
+ for (int p = 0; p < planes.Length; p++)
+ for (int i = 0; i < 24; i++)
+ {
+ float t = i * period / 24f, u = t - loops[p].Lag;
+ loops[p].Place(t);
+ var nose = planes[p].TransformDirection(Vector3.down);
+ Assert.AreEqual(0f, nose.y, 1e-3f, "the nose level (it banks about it)");
+ Assert.Greater(Vector2.Dot(new Vector2(nose.x, nose.z).normalized, SeaAirCollection.DakotaLoopHeading(u)), 0.999f, $"{planes[p].name} nose along the path at {t:0.0} s");
+ var b = WorldBounds(planes[p].gameObject); var at = SeaAirCollection.DakotaLoopOffset(u);
+ Assert.AreEqual(centre.x + at.x, b.center.x, 1f); Assert.AreEqual(centre.z + at.y, b.center.z, 1f); Assert.AreEqual(centre.y, b.center.y, 1f);
+ }
+ foreach (var loop in loops) for (int i = 0; i < 10; i++) loop.Place(i); // warm up
long before = GC.GetAllocatedBytesForCurrentThread();
- for (int i = 0; i < 1000; i++) loop.Place(i * 0.016f);
+ for (int i = 0; i < 1000; i++) foreach (var loop in loops) loop.Place(i * 0.016f);
Assert.AreEqual(0, GC.GetAllocatedBytesForCurrentThread() - before, "no allocation per frame");
}
- /// <summary>Egypt's flag as the owner ruled for the Spitfire on #2260 ("Smaller flag, no pole"): the cloth alone, in Egypt's
- /// sourced colours, half the tokens' flag size, floating over the tail and clear above the aircraft at every point of its
- /// loop, turned to the camera, and gone with the aircraft.</summary>
+ /// <summary>#2482's "a bank into their turns" (owner, 4 November 2026, before the ruling: "it also doesnt look like its flying"):
+ /// the Dakotas' loop is the Spitfire's shape at DakotaLoopScale, so its curvature at each point is the Spitfire's over that
+ /// scale, and the Spitfire's BankFor of the curvature at the Spitfire's scale gives the same bank at the same point: level on
+ /// the passes (the bomb run over Tel Aviv among them), the unit tokens' aircraft bank at the ends, and some all through the
+ /// turns. The curvature is the path's own (a finite difference of DakotaLoopOffset agrees). Each drawn aircraft's inner
+ /// wing is lower by its own bank, on its own lagged clock, and its nose stays level.</summary>
+ [Test]
+ public void TheDakotasBankIntoTheirTurnsByBankFor()
+ {
+ float period = SeaAirCollection.DakotaLoopSeconds, max = Statecraft.Game.Map.Units.UnitShowcase.BankDegrees;
+ Assert.AreEqual(0f, SeaAirCollection.DakotaBankDegrees(0f), 1e-3f, "level on the bomb run over Tel Aviv");
+ Assert.AreEqual(0f, SeaAirCollection.DakotaBankDegrees(0.5f * period), 1e-3f, "level on the pass back");
+ Assert.AreEqual(max, SeaAirCollection.DakotaBankDegrees(0.25f * period), 1e-3f, "the turn at the east end");
+ Assert.AreEqual(max, SeaAirCollection.DakotaBankDegrees(0.75f * period), 1e-3f, "the turn at the west end");
+ float least = SeaAirCollection.DakotaLoopCurvature(0f);
+ for (int i = 0; i < 200; i++)
+ {
+ float t = i * period / 200f, h = 0.5f;
+ Vector2 p0 = SeaAirCollection.DakotaLoopOffset(t - h), p1 = SeaAirCollection.DakotaLoopOffset(t), p2 = SeaAirCollection.DakotaLoopOffset(t + h);
+ Vector2 d1 = (p2 - p0) / (2f * h), d2 = (p2 - 2f * p1 + p0) / (h * h);
+ float numeric = Mathf.Abs(d1.x * d2.y - d1.y * d2.x) / Mathf.Pow(d1.magnitude, 3f);
+ float k = SeaAirCollection.DakotaLoopCurvature(t);
+ Assert.AreEqual(numeric, k, 0.01f * numeric, $"the path's curvature at {t:0.0} s");
+ Assert.AreEqual(SeaAirCollection.BankFor(SeaAirCollection.DakotaLoopScale * k), SeaAirCollection.DakotaBankDegrees(t), 1e-3f, $"BankFor at the Spitfire's scale at {t:0.0} s");
+ if (k > 1.05f * least) Assert.Greater(SeaAirCollection.DakotaBankDegrees(t), 0f, $"into the turn at {t:0.0} s");
+ }
+ var map = OpenMap();
+ var (_, planes, loops, centre) = DrawnDakotas(map);
+ var c = Xz(centre);
+ for (int p = 0; p < planes.Length; p++)
+ {
+ var mesh = planes[p].GetComponentInChildren<MeshFilter>(); var v = mesh.sharedMesh.vertices;
+ float tipX = v.Max(q => Mathf.Abs(q.x));
+ Vector3 Tip(float side) { var tip = v.Where(q => q.x * side > 0.96f * tipX).ToList(); return tip.Aggregate(Vector3.zero, (a, q) => a + q) / tip.Count; }
+ Vector3 left = Tip(-1f), right = Tip(1f);
+ for (int i = 0; i <= 200; i++)
+ {
+ float t = i * 2f * period / 200f;
+ loops[p].Place(t);
+ Vector3 a = mesh.transform.TransformPoint(left), b = mesh.transform.TransformPoint(right);
+ bool aInner = Vector2.Distance(Xz(a), c) < Vector2.Distance(Xz(b), c);
+ Vector3 inner = aInner ? a : b, outer = aInner ? b : a;
+ float roll = Mathf.Asin((outer.y - inner.y) / (outer - inner).magnitude) * Mathf.Rad2Deg;
+ Assert.AreEqual(SeaAirCollection.DakotaBankDegrees(t - loops[p].Lag), roll, 1.5f, $"{planes[p].name}'s inner wing down by its bank at {t:0.0} s");
+ Assert.AreEqual(0f, planes[p].TransformDirection(Vector3.down).y, 1e-3f, $"the nose level at {t:0.0} s");
+ }
+ }
+ }
+
+ /// <summary>#2482's "turning propellers on both engines" (the C-47's two radial engines, en.wiki "Douglas C-47 Skytrain"). The
+ /// model is one fused mesh, so, as the Spitfire's (#2260), a translucent disc turns at each engine instead: two children
+ /// of the aircraft's mesh, one either side of the fuselage, each at the front of its own nacelle (the front-most vertices
+ /// on its side, read here from the mesh), turning about the flight axis by the clock, held still in edit mode and shots.
+ /// Their boxes stay inside the airframe's at every angle, so the aircraft's measured box never moves with them.</summary>
[Test]
- public void TheDakotaFliesEgyptsFlagOverItsTailWithNoPole()
+ public void EachDakotaEngineHasATurningPropeller()
{
var map = OpenMap();
- var (layer, plane, loop, _) = DrawnDakota(map);
- var flag = loop.Flag;
- Assert.IsNotNull(flag, "a flag over the aircraft");
- Assert.IsNotNull(flag!.GetComponent<Statecraft.Game.Map.Units.UnitFlagFacing>(), "turned to the camera, as the tokens' flags");
- var mesh = flag.GetComponent<MeshFilter>().sharedMesh;
+ var (_, planes, loops, _) = DrawnDakotas(map);
+ float span = SeaAirCollection.SizeOf(SeaAirCollection.Dakota);
+ for (int p = 0; p < planes.Length; p++)
+ {
+ var loop = loops[p]; var plane = planes[p];
+ var airframe = plane.GetComponentInChildren<MeshFilter>();
+ var props = airframe.transform.Cast<Transform>().Where(x => x.name == SeaAirCollection.DakotaPropellerName).ToArray();
+ Assert.AreEqual(2, props.Length, $"{plane.name}: a disc at each engine");
+ loop.Place(loop.Lag); // level, nose east
+ var nose = plane.TransformDirection(Vector3.down); var across = plane.TransformDirection(Vector3.right);
+ var middle = WorldBounds(plane.gameObject).center;
+ var verts = airframe.sharedMesh.vertices.Select(airframe.transform.TransformPoint).ToList();
+ float length = verts.Max(v => Vector3.Dot(v, nose)) - verts.Min(v => Vector3.Dot(v, nose));
+ var sides = props.Select(x => Vector3.Dot(x.position - middle, across)).ToArray();
+ Assert.Less(sides[0] * sides[1], 0f, "one either side of the fuselage");
+ foreach (var prop in props)
+ {
+ float side = Vector3.Dot(prop.position - middle, across);
+ Assert.That(Mathf.Abs(side) / span, Is.InRange(0.08f, 0.2f), "on the wing, at an engine, not at the nose or a tip");
+ var nacelle = verts.Where(v => Mathf.Abs(Vector3.Dot(v - middle, across) - side) < 0.03f * span).ToList();
+ float front = nacelle.Max(v => Vector3.Dot(v, nose));
+ float behind = front - Vector3.Dot(prop.position, nose);
+ Assert.That(behind / length, Is.InRange(-0.01f, 0.05f), $"at its nacelle's front ({behind:0} m behind it)");
+ Assert.Greater(Mathf.Abs(Vector3.Dot(prop.TransformDirection(Vector3.up), nose)), 0.999f, "it turns about the flight axis");
+ Assert.AreEqual(ShadowCastingMode.Off, prop.GetComponent<MeshRenderer>().shadowCastingMode, "a blur casts no shadow");
+ loop.Place(loop.Lag); var q0 = prop.localRotation;
+ loop.Place(loop.Lag + 0.02f); var q1 = prop.localRotation;
+ Assert.AreEqual(0.02f * SpitfireLoop.PropDegreesPerSecond, Quaternion.Angle(q0, q1), 0.5f, "it turns between two frames");
+ }
+ for (int i = 0; i < 24; i++)
+ {
+ float t = i * 0.011f + (i % 4) * 25f;
+ loop.Place(t);
+ var all = WorldBounds(plane.gameObject); var own = airframe.GetComponent<Renderer>().bounds;
+ Assert.Less((all.min - own.min).magnitude + (all.max - own.max).magnitude, 0.5f, $"the discs' boxes stay inside the airframe's at {t:0.000} s");
+ }
+ Assert.IsTrue(loop.Still, "edit mode holds the loop's start");
+ var clock = SpitfireLoop.Clock;
+ var update = typeof(DakotaLoop).GetMethod("Update", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!;
+ try
+ {
+ loop.Place(0f); var held = props[0].localRotation;
+ SpitfireLoop.Clock = () => 12.34f;
+ update.Invoke(loop, null);
+ Assert.AreEqual(0f, Quaternion.Angle(held, props[0].localRotation), 1e-3f, "held (edit mode, -shot): the propellers do not turn");
+ }
+ finally { SpitfireLoop.Clock = clock; }
+ }
+ }
+
+ /// <summary>#2482's "a shadow on the ground", as the Spitfire's: a soft dark disc in each Dakota's marks object, where the
+ /// scene's sun casts it through the aircraft, turned with its heading, a little over the ground (or the sea) under it.</summary>
+ [Test]
+ public void EachDakotaCastsAShadowOnTheGround()
+ {
+ var map = OpenMap();
+ var sun = new GameObject("TEST ONLY sun").AddComponent<Light>();
+ var sunWas = RenderSettings.sun;
+ try
+ {
+ sun.type = LightType.Directional; MapLighting.Apply(sun);
+ var (layer, planes, loops, centre) = DrawnDakotas(map);
+ float y0 = map.Terrain.transform.position.y, span = SeaAirCollection.SizeOf(SeaAirCollection.Dakota);
+ float Height(Vector3 q) => Mathf.Max(map.Terrain.SampleHeight(q) + y0, PlacementLayer.CampGround(map).SeaLevelY);
+ for (int p = 0; p < planes.Length; p++)
+ {
+ var shadow = layer.transform.Find(planes[p].name + SeaAirCollection.DakotaMarksSuffix)?.Find(SeaAirCollection.DakotaShadowName);
+ Assert.IsNotNull(shadow, $"{planes[p].name}: a ground shadow beside the aircraft");
+ var r = shadow!.GetComponent<MeshRenderer>();
+ Assert.AreEqual(ShadowCastingMode.Off, r.shadowCastingMode); Assert.IsFalse(r.receiveShadows);
+ for (int i = 0; i < 24; i++)
+ {
+ float t = i * SeaAirCollection.DakotaLoopSeconds / 24f, u = t - loops[p].Lag;
+ loops[p].Place(t);
+ var at = SeaAirCollection.DakotaLoopOffset(u); var drawn = centre + new Vector3(at.x, 0f, at.y);
+ var s = shadow.position; float g = Height(s);
+ Assert.GreaterOrEqual(s.y - g, 0f, $"over the ground under it at {t:0.0} s");
+ // The disc lies flat, lifted ShadowLiftM over the highest ground under its middle and its four ends
+ // (SpitfireLoop.LayShadow). The Dakota's is km across, so on the rising ground east of Tel Aviv an end can
+ // stand hundreds of metres over the middle: the rule, read off the shadow's own transform, not a fixed band.
+ var fore = shadow.forward; var side = new Vector3(fore.z, 0f, -fore.x);
+ float hMid = Height(s), hAcross1 = Height(s + side * shadow.localScale.x), hAcross2 = Height(s - side * shadow.localScale.x),
+ hAlong1 = Height(s + fore * shadow.localScale.z), hAlong2 = Height(s - fore * shadow.localScale.z);
+ float top = Mathf.Max(hMid, Mathf.Max(Mathf.Max(hAcross1, hAcross2), Mathf.Max(hAlong1, hAlong2)));
+ Assert.AreEqual(top + SpitfireLoop.ShadowLiftM, s.y, 0.5f, $"lifted ShadowLiftM over the highest ground under it at {t:0.0} s: "
+ + $"middle {hMid:0.0}, across {hAcross1:0.0} / {hAcross2:0.0}, along {hAlong1:0.0} / {hAlong2:0.0} m");
+ var cast = drawn + SpitfireLoop.SunRay * ((drawn.y - g) / -SpitfireLoop.SunRay.y);
+ float miss = Xz(s - cast).magnitude;
+ Assert.Less(miss, 0.03f * (drawn.y - g), $"on the sun's ray through the aircraft at {t:0.0} s: ground {g:0} m under the shadow, "
+ + $"{Height(drawn):0} m under the aircraft, {drawn.y:0} m aircraft, {miss:0} m off the ray");
+ // The ray's first crossing (review of #2490): from the aircraft to the shadow the ray is over the ground at
+ // every 100 m, but for the last metre, so no ridge it clips before the shadow is passed over.
+ float reach = Xz(s - drawn).magnitude / Xz(SpitfireLoop.SunRay).magnitude;
+ for (float along = 0f; along < reach - 1f; along += 100f)
+ {
+ var q = drawn + SpitfireLoop.SunRay * along;
+ Assert.Greater(q.y, Height(q), $"the ray over the ground before its shadow at {t:0.0} s: under it at s = {along:0} m of {reach:0} m");
+ }
+ var heading = SeaAirCollection.DakotaLoopHeading(u);
+ Assert.Greater(Vector3.Dot(shadow.forward, new Vector3(heading.x, 0f, heading.y)), 0.999f, "turned with its heading");
+ Assert.That(shadow.lossyScale.x / span, Is.InRange(0.4f, 0.6f), "half as wide, about (narrower in a bank)");
+ }
+ }
+ }
+ finally { RenderSettings.sun = sunWas; Object.DestroyImmediate(sun.gameObject); }
+ }
+
+ /// <summary>#2482, option 1: "drops bombs with flashes and smoke on the city. Looks only; no change to the game's numbers."
+ /// Each Dakota releases a bomb every DakotaBombIntervalS of its loop while it is over Tel Aviv's hex, and only where the
+ /// bomb also lands on that hex: every release point and every impact point is on Tel Aviv's hex (by the map's own click
+ /// picker). A bomb falls from the aircraft's belly to the ground under the aircraft's track, faster as it falls; at the
+ /// impact a flash shows, then puffs of smoke rise there. Over two loops, every bomb, flash and puff drawn is over Tel Aviv's
+ /// hex; on the pass back (half a loop on) the lead draws none. Outside the window there is no Dakota, so nothing drops
+ /// (TwoDakotasFlyInTheWindowAndNoneOutsideIt).</summary>
+ [Test]
+ public void TheDakotasBombTelAvivAndOnlyTelAviv()
+ {
+ var map = OpenMap();
+ var (_, planes, loops, _) = DrawnDakotas(map);
+ float period = SeaAirCollection.DakotaLoopSeconds, fall = SeaAirCollection.DakotaBombFallS, every = SeaAirCollection.DakotaBombIntervalS;
+ var ground = PlacementLayer.CampGround(map);
+ for (int p = 0; p < planes.Length; p++)
+ {
+ var loop = loops[p]; var run = loop.Bombs;
+ Assert.IsNotNull(run, $"{planes[p].name} carries its bombs");
+ Assert.Greater(run!.Drops.Count, 1, $"{planes[p].name} drops bombs on its pass over Tel Aviv");
+ foreach (var d in run.Drops)
+ {
+ Assert.That(d.At, Is.InRange(0f, period), "a time of its loop");
+ Assert.AreEqual(0f, Mathf.Repeat(d.At / every + 0.5f, 1f) - 0.5f, 1e-3f, "on the release clock");
+ Assert.IsTrue(OnTelAviv(map, d.From), $"released over Tel Aviv at {d.At:0.0} s ({d.From})");
+ Assert.IsTrue(OnTelAviv(map, d.To), $"lands on Tel Aviv at {d.At:0.0} s ({d.To})");
+ Assert.Greater(d.From.y - d.To.y, 2000f, "dropped from the aircraft's belly at altitude");
+ Assert.AreEqual(ground.Y(d.To.x, d.To.z), d.To.y, 1f, "lands on the ground");
+ }
+ var first = run.Drops[0];
+ loop.Place(loop.Lag + first.At + 0.5f * fall);
+ var expect = Vector3.Lerp(first.From, first.To, 0.5f); expect.y = first.From.y - 0.25f * (first.From.y - first.To.y);
+ Assert.IsTrue(run.Bombs.Any(r => r.enabled && (r.transform.position - expect).magnitude < 1f), "half way through its fall a bomb is a quarter of the way down, falling faster");
+ loop.Place(loop.Lag + first.At + fall + 0.05f);
+ Assert.IsTrue(run.Flashes.Any(r => r.enabled && Xz(r.transform.position - first.To).magnitude < 1f), "a flash at the impact");
+ loop.Place(loop.Lag + first.At + fall + 1f);
+ Assert.IsTrue(run.Smoke.Any(r => r.enabled && Xz(r.transform.position - first.To).magnitude < SeaAirCollection.DakotaBombMarginM), "smoke rising at the impact");
+ Assert.IsTrue(run.Blasts.Any(r => r.enabled && Xz(r.transform.position - first.To).magnitude < 1f), "the blast at the impact");
+ loop.Place(loop.Lag + 0.5f * period);
+ Assert.IsFalse(run.Bombs.Concat(run.Flashes).Concat(run.Blasts).Concat(run.Smoke).Any(r => r.enabled), "no bomb, flash, blast or dust on the pass back, away from Tel Aviv");
+ Assert.IsTrue(run.Columns.Any(r => r.enabled), "the smoke columns still rising over Tel Aviv on the pass back (owner, 4 November 2026)");
+ int bombs = 0, flashes = 0, blasts = 0, smoke = 0, columns = 0;
+ for (int i = 0; i < 2400; i++)
+ {
+ float t = i * 2f * period / 2400f;
+ loop.Place(t);
+ foreach (var r in run.Bombs.Concat(run.Flashes).Concat(run.Blasts).Concat(run.Smoke).Concat(run.Columns))
+ {
+ if (!r.enabled) continue;
+ Assert.IsTrue(OnTelAviv(map, r.transform.position), $"{r.name} over Tel Aviv at {t:0.00} s ({r.transform.position})");
+ if (run.Bombs.Contains(r)) bombs++; else if (run.Flashes.Contains(r)) flashes++; else if (run.Blasts.Contains(r)) blasts++;
+ else if (run.Smoke.Contains(r)) smoke++; else columns++;
+ }
+ }
+ TestContext.WriteLine($"{planes[p].name}: {run.Drops.Count} drops a loop; {bombs} bomb, {flashes} flash, {blasts} blast, {smoke} dust "
+ + $"and {columns} column-puff frames over two loops");
+ Assert.Greater(bombs, 0); Assert.Greater(flashes, 0); Assert.Greater(blasts, 0); Assert.Greater(smoke, 0); Assert.Greater(columns, 0);
+ }
+ }
+
+ /// <summary>The owner, 4 November 2026, on the 15 May captures: "the explosions look bad in the screenshot and there is no
+ /// smoke columns coming up", then "it needs to look top quality" (Unity Labs' CC0 flipbooks approved). The blast plays
+ /// the explosion flipbook once over DakotaBlastS: it opens at DakotaBlastOpenShare of DakotaBlastM, swells to the full
+ /// size by a quarter of its life and on a little after, its frames run in order from the first to the last, and it fades
+ /// over its last DakotaBlastFadeShare to nothing; then it is gone.</summary>
+ [Test]
+ public void EachBlastPlaysTheExplosionFlipbookSwellingThenFading()
+ {
+ Assert.IsNotNull(Resources.Load<Texture2D>(SeaAirCollection.DakotaBlastTexture), "the explosion flipbook ships in Resources");
+ Assert.IsNotNull(Resources.Load<Texture2D>(SeaAirCollection.DakotaSmokeTexture), "the smoke flipbook ships in Resources");
+ Assert.AreEqual(SeaAirCollection.DakotaBlastOpenShare, DakotaBombRun.BlastSwell(0f), 1e-5f, "opens small");
+ Assert.AreEqual(1f, DakotaBombRun.BlastSwell(0.25f), 1e-5f, "full size by a quarter of its life");
+ for (float b = 0.01f; b <= 1f; b += 0.01f)
+ Assert.Greater(DakotaBombRun.BlastSwell(b), DakotaBombRun.BlastSwell(b - 0.01f) - 1e-6f, $"never shrinks ({b:0.00})");
+ Assert.AreEqual(1f, DakotaBombRun.BlastAlpha(1f - SeaAirCollection.DakotaBlastFadeShare - 0.01f), 1e-5f, "whole until its fade");
+ Assert.AreEqual(0f, DakotaBombRun.BlastAlpha(1f), 1e-5f, "gone at its end");
+
+ var map = OpenMap();
+ var (_, _, loops, _) = DrawnDakotas(map);
+ var loop = loops[0]; var run = loop.Bombs!; var first = run.Drops[0];
+ float impact = loop.Lag + first.At + SeaAirCollection.DakotaBombFallS, life = SeaAirCollection.DakotaBlastS;
+ int Here() { for (int s = 0; s < run.Blasts.Count; s++) if (run.Blasts[s].enabled && Xz(run.Blasts[s].transform.position - first.To).magnitude < 1f) return s; return -1; }
+ int lastFrame = -1; float lastSize = 0f;
+ foreach (float b in new[] { 0.02f, 0.15f, 0.3f, 0.6f, 0.9f, 0.99f })
+ {
+ loop.Place(impact + b * life);
+ int s = Here();
+ Assert.GreaterOrEqual(s, 0, $"the blast shows at the impact at {b:0.00} of its life");
+ var r = run.Blasts[s];
+ int frame = run.BlastFrame(s);
+ Assert.That(frame, Is.InRange(0, SeaAirCollection.DakotaBlastGrid * SeaAirCollection.DakotaBlastGrid - 1), "a frame of the flipbook");
+ Assert.Greater(frame, lastFrame, $"its frames run forward ({b:0.00})");
+ Assert.AreEqual(SeaAirCollection.DakotaBlastM * DakotaBombRun.BlastSwell(b), r.transform.localScale.x, 1f, $"its size at {b:0.00}");
+ Assert.GreaterOrEqual(r.transform.localScale.x, lastSize - 1e-3f, $"it never shrinks ({b:0.00})");
+ Assert.AreEqual(DakotaBombRun.BlastAlpha(b), DakotaBombRun.Colour(r).a, 1e-3f, $"its alpha at {b:0.00}");
+ Assert.Less(r.transform.position.y - 0.5f * r.transform.localScale.y, first.To.y + 1f, "its foot at or under the ground");
+ lastFrame = frame; lastSize = r.transform.localScale.x;
+ }
+ Assert.AreEqual(SeaAirCollection.DakotaBlastGrid * SeaAirCollection.DakotaBlastGrid - 1, lastFrame, "it ends on the flipbook's last frame");
+ loop.Place(impact + 0.02f * life); float early = DakotaBombRun.Colour(run.Blasts[Here()]).a;
+ loop.Place(impact + 0.99f * life); float late = DakotaBombRun.Colour(run.Blasts[Here()]).a;
+ Assert.Greater(early, 0.99f, "bright at the start"); Assert.Less(late, 0.05f, "all but gone at the end");
+ loop.Place(impact + life + 0.01f);
+ Assert.AreEqual(-1, Here(), "gone after its life");
+ }
+
+ /// <summary>The owner, 4 November 2026: "there is no smoke columns coming up". Each Dakota lights at most DakotaColumns
+ /// smoke columns over Tel Aviv, at impacts of its own (the pair at most twice that, never two on one spot), each made of
+ /// DakotaColumnPuffs puffs. A column shows nothing before its first hit; after it, it grows from the ground (its top
+ /// higher a few seconds later), and from one DakotaColumnLife on it stands whole: every puff showing, its top near
+ /// DakotaColumnM up, wider aloft than at its foot, leaning downwind (east) less than DakotaBombMarginM, so it stays over
+ /// Tel Aviv's hex. It stays through the pass back and the next loops (as long as the Dakotas fly). The same time draws
+ /// the same column.</summary>
+ [Test]
+ public void TheBombsLightSmokeColumnsThatGrowThenStandOverTelAviv()
+ {
+ var map = OpenMap();
+ var (_, planes, loops, _) = DrawnDakotas(map);
+ float period = SeaAirCollection.DakotaLoopSeconds, life = SeaAirCollection.DakotaColumnLifeS;
+ int P = SeaAirCollection.DakotaColumnPuffs;
+ var all = new List<Vector3>();
+ for (int p = 0; p < planes.Length; p++)
+ {
+ var loop = loops[p]; var run = loop.Bombs!;
+ int sites = run.ColumnSites.Count;
+ Assert.That(sites, Is.InRange(1, SeaAirCollection.DakotaColumns), $"{planes[p].name} lights one to {SeaAirCollection.DakotaColumns} columns");
+ Assert.AreEqual(sites * P, run.Columns.Count, "a pool of puffs for each column, no more");
+ foreach (var site in run.ColumnSites)
+ {
+ Assert.IsTrue(run.Drops.Any(d => (d.To - site).magnitude < 1e-3f), "each column stands where a bomb lands");
+ Assert.IsTrue(all.All(o => Xz(o - site).magnitude > 1f), "never two columns on one spot");
+ all.Add(site);
+ }
+ for (int c = 0; c < sites; c++)
+ {
+ var site = run.ColumnSites[c]; float from = (float)run.ColumnFrom(c);
+ IEnumerable<Renderer> Puffs() => run.Columns.Skip(c * P).Take(P);
+ float Top() => Puffs().Where(r => r.enabled).Select(r => r.transform.position.y - site.y).DefaultIfEmpty(0f).Max();
+ loop.Place(loop.Lag + from - 0.5f);
+ Assert.IsFalse(Puffs().Any(r => r.enabled), $"{planes[p].name} column {c}: nothing before its first hit");
+ loop.Place(loop.Lag + from + 2f); float young = Top();
+ Assert.IsTrue(Puffs().Any(r => r.enabled), "it rises from its first hit");
+ Assert.Less(young, 0.5f * SeaAirCollection.DakotaColumnM, "low at first");
+ loop.Place(loop.Lag + from + 8f); float older = Top();
+ Assert.Greater(older, young + 1000f, "it grows upward");
+ foreach (float later in new[] { 1.5f * life, 0.5f * period, period + 3f, 3f * period + 7.5f })
+ {
+ loop.Place(loop.Lag + from + later);
+ var on = Puffs().Where(r => r.enabled).ToList();
+ Assert.AreEqual(P, on.Count, $"whole {later:0.0} s after its first hit");
+ var top = on.OrderBy(r => r.transform.position.y).Last(); var foot = on.OrderBy(r => r.transform.position.y).First();
+ Assert.Greater(top.transform.position.y - site.y, 0.7f * SeaAirCollection.DakotaColumnM, "standing tall");
+ Assert.Greater(top.transform.localScale.x, foot.transform.localScale.x, "wider aloft");
+ Assert.Greater(Vector3.Dot(top.transform.position - site, new Vector3(0.94f, 0f, 0.34f)), 100f, "its top leans downwind (east)");
+ foreach (var r in on)
+ {
+ Assert.Less(Xz(r.transform.position - site).magnitude, SeaAirCollection.DakotaBombMarginM, "it leans less than the margin");
+ Assert.IsTrue(OnTelAviv(map, r.transform.position), $"over Tel Aviv ({r.transform.position})");
+ Assert.That(run.ColumnFrame(run.Columns.ToList().IndexOf(r)), Is.InRange(0, SeaAirCollection.DakotaSmokeGrid * SeaAirCollection.DakotaSmokeGrid - 1), "a smoke flipbook frame");
+ }
+ }
+ // The same time draws the same column.
+ float t = loop.Lag + from + 41.3f;
+ loop.Place(t); var a = Puffs().Select(r => (r.transform.position, r.transform.localScale, DakotaBombRun.Colour(r))).ToList();
+ loop.Place(t + 17f); loop.Place(t); var b = Puffs().Select(r => (r.transform.position, r.transform.localScale, DakotaBombRun.Colour(r))).ToList();
+ CollectionAssert.AreEqual(a, b, "a pure function of the loop's clock");
+ }
+ }
+ Assert.LessOrEqual(all.Count, SeaAirCollection.DakotaColumns * planes.Length, "capped");
+ TestContext.WriteLine($"{all.Count} smoke columns over Tel Aviv");
+ }
+
+ /// <summary>Sampling the bombs, blasts, dust and columns, and turning them to a camera, allocates nothing (DakotaBombRun),
+ /// as the gun's shot (UnitGunFireTests).</summary>
+ [Test]
+ public void SamplingTheBombRunAllocatesNothing()
+ {
+ var map = OpenMap();
+ var (_, _, loops, _) = DrawnDakotas(map);
+ var run = loops[0].Bombs!; var view = Quaternion.Euler(50f, 0f, 0f);
+ float t = run.Drops[0].At;
+ TestDelegate frames = () => { for (int i = 0; i < 200; i++) { t += 0.05f; run.Sample(t); run.Face(view); } };
+ frames(); // Mono JIT-compiles the delegate on its first call (UnitGunFireTests)
+ t = run.Drops[0].At;
+ Assert.That(frames, UnityEngine.TestTools.Constraints.Is.Not.AllocatingGCMemory());
+ // The measured frames ran from the first release through ten seconds of the loop; half a second after the first
+ // impact, inside them, a blast, dust and a column were showing.
+ run.Sample(run.Drops[0].At + SeaAirCollection.DakotaBombFallS + 0.5f);
+ Assert.IsTrue(run.Blasts.Any(r => r.enabled) && run.Smoke.Any(r => r.enabled) && run.Columns.Any(r => r.enabled), "the measured frames drew blasts, dust and columns");
+ }
+
+ /// <summary>#2482's margin at its edge (review of #2490): OnDakotaTarget refuses a point 1 m short of
+ /// DakotaBombMarginM inside Tel Aviv's hex and accepts one 1 m past it, so dropping its edge check turns this red.</summary>
+ [Test]
+ public void ABombPointOneMetreShortOfTheMarginIsOffTheTargetAndOneMetrePastItIsOn()
+ {
+ var map = OpenMap();
+ var ground = PlacementLayer.CampGround(map);
+ float size = ground.HexSizeM, inradius = 0.5f * Mathf.Sqrt(3f) * size;
+ var h = C.SettlementHexes.First(x => x.Id == SeaAirCollection.DakotaTown);
+ var centre = HexGrid.Centre(h.Q, h.R, size);
+ var targets = new List<Vector2> { Xz(HexGrid.ToWorld(centre, ground.TerrainOrigin, ground.Length)) };
+ // Due east of the centre the nearest side is the flat east side, so a point d metres east is inradius - d inside it.
+ Vector2 At(float inside) => Xz(HexGrid.ToWorld(centre + new Vector2(inradius - inside, 0f), ground.TerrainOrigin, ground.Length));
+ Assert.IsFalse(SeaAirCollection.OnDakotaTarget(ground, targets, At(SeaAirCollection.DakotaBombMarginM - 1f)), "1 m short of the margin");
+ Assert.IsTrue(SeaAirCollection.OnDakotaTarget(ground, targets, At(SeaAirCollection.DakotaBombMarginM + 1f)), "1 m past the margin");
+ }
+
+ /// <summary>#2482's margin, checked on its own (review of #2490): every bomb's release point and impact point lies at
+ /// least SeaAirCollection.DakotaBombMarginM inside the edge of one of Tel Aviv's hexes, so the smoke's drift stays on the
+ /// hex. The distance is measured here from the hex's own six corners (pointy-top, circumradius the map's hex size, as
+ /// tools/hexgrid.py lays them), as the point's distance to the nearest of the six sides, with the point inside all six;
+ /// it does not call the layer's own OnDakotaTarget.</summary>
+ [Test]
+ public void EveryDakotaBombIsReleasedAndLandsAtLeastTheMarginInsideTelAvivsHex()
+ {
+ // Pinned, so lowering the constant cannot weaken the code and this test together.
+ Assert.AreEqual(600f, SeaAirCollection.DakotaBombMarginM, "the bombs fall at least 600 m inside Tel Aviv's hex");
+ var map = OpenMap();
+ var (_, planes, loops, _) = DrawnDakotas(map);
+ var ground = PlacementLayer.CampGround(map);
+ float size = ground.HexSizeM;
+ var hexes = new List<Vector2[]>();
+ foreach (var h in C.SettlementHexes.Where(x => x.Id == SeaAirCollection.DakotaTown))
+ {
+ var centre = HexGrid.Centre(h.Q, h.R, size);
+ var corners = new Vector2[6];
+ for (int k = 0; k < 6; k++)
+ {
+ float a = (60f * k - 30f) * Mathf.Deg2Rad;
+ corners[k] = Xz(HexGrid.ToWorld(centre + size * new Vector2(Mathf.Cos(a), Mathf.Sin(a)), ground.TerrainOrigin, ground.Length));
+ }
+ hexes.Add(corners);
+ }
+ Assert.Greater(hexes.Count, 0, "premise: Tel Aviv has its hex");
+ // Inside a convex polygon: on the same side of every side; then the distance to the nearest side. Negative outside.
+ float Inside(Vector2[] corners, Vector2 p)
+ {
+ float sign = 0f, nearest = float.MaxValue;
+ for (int k = 0; k < 6; k++)
+ {
+ Vector2 a = corners[k], b = corners[(k + 1) % 6], ab = b - a;
+ float cross = ab.x * (p.y - a.y) - ab.y * (p.x - a.x);
+ if (sign == 0f) sign = Mathf.Sign(cross);
+ else if (Mathf.Sign(cross) != sign) return -1f;
+ float t = Mathf.Clamp01(Vector2.Dot(p - a, ab) / ab.sqrMagnitude);
+ nearest = Mathf.Min(nearest, (p - (a + t * ab)).magnitude);
+ }
+ return nearest;
+ }
+ float closest = float.MaxValue; int points = 0;
+ for (int p = 0; p < planes.Length; p++)
+ {
+ var run = loops[p].Bombs;
+ Assert.IsNotNull(run, $"{planes[p].name} carries its bombs");
+ Assert.Greater(run!.Drops.Count, 0, $"{planes[p].name} drops bombs");
+ foreach (var d in run.Drops)
+ foreach (var (what, at) in new[] { ("release", d.From), ("impact", d.To) })
+ {
+ float inside = hexes.Max(corners => Inside(corners, Xz(at)));
+ Assert.GreaterOrEqual(inside, SeaAirCollection.DakotaBombMarginM,
+ $"{planes[p].name}'s {what} at {d.At:0.0} s ({at}) is {inside:0} m inside Tel Aviv's hex edge");
+ closest = Mathf.Min(closest, inside); points++;
+ }
+ }
+ TestContext.WriteLine($"{points} release and impact points; the nearest is {closest:0} m inside the hex's edge (margin {SeaAirCollection.DakotaBombMarginM:0} m)");
+ }
+
+ /// <summary>Egypt's flag as the owner ruled for the Spitfire on #2260 ("Smaller flag, no pole"): on each Dakota the cloth alone,
+ /// in Egypt's sourced colours, half the tokens' flag size, floating over the tail and clear above the aircraft at every
+ /// point of its loop (banked or not), turned to the camera, and gone with the aircraft. Changed from #2274's test: both
+ /// aircraft are checked, each on its own clock, and both keys are gone after the window.</summary>
+ [Test]
+ public void TheDakotasFlyEgyptsFlagOverTheirTailsWithNoPole()
+ {
+ var map = OpenMap();
+ var (layer, planes, loops, _) = DrawnDakotas(map);
var colours = Statecraft.Game.Map.Units.UnitFlags.Colours(Statecraft.Game.Map.Units.UnitFlags.Egypt);
- Assert.AreEqual(colours.Count, mesh.subMeshCount, "the cloth's colours only: no pole submesh");
- var mats = flag.GetComponent<MeshRenderer>().sharedMaterials;
- Assert.AreEqual(colours.Count, mats.Length, "one material a cloth colour");
- for (int i = 0; i < mats.Length; i++)
- Assert.Less(Vector4.Distance(colours[i], mats[i].color), 1e-4f, $"Egypt's sourced colour {i}");
- Assert.AreEqual(SeaAirCollection.DakotaFlagScale * Statecraft.Game.Map.Units.UnitBadge.FigureHeightM * Statecraft.Game.Map.Units.UnitShowcase.FigureScale,
- flag.lossyScale.y, 1f, "half the tokens' flag size");
- Assert.Less(mesh.bounds.size.y, 0.6f * Statecraft.Game.Map.Units.UnitFlags.PoleHeight, "no pole: the cloth alone");
- for (int i = 0; i < 24; i++)
+ for (int p = 0; p < planes.Length; p++)
{
- float t = i * SeaAirCollection.DakotaLoopSeconds / 24f;
- loop.Place(t);
- var b = WorldBounds(plane.gameObject); var fb = flag.GetComponent<MeshRenderer>().bounds;
- Assert.Greater(fb.min.y, b.max.y, $"the flag floats clear above the aircraft at {t:0.0} s");
- var back = -new Vector3(SeaAirCollection.DakotaLoopHeading(t).x, 0f, SeaAirCollection.DakotaLoopHeading(t).y);
- Assert.Greater(Vector3.Dot(flag.position - b.center, back), 0.3f * b.extents.x, $"over the tail, behind the centre, at {t:0.0} s");
+ var loop = loops[p]; var plane = planes[p];
+ var flag = loop.Flag;
+ Assert.IsNotNull(flag, "a flag over the aircraft");
+ Assert.IsNotNull(flag!.GetComponent<Statecraft.Game.Map.Units.UnitFlagFacing>(), "turned to the camera, as the tokens' flags");
+ var mesh = flag.GetComponent<MeshFilter>().sharedMesh;
+ Assert.AreEqual(colours.Count, mesh.subMeshCount, "the cloth's colours only: no pole submesh");
+ var mats = flag.GetComponent<MeshRenderer>().sharedMaterials;
+ Assert.AreEqual(colours.Count, mats.Length, "one material a cloth colour");
+ for (int i = 0; i < mats.Length; i++)
+ Assert.Less(Vector4.Distance(colours[i], mats[i].color), 1e-4f, $"Egypt's sourced colour {i}");
+ Assert.AreEqual(SeaAirCollection.DakotaFlagScale * Statecraft.Game.Map.Units.UnitBadge.FigureHeightM * Statecraft.Game.Map.Units.UnitShowcase.FigureScale,
+ flag.lossyScale.y, 1f, "half the tokens' flag size");
+ Assert.Less(mesh.bounds.size.y, 0.6f * Statecraft.Game.Map.Units.UnitFlags.PoleHeight, "no pole: the cloth alone");
+ for (int i = 0; i < 24; i++)
+ {
+ float t = i * SeaAirCollection.DakotaLoopSeconds / 24f;
+ loop.Place(t);
+ var b = WorldBounds(plane.gameObject); var fb = flag.GetComponent<MeshRenderer>().bounds;
+ Assert.Greater(fb.min.y, b.max.y, $"the flag floats clear above the aircraft at {t:0.0} s");
+ var h = SeaAirCollection.DakotaLoopHeading(t - loop.Lag);
+ Assert.Greater(Vector3.Dot(flag.position - b.center, -new Vector3(h.x, 0f, h.y)), 0.3f * b.extents.x, $"over the tail, behind the centre, at {t:0.0} s");
+ }
+ var fbNow = flag.GetComponent<MeshRenderer>().bounds; var keepNow = DakotaKeepOf(layer, plane.gameObject)!.Value;
+ Assert.IsTrue(keepNow.Contains(fbNow.min) && keepNow.Contains(fbNow.max), "the labels keep clear of the flag too, where it is now");
}
- Assert.AreEqual(1, layer.KeepClear.Count(k => k[0].Contains(flag.GetComponent<MeshRenderer>().bounds.center)), "the labels keep clear of the flag too");
CollectionGeometryFixture.Craft(map, new DateTime(1948, 6, 15), Array.Empty<Placement>(), C);
AnswerAll();
- Assert.IsNull(layer.transform.Find(SeaAirCollection.DakotaKey), "no Dakota after its window");
- Assert.IsNull(layer.transform.Find(SeaAirCollection.DakotaKey + SeaAirCollection.DakotaMarksSuffix), "its flag goes with it");
+ foreach (var k in SeaAirCollection.DakotaKeys)
+ {
+ Assert.IsNull(layer.transform.Find(k), $"no {k} after its window");
+ Assert.IsNull(layer.transform.Find(k + SeaAirCollection.DakotaMarksSuffix), "its flag, shadow and bombs go with it");
+ }
Assert.AreEqual(0, Object.FindObjectsByType<DakotaLoop>(FindObjectsInactive.Include, FindObjectsSortMode.None).Length);
}
@@ -855,29 +1478,32 @@ public class SeaAirCollectionTests
return layer;
}
- /// <summary>The Dakota's keep-clear box survives a retirement, as every other craft's does (#2274 merged with main's per-object
- /// boxes): FlyDakota keeps it by object, so ClearForRetirement's rebuild from those boxes keeps it. The retirement here is
- /// degenerate (an empty key set: no craft whose window ends inside the Dakota's, 15 May to 11 June 1948, was found), and it
- /// runs exactly that rebuild.</summary>
+ /// <summary>The Dakotas' keep-clear boxes survive a retirement, as every other craft's do (#2274 merged with main's per-object
+ /// boxes): FlyDakota keeps each by object, so ClearForRetirement's rebuild from those boxes keeps them. The retirement here
+ /// is degenerate (an empty key set: no craft whose window ends inside the Dakotas', 15 May to 11 June 1948, was found), and
+ /// it runs exactly that rebuild. Changed for #2482: both aircraft's boxes, by their two keys, where #2274 had one.</summary>
[Test]
public void ARetirementKeepsTheDakotasKeepClearBox()
{
var map = OpenMap();
var layer = DrawnLayer(map, new DateTime(1948, 5, 15));
var keepOf = (System.Collections.IDictionary)typeof(SeaAirCollection).GetField("keepOf", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)!.GetValue(layer)!;
- Assert.IsTrue(layer.Placed.Any(p => p.Model == SeaAirCollection.Dakota), "premise: the Dakota is drawn");
- Assert.AreEqual(layer.Placed.Count, keepOf.Count, "one keep-clear entry a drawn craft, the Dakota's included");
- var dakota = layer.transform.Find(SeaAirCollection.DakotaKey)!.gameObject;
+ Assert.AreEqual(2, layer.Placed.Count(p => p.Model == SeaAirCollection.Dakota), "premise: both Dakotas are drawn");
+ Assert.AreEqual(layer.Placed.Count, keepOf.Count, "one keep-clear entry a drawn craft, each Dakota's included");
+ var dakotas = SeaAirCollection.DakotaKeys.Select(k => layer.transform.Find(k)!.gameObject).ToList();
var retire = typeof(SeaAirCollection).GetMethod("ClearForRetirement", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic,
null, new[] { typeof(IReadOnlyCollection<(string id, CollectionDetail detail)>) }, null)!;
retire.Invoke(layer, new object[] { Array.Empty<(string id, CollectionDetail detail)>() });
- Assert.IsTrue(layer.KeepClear.Any(b => ReferenceEquals(b, keepOf[dakota])), "the Dakota's box is still kept clear");
+ foreach (var dakota in dakotas) Assert.IsTrue(layer.KeepClear.Any(b => ReferenceEquals(b, keepOf[dakota])), $"{dakota.name}'s box is still kept clear");
Assert.AreEqual(layer.Placed.Count, layer.KeepClear.Count);
}
- /// <summary>#2351's allocation-free residency fill with #2274's Dakota in it: the Dakota's anchor is the ground under its
- /// loop's centre (never the Tel Aviv coast point its row names), with its wingspan as radius; filling allocates nothing
- /// once warm; and the fill runs only when the view's policy lets a camera scan, so the Dakota is resident only close up.</summary>
+ /// <summary>#2351's allocation-free residency fill with the Dakotas in it: each Dakota's anchor is the ground under its
+ /// loop's centre (never the Tel Aviv coast point its row names); filling allocates nothing once warm; and the fill runs
+ /// only when the view's policy lets a camera scan, so the Dakotas are resident only close up. Changed for #2482: one anchor
+ /// a Dakota (two), and its radius is its swept half-box's diagonal (DakotaSweptHalf), not its wingspan, because the loop
+ /// over Tel Aviv is now far wider than the aircraft (the pair must fly it apart), so an aircraft can be that far from the
+ /// centre.</summary>
[Test]
public void TheDakotasResidencyAnchorIsItsLoopCentreOnlyWhenScannedAndAllocatesNothing()
{
@@ -893,13 +1519,16 @@ public class SeaAirCollectionTests
var centre = (Vector2?)typeof(SeaAirCollection).GetMethod("DakotaCentre", flags)!.Invoke(layer, null);
Assert.IsTrue(centre.HasValue, "premise: the Dakota's loop has a centre on this map");
var c = centre!.Value;
- var dakota = list.Where(a => a.key == SeaAirCollection.DakotaKey).ToList();
- Assert.AreEqual(1, dakota.Count, "one anchor for the Dakota");
- Assert.Less((dakota[0].at - new Vector3(c.x, 0f, c.y)).magnitude, 1e-3f, "on the ground under its loop's centre");
- Assert.AreEqual(SeaAirCollection.SizeOf(SeaAirCollection.Dakota), dakota[0].radius, 1e-4f, "its wingspan");
+ var dakota = list.Where(a => SeaAirCollection.DakotaKeys.Contains(a.key)).ToList();
+ CollectionAssert.AreEqual(SeaAirCollection.DakotaKeys, dakota.Select(a => a.key), "one anchor a Dakota");
+ foreach (var a in dakota)
+ {
+ Assert.Less((a.at - new Vector3(c.x, 0f, c.y)).magnitude, 1e-3f, "on the ground under its loop's centre");
+ Assert.AreEqual(SeaAirCollection.DakotaSweptHalf.magnitude, a.radius, 1e-2f, "the reach of its loop");
+ }
var coast = SeaCraft.Coasts.Single(x => x.place == SeaAirCollection.DakotaTown);
var coastAt = map.Frame.ToWorld(coast.lon, coast.lat, 0);
- Assert.IsFalse(list.Any(a => a.key == SeaAirCollection.DakotaKey && (a.at - coastAt).magnitude < 1f), "not at the Tel Aviv coast point");
+ Assert.IsFalse(dakota.Any(a => (a.at - coastAt).magnitude < 1f), "not at the Tel Aviv coast point");
TestDelegate hundredFills = () => { for (int i = 0; i < 100; i++) { list.Clear(); fill(list); } };
hundredFills(); // once unmeasured: the JIT, as #2351's test does
@@ -913,11 +1542,11 @@ public class SeaAirCollectionTests
camera.transform.SetPositionAndRotation(new Vector3(c.x, 1000f, c.y), Quaternion.Euler(90f, 0f, 0f));
for (int frame = 0; frame < 3; frame++) view.Observe(camera, counted, frame);
Assert.AreEqual(0, fills, "a camera above the view height fills no anchors");
- Assert.IsFalse(view.Keys.Contains(SeaAirCollection.DakotaKey));
+ Assert.IsFalse(SeaAirCollection.DakotaKeys.Any(view.Keys.Contains));
camera.transform.SetPositionAndRotation(new Vector3(c.x, 10f, c.y), Quaternion.Euler(90f, 0f, 0f));
for (int frame = 3; frame < 8; frame++) view.Observe(camera, counted, frame);
Assert.AreEqual(5, fills, "a close camera fills the anchors once a frame");
- Assert.IsTrue(view.Keys.Contains(SeaAirCollection.DakotaKey), "the Dakota is resident close up");
+ Assert.IsTrue(SeaAirCollection.DakotaKeys.All(view.Keys.Contains), "both Dakotas are resident close up");
int next = 8;
TestDelegate hundredFrames = () => { for (int i = 0; i < 100; i++) { view.Observe(camera, counted, next); view.Prune(next); next++; } };
hundredFrames();
diff --git a/unity/Assets/Tests/EditMode/TalModelsShots.cs b/unity/Assets/Tests/EditMode/TalModelsShots.cs
index d6c71b0f1..fc2cd4f2e 100644
--- a/unity/Assets/Tests/EditMode/TalModelsShots.cs
+++ b/unity/Assets/Tests/EditMode/TalModelsShots.cs
@@ -236,7 +236,8 @@ public class TalModelsShots
SeaAirCollection.Request = Answer(Array.Empty<string>());
Drop(map, SeaAirCollection.Name);
var layer = CollectionGeometryFixture.Craft(map, state.Date, state.Placements, content)!;
- var plane = layer.Placed.Single(p => p.Model == SeaAirCollection.Dakota);
+ // #2482: two Dakotas fly one loop, so both carry its centre; the lead's is the one to aim at.
+ var plane = layer.Placed.First(p => p.Model == SeaAirCollection.Dakota);
if (!after)
{
SeaAirCollection.Request = Answer(new[] { SeaAirCollection.Dakota });