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: an opt-in Civilization-style hex-tile map (?hex-tiles), presentation only (refs #18) (#1120)

pixelrenderai-hashc5771d9e83ff
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2eccad0bc..2483a6563 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
### Added
+- An opt-in Civilization-style hex-tile map (`?hex-tiles`, desktop `-hex-tiles`; `?hex-tiles=tel_aviv_crop` for the
+ Tel Aviv crop): one-file hex prototypes (towns, orchards, fields, forests, hills), units as their own layer, painted
+ ground, a landscape ring round the play hexes and a warmer light while it is on. Presentation only; off by default,
+ the shipped map is unchanged. Its models are local until their assets clear, so other machines draw stand-ins
+ (docs/hex-tiles/README.md; refs #18).
- The Cabinet disc in the side menu shows a small gold badge while a post is vacant that the player can fill this turn,
and its tip says so in English and Hebrew. The sim's `Cabinet.Vacancies` decides it (a vacant seat, someone may be
appointed, no appointment to it queued, the game not over, and enough Attention left after this turn's queued orders,
@@ -15,6 +20,12 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
- Unit cards show the sourced Hebrew unit name in the Hebrew UI, with an English fallback. INS Haganah gains its
sourced Hebrew name, still flagged for a native speaker's review (#902).
### Fixed
+- Keep the opt-in hex terrain overlay out of automatic neighboring with the real map terrain.
+- Keep the capsule-collider dependency used while creating hex unit stand-ins in stripped player builds; the temporary collider is still removed.
+- Missing unit models on the opt-in hex-tile map use an owned copy of the shipped material in player builds.
+- The opt-in hex-tile map regenerates cached stand-in meshes released by an editor scene change.
+- The opt-in hex-tile map preserves settlement marker visibility when removed or rebuilt, and missing vehicle models
+ keep their declared box stand-in and footprint size.
- The Cabinet, Budget, Defence, Why, How to play and Settings screens each gain an X in the header that closes
them (the same close as Escape): a phone has no Escape key, and re-tapping the lit rail button was the only way
out (v0.1.1 playtest feedback).
diff --git a/docs/hex-tiles/CIV-LAYERS-AND-TEAM-PLAN.md b/docs/hex-tiles/CIV-LAYERS-AND-TEAM-PLAN.md
new file mode 100644
index 000000000..2aa12e06e
--- /dev/null
+++ b/docs/hex-tiles/CIV-LAYERS-AND-TEAM-PLAN.md
@@ -0,0 +1,220 @@
+# Civ layers and the team plan for hex tiles
+
+Status: a design proposal from Tal (lead designer). It decides nothing: Tal proposes visual changes, and the project
+owner approves design changes. The hex tiles are presentation only. Runtime code lives under
+`unity/Assets/Scripts/Map/HexTiles/`; editor helpers and tests live under `unity/Assets/Editor/HexTiles/`.
+The runtime map is opt-in and off by default, so the shipped default look and simulation goldens stay unchanged.
+
+Read with `docs/hex-tiles/README.md` (the contributor contract). Scale reminder: `HexScale.HexM` = 5,000 m is the hex
+circumradius (`content/map/hexes.json` `hex_size_km: 5.0`), so a hex is about 8.7 km flat to flat. One hex is a whole
+landscape: the Bauhaus "White City" is one hex, and the Tel Aviv to Jerusalem road, from (-3,19) to (0,23), is 7 hexes.
+
+State of the working tree on 18 October, evening: `Core/` is being extended now, uncommitted. It has gained
+`ctx.PaintGround` and `ctx.PaintStroke` (ground painted into the splat), the crop layers `wheat`, `green_crop`,
+`ploughed` and `dirt`, and board-level `roads` (hex centre to hex centre, painted dirt) and `rivers` (along hex
+corners, carved as a channel). The tables below count these as "in progress".
+
+## 1. Civ's layer model, mapped to ours
+
+Civ stacks a hex in layers. Civ VI has terrain, then a hills or mountain modifier, a feature, a resource, an
+improvement or district, routes, rivers on edges, borders and units. Civ VII renames base terrain as *biome*
+(grassland, plains, tropical, desert, tundra, marine) and keeps the terrain types (flat, rough, mountainous, water). It
+also moves rivers into tiles: minor rivers, plus navigable rivers that fill whole tiles. Settlements grow onto rural
+tiles (improvements) and urban districts, and an urban district with two buildings becomes a *quarter*.
+
+| Civ layer | Civ examples | Ours today | Status | 1948 examples |
+|---|---|---|---|---|
+| Base terrain / biome | grassland, plains, desert, coast | `BoardHex.ground` (grass, plains, hills, mountain, desert, beach, seabed); `hexes.json` `biome` (7 kinds) | Have (needs a biome mapping, see WP9) | Coastal plain = `plains`; Negev = `desert` |
+| Terrain modifier | flat, hills, mountain | `BoardHex.terrain` = `HexTerrain` Flat/Hills/Mountain/Water | Have | Judean hills at Jerusalem (0,23) = hills, 689 m |
+| Water | coast, ocean, lake | `terrain: water`, `seabed`, shore beach painted automatically | Have | Mediterranean; Sea of Galilee and the Dead Sea (`lake`, 16 hexes) |
+| Feature | woods, rainforest, marsh, floodplain, oasis | Drawn as a whole-hex `prototype` (`pine_forest`, `coastal_dunes`) | Partly: no separate field, so a hex can't be both "forest" and "village" | JNF pine forests; Hula swamp (marsh); Jordan floodplain; Ein Gedi (oasis) |
+| Resource | wheat, fish, iron, citrus | Nothing | Missing | Jaffa oranges; Dead Sea potash; fish at Jaffa and Acre; Negev sheep |
+| Improvement / rural tile | farm, mine, pasture, plantation, camp, fishing boats | `prototype` art (`wheat_fields`, `grazing_land`, `citrus_orchard`) plus `PaintGround` crop layers | Have (as art) | Kibbutz fields; citrus plantations at Petah Tikva; Dead Sea Works as a mine |
+| District / urban quarter | campus, harbour; VII quarters | `prototype` (`tel_aviv_city`, `moshava_village`, `arab_village`) | Have (one per hex) | Bauhaus White City; Jaffa port; Jerusalem Old City |
+| Settlement | city centre | `content/map/settlements_1948.yaml` and `settlement_hexes.yaml` (owned by the sim) | Have, in the sim | Tel Aviv, Haifa, Jerusalem |
+| River | VI: on edges; VII: minor in tile, navigable fills the tile | `BoardRiver`, along hex corners, carved channel | In progress (Civ VI style) | Yarkon (north edge of Tel Aviv), Kishon (Haifa bay), Jordan |
+| Road / railroad | road, railroad | `BoardRoad`, centre to centre, painted dirt | In progress; no railway | Tel Aviv to Jerusalem road via Bab al-Wad; Jaffa to Jerusalem railway; coastal road; the Burma Road (June 1948) |
+| Borders / territory | coloured border on owner edges | Nothing (`owner` missing) | Missing | Yishuv, Arab, Transjordan and Egypt control; British Mandate until 15 May |
+| Units | VI: one military plus one civilian; VII: commanders pack armies | `BoardHex.unit` plus `facing`, one per hex, own layer (`HexUnitMotion`) | Have (one slot) | `palmach_squad`, `sandwich_truck`, `willys_jeep` |
+| Yields | food, production, gold icons | Nothing on the board | Missing, and should stay in the sim | Citrus exports, housing, morale (`MapActions`) |
+
+**Open contract issues to raise as issues (not to fix in a package):**
+- **Unit sizes disagree.** README says 0.26 / 0.15 / 0.48 S. Code (`HexUnitScale`) says 0.30 / 0.22 / 0.50 S.
+- **Squad size disagrees.** The `HexScale.FigureMin` comment says "3 to 7 to a unit", but `HexUnitScale.Characters` = 8.
+- **Settlements share hexes.** `settlement_hexes.yaml` puts Tel Aviv and Jaffa in one hex (-3,19), and also Lod with
+ Ramla and Rishon LeZion with Rehovot. On the real map, a Jaffa prototype can't sit beside the Tel Aviv one. Tal's
+ options: a mixed prototype, a board-only exception, or sub-hex quarters.
+- **Features have no field.** There is no separate feature or resource field. Today the prototype is the feature.
+
+## 2. Visual rules that make the map feel connected
+
+Civ hexes read as one thing each and still form one landscape. The rules for our renderer, with what exists:
+
+| Rule | How, in our renderer | Status |
+|---|---|---|
+| **Ground is painted, not placed** | Fields, sand, yards and tracks go into the terrain splat (`ctx.PaintGround/PaintStroke`), not `PlaceFlat` slabs. Slabs flicker when co-planar and fail on slopes. Ground layers blend across edges (weights 0.75 to 0.95 of S) | Have; move remaining fields to paint |
+| **Shape follows the hex** | `HexBoardSurface` per-hex profiles blended over 0.5 to 1.12 S: hills round off, coasts soften | Have |
+| **Features thin out toward the edge** | Dense in the middle, sparse near the inset (0.07 S), so two forest hexes meet as one forest. A later contract option: a read-only `ctx.Neighbour(dir)` so a tile can spill toward a like neighbour | Prototype habit now; neighbour query = contract change |
+| **Roads and rivers are board layers** | Drawn once by the builder as continuous lines (roads through centres, rivers on corners), never by a prototype. Prototypes leave a corridor so a road isn't hidden | In progress |
+| **Units are a separate layer** | Never in a tile. `HexScale.UnitSpotShare` 0.3 S keeps tall pieces off the centre. Units are larger than buildings | Have |
+| **Faint hex lines** | `HexBoardEdges`: a pale ribbon draped on land edges. Keep it faint; fade it out at close zoom | Have |
+| **Territory borders** | A coloured ribbon inset on the owner's side, only where two owners meet. A softer wash fills inside. Drawn like the edges | Missing (needs `owner`) |
+| **Resources read as a small icon plus one piece** | A 2D pin above the hex plus one modest model (orange crates, a fishing boat). The icon carries the meaning at map zoom | Missing |
+| **One scale, one sun** | `HexScale` shares for every piece. One lighting rig in the captures. No tile brings its own light | Have |
+| **Stand-ins must read** | Every tile and unit must read in stand-ins alone. Most machines lack the pending-rights models | Rule |
+
+On rivers, the current code follows Civ VI (on edges). Civ VII's in-tile rivers would fit "one hex, one job" better: a
+river hex is its own feature. Edge rivers fit "crossing a river costs movement" better. Tal should pick one. The data
+format is the only part that is costly to change later.
+
+## 3. Gameplay mechanics: the owner's rulings, and what the hex tiles must show
+
+Movement and stacking are decided on `main`, in `docs/gdd/military-combat.md` (`Q-MOVE-1` to `Q-MOVE-5`, 15 October
+2026). The values are labelled design values in `content/rules.yaml`, set in the implementing PRs (#1071, #1073). The
+hex tiles only show the sim's result and never decide a rule. Movement costs are keyed on the content `biome`, never
+on the presentation `HexTerrain`.
+
+What the tiles must show:
+- **Costs (`Q-MOVE-1`):** integer movement points per unit type against an integer cost per biome. Lakes and the sea
+ are impassable. A cost overlay, if wanted, reads the sim's values.
+- **Roads (`Q-MOVE-2`):** only a *built corridor road* lowers its hex's cost. Board roads are drawn for every period,
+ so the look must tell a built corridor road from an ordinary track.
+- **Stacking (`Q-MOVE-3`):** a stacking limit per side per hex; #1073 proposes 3. The units layer must therefore draw
+ **up to three units in one hex**. Today one 8-figure wedge fills it, so three smaller formations or offset spots are
+ a contract change (`units[]` on the board hex). Entering a hex an enemy unit holds is an attack.
+- **No zone of control (`Q-MOVE-4`) and no transport or embarkation (`Q-MOVE-5`).** Nothing in the look should suggest
+ either.
+- **Territory:** control already comes per period from `content/map/control_hexes_1948_49.yaml`, and the map editor
+ (#1009) edits it. Borders on the tiles read that data.
+
+Still open, to bring to the owner as proposals with options and costs (AGENTS.md): river edges (no rule yet), and new
+tile or hex types beyond the eight biomes, which the GDD marks TBD.
+
+## 4. Team work split
+
+How packages work: each package is one branch `hex/<id>`, done with the collaborator's own Claude. Each owns its listed
+files only.
+
+Everyone's definition of done:
+- mid and close captures with local models, **and** a stand-in-only capture;
+- `HexPrototypeTests` green;
+- the stats line within `TriangleBudget`;
+- settings rewrites reverted (`git checkout -- unity/Assets/Settings unity/ProjectSettings/...`).
+
+Asset rules for everyone:
+- New Tripo generation is Tal's (credits, rights). Pending-rights `proto:` models stay local and are never committed.
+- Any committed model or texture needs a repository-compatible licence and an `ASSETS.yaml` row. Unity Asset Store
+ material is never accepted.
+
+**Independent** packages need only new files. **Blocked** packages need WP0 first.
+
+**WP0. Contract v2.** Gating; proposed by Tal in an issue and approved by the owner (eyalgolan, the sole code owner). Size L.
+- Goal: one reviewed change to `Core/` and the board format for what the other packages need: per-hex `feature`,
+ `resource` and `owner`; a second unit slot; an overlay registry (`[HexOverlay]`, `Overlays/`, one file per overlay,
+ like prototypes); a read-only neighbour query.
+- Also: settle the rivers choice (edge or in-tile) and the three open issues in section 1.
+- Done: tests extended, the Tel Aviv board captures unchanged.
+
+**WP1. Galilee kibbutz.** Independent. Size M.
+- Goal: `kibbutz_galilee` with dining hall, water tower, cowshed, fishponds and fields painted with `PaintGround`.
+ Optionally a stockade-and-watchtower variant.
+- Owns: `Prototypes/KibbutzGalilee.cs`.
+- Inputs: 1930s and 1940s kibbutz photos (Hanita, Degania); building kit stand-ins.
+- Done: universal list above, on `-on moshava_village`.
+
+**WP2. Jerusalem quarters.** Independent. Size M.
+- Goal: `jerusalem_old_city`, the walled Old City as one landmark plus domes; then `jerusalem_stone_quarter`, Rehavia
+ stone houses on a hills hex.
+- Owns: one file each in `Prototypes/`.
+- Inputs: Old City plans, Rehavia photos; stone colours.
+- Done: reads on `terrain: hills` (slope limits); landmark ≤ 0.40 S.
+
+**WP3. Coastal cities.** Independent. Size M. Can be two people.
+- Goal: `haifa_port` (bay, breakwater, refinery tanks, Carmel slope behind) and `jaffa_old_city` (hilltop old town,
+ clock tower, harbour, fishing boats).
+- Owns: `Prototypes/HaifaPort.cs` and `Prototypes/JaffaOldCity.cs`.
+- Inputs: 1940s aerial photos.
+- Done: shore pieces respect `IsWater`; Jaffa tried with `-on tel_aviv_city`; the shared-hex question is left to Tal.
+
+**WP4. Negev desert and Bedouin.** Independent. Size S.
+- Goal: `negev_desert` (wadis painted `dirt`, rocks, acacias) and `bedouin_camp` (black tents as stand-ins, camels and
+ goats as a tile's life, kept small).
+- Owns: one file each.
+- Inputs: Beersheba-area photos; `sandbox:desert_rock*`.
+- Done: on `ground: desert`, at `BudgetFields` or below.
+
+**WP5. Infantry units.** Independent. Size S each.
+- Goal: `haganah_field_corps`, `arab_legion_squad`, `arab_irregulars` (ALA or local fighters), each exactly 8
+ characters via `HexUnitTypes.Squad`.
+- Owns: one `Units/<Id>.cs` each.
+- Inputs: uniform references (Tal's character roster docs); stand-in figures until Tal generates models.
+- Done: the unit-move video renders; walk and idle clips named "walk" and "idle"; `CycleShare` ≈ 0.86 × `HeightShare`.
+
+**WP6. Vehicles and guns.** Partly blocked. Size M.
+- Goal: the sim's unit types (`content/unit_types.yaml`: `veteran_soldier`, `artillery`, `armoured_car`). `armoured_car`
+ (one vehicle) is independent.
+- Needs a look decision (Tal proposes, owner approves): `artillery`, a gun plus crew that fits neither "8 characters"
+ nor "one vehicle". No convoy unit: the sim has no transport (`Q-MOVE-5`).
+- Owns: `Units/<Id>.cs` per unit.
+- Done: `YawOffset` checked in the close capture; ≤ `BudgetUnits`.
+
+**WP7. Ground layers.** Blocked on `HexGround.Layers` in Core. Size M.
+- Goal: textures for citrus rows, vineyard rows, sand ripples, wadi gravel, riverbed and mud banks, swamp. Made by
+ extending `asset-staging/tools/kit/make_crop_textures.py` (local) or from CC0 sources.
+- Owns: textures in git-ignored staging, plus an issue listing the layer rows.
+- Done: a swatch sheet and a before/after board capture; `ASSETS.yaml` rows ready for when Tal approves the batch.
+
+**WP8. Rivers and roads look.** Blocked on WP0 for railways and borders. Size L.
+- Goal: finish the in-progress roads and rivers as overlays: road grades (track, road, the paved main road), railway
+ (Jaffa to Jerusalem), bridges, river banks and reeds, then territory borders.
+- Owns: `Overlays/<Id>.cs` after WP0.
+- Inputs: 1940s Survey of Palestine maps (check licence); the route list from Tal.
+- Done: continuous across hexes in mid and board captures; road triangles near zero (painted).
+
+**WP9. Real-map boards.** Independent tooling. Size M.
+- Goal: a generator `tools/hex_board_from_map.py` that cuts a region of `content/map/hexes.json` into a board JSON.
+ Biome to `terrain` and `ground`: coastal_plain and valley → flat/plains or grass; hills → hills; mountains → hills,
+ or mountain above a height Tal sets; desert → flat/desert; sea and lake → water/seabed. It also marks settlement
+ hexes from `settlement_hexes.yaml`.
+- Owns: the tool, its pytest, and proposed boards in `asset-staging/ui-local/hex-tiles/boards/`.
+- Done: pytest green; whole-board captures of the Jerusalem corridor and Haifa bay. Tal copies the chosen ones into
+ `Boards/`.
+
+**WP10. LOD and impostors.** Blocked on Core (`HexModels`, builder). Size L.
+- Goal: keep a whole-region board interactive: two decimation levels per local model, octahedral impostors for trees at
+ board zoom, a per-tile triangle report at three zooms.
+- Owns: offline tooling and a measured report, then a WP0-style issue.
+- Done: board frame time and triangle totals before and after on Tal's machine.
+
+**WP11. Unit banners and icons.** Art independent; integration blocked. Size S/M.
+- Goal: Civ-style unit flags: a faction colour plate, a type icon (infantry, armour, artillery), a strength
+ pip; plus resource pins.
+- Owns: SVG and PNG icons in `asset-staging/ui-local/hex-tiles/icons/`, and an HTML mockup (not a Unity render).
+- Done: legible at board zoom in mockups; original art only; the flag drawn as a billboard over the unit spot (after
+ WP0).
+
+**Stays with Tal:**
+- board layouts (`Boards/*.json`), which prototypes go on a board, and the routes and rivers lists;
+- approval of before/after captures before any wider rollout;
+- Tripo generation and credits, rights decisions, `ASSETS.yaml` approval of asset batches;
+- every gameplay proposal in section 3;
+- push, PR and deployment.
+
+**Must not be touched by a package:**
+- `Core/`, `Capture/` and `Tests/` without an approved issue (WP0);
+- another contributor's prototype or unit file;
+- the simulation (`sim/`) and `content/` rules or data, except through Tal's own sim PR;
+- the shipped game, scenes and default look; tracked Unity folders for pending-rights models;
+- any committed, shared or uploaded build while pending-rights models exist.
+
+## Sources
+
+- Civ VII Dev Diary #5, Combat (commanders, packing units, ZOC): https://civilization.2k.com/civ-vii/archive/dev-diary/combat/
+- Civ VII Dev Diary #3, Managing Your Empire (rural and urban districts, growth): https://civilization.2k.com/civ-vii/game-guide/dev-diary/managing-your-empire/
+- Civ VII glossary (biomes, navigable rivers, zone of control): https://civilization.2k.com/civ-vii/glossary/
+- Civ VII TSL Earth map (rivers and resources placed to match the real Earth): https://civilization.2k.com/civ-vii/game-guide/gameplay/earth-map/
+- Quarter (Civ7), Civilization Wiki: https://civilization.fandom.com/wiki/Quarter_(Civ7)
+- Civilization VI: Terrain, CivFanatics (hills and woods cost 2; pre-release river note): https://civfanatics.com/?p=2010
+- Firaxis interview, PC Games Hardware (procedural placement for organic cities and roads): https://www.pcgameshardware.de/Civilization-6-Spiel-56986/Specials/Interview-technical-details-1199995/
+- From general knowledge, to verify before relying on it: Civ VI's one military plus one civilian per tile rule, Civ VI
+ road costs by era, and the exact Civ VI river-crossing cost.
diff --git a/docs/hex-tiles/README.md b/docs/hex-tiles/README.md
new file mode 100644
index 000000000..df3af476c
--- /dev/null
+++ b/docs/hex-tiles/README.md
@@ -0,0 +1,290 @@
+# Hex tiles: Civ-style prototype hexes
+
+Status: local prototype for review (Tal, lead designer). The default game is unchanged.
+
+- **In the game, opt-in:** the board runs on the real map behind `?hex-tiles` (web) or `-hex-tiles` (desktop), wired in
+ `GameRoot` next to `?map-look`.
+- **Where the code lives:**
+ - Runtime: `unity/Assets/Scripts/Map/HexTiles/`, namespace `Statecraft.HexTiles`, inside `Statecraft.Game`. That is
+ `Core/` (the board placed by `HexRealMap`), `Prototypes/`, `Units/` and `HexTilesLook.cs` (the switch).
+ - Board files: `unity/Assets/Resources/HexTiles/Boards/`.
+ - Shipped material templates: `unity/Assets/Resources/HexTiles/Materials/`, made by the menu
+ **Statecraft/Hex Tiles/Make Materials And Local Ground**.
+ - Editor-only captures and tests: `unity/Assets/Editor/HexTiles/` (`Statecraft.HexTiles.Editor`).
+- **It becomes the default when** the whole map is covered and its models are cleared for shipping. Then the switch
+ goes.
+
+## The idea
+
+The map is drawn hex by hex, the way Civilization draws it:
+
+- **The ground follows the hexes, not a real heightmap.** Each hex is flat, hills, mountain or water. The ground is
+ shaped and painted from that, and blended softly across edges.
+- **Each hex has one job.** It might be a city core, a forest, a farmed plain or an orange grove. One *prototype*
+ fills it with a few large pieces. Units (soldiers, vehicles) are not tile jobs: they are a separate layer on top (see
+ "Units are a layer, not a tile").
+- **Prototypes are tried on a fixed board.** The first board is 37 hexes around Tel Aviv, in
+ `unity/Assets/Resources/HexTiles/Boards/tel_aviv.json`. It uses the game's own `q`/`r` coordinates, so a board maps
+ onto the real map later.
+
+## Boards: generated, then hand-edited
+
+`central_israel` (108 hexes, Hadera to Jerusalem, coast to the Judean hills) is what the game shows behind `?hex-tiles`.
+Name another board to show it instead: `?hex-tiles=tel_aviv_crop` (desktop `-hex-tiles tel_aviv_crop`). `tel_aviv_crop` is
+the Tel Aviv crop that sets the look: about 30 play hexes inside an environment ring. Ring hexes (`"env": true`) carry no
+tiles. They are one continuous landscape of noise-placed woods and meandering ground (HexEnvironment), with no hex lines.
+It is generated from the game's own hexes and 1948 settlements:
+
+```bash
+python3 tools/hex_tiles/make_board.py --id central_israel --lat 31.62 32.48 --lon 34.4 35.42
+```
+
+The generator does the following:
+
+- **Terrain:** by elevation, and game-friendly as in Civ: flat below 120 m, hills to 450 m, smooth highland above. It
+ draws no real cliffs or ravines, so units cross every land hex.
+- **Ground:** by biome.
+- **Settlements:** each gets its own tile:
+ - Tel Aviv, Jaffa and Jerusalem by id;
+ - the other towns as moshavot or Arab villages;
+ - kibbutzim and moshavim as kibbutz tiles.
+- **Every other hex:** a tile chosen by terrain, biome and coast.
+- **Connections:** roads between the main towns along hex lines, and the Yarkon.
+
+The output is a plain file: edit it by hand afterwards, and re-running overwrites it. `tel_aviv` stays the small test
+board.
+
+## Adding a prototype hex (the contributor workflow)
+
+**One prototype is one new file** (or one unit is one new file under `Units/`). **You never edit anyone else's file.**
+
+1. **Copy the reference** `unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs` to
+ `Prototypes/<YourName>.cs`. Then:
+ - Give it a new `[HexPrototype("your_id")]`, in lower_snake_case and unique.
+ - Use the namespace `Statecraft.HexTiles.Prototypes`.
+ - Write it in C# 9: no `record` types.
+ - Keep one prototype class per file. Do not copy `WheatFields.cs`: it holds two (`wheat_fields` and `grazing_land`).
+ `MountainPeaks.cs` is a clean single-class example of a light context tile.
+2. **Implement `IHexPrototype`:**
+ - `Title`, the `Terrain` you want under it, the `Ground` layer, and a `TriangleBudget` (see `HexScale.Budget*`).
+ - `Build(HexTileContext ctx)`. Place everything through `ctx`.
+
+ `Terrain` shapes the ground (`HexBoardSurface`, heights in metres above sea level):
+
+ | Terrain | What it looks like |
+ |---|---|
+ | `Flat` | About 80 m, with roughly ±50 m of gentle noise |
+ | `Hills` | A dome rising from 80 m to up to about 700 m above it at the centre |
+ | `Mountain` | A raised base (80 + 500 m) and a dome (+600 m). A mountain hex with no prototype gets `mountain_peaks` rocks |
+ | `Water` | Below sea level (about -520 m). Anything under 4 m reads as water, and `Place*` refuses it |
+
+ `Ground` must be one of the `HexGround.Layers` ids:
+
+ | Ground | Look |
+ |---|---|
+ | `grass` | Green grass with rock |
+ | `plains` | Drier yellow-green grassland (the city and fields use it) |
+ | `hills` | Earth and rock |
+ | `mountain` | Rocky terrain |
+ | `desert` | Sand |
+ | `beach` | Shore sand (the board also paints it on every shoreline) |
+ | `seabed` | Under water (painted automatically below the sea) |
+
+3. **Use only the context API** (`Core/HexTileContext.cs`):
+ - `ctx.S` is the hex size. Size everything as a share of it.
+ - `ctx.Centre` is the hex centre. `ctx.At(bearingDeg, share)` gives a point at a bearing and distance from it.
+ `ctx.RandomPoint(margin)` gives a random point in the hex. `ctx.Inside(p, margin)` tests whether a point is in.
+ - `ctx.Rng` and `ctx.Range(a, b)` are the *only* randomness allowed. They are seeded by the hex, so the same hex always
+ builds the same way.
+ - `ctx.GroundY(p)`, `ctx.IsWater(p)` and `ctx.SlopeDeg(p)` read the ground.
+ - `ctx.PlaceByWidth(model, at, yaw, widthM, standIn, tint)` places buildings and rocks, sized by footprint.
+ - `ctx.PlaceByHeight(model, at, yaw, heightM, standIn, tint, footprintShare)` places trees, figures and animals,
+ sized by height.
+ - `ctx.PlaceFlat(at, yaw, width, depth, colour)` places fields, roads and plazas.
+ - Every `Place*` refuses, and returns false, when the footprint leaves the inset hexagon or lands on water or steep
+ ground. A refused placement is normal, so just carry on.
+ - `PlaceFlat` also refuses when the ground under it rises more than `maxRiseM` (default 60 m). Large flats can fail
+ even on flat hexes because of the noise, and always on hills. Pass a larger value (`WheatFields` passes 120) or use
+ many small flats.
+ - On mountains the slope limit (`maxSlopeDeg`, 30 or 35 by default) refuses most pieces. `MountainPeaks` passes 90.
+ - **There is no collision or reservation.** `Place*` never checks earlier pieces. Plan positions so pieces do not
+ overlap: lots, rings, rows (the reference uses rings and avenues). Do not stack flats on the same spot, because
+ co-planar flats flicker. Vary their size or offset them instead.
+ - `tint` colours stand-ins and flats only. A real model keeps its own material.
+ - **Facing:** at yaw 0 a model's front faces north (+Z), if it was exported the usual way. Several Tripo vehicles face
+ +X instead. Check the close capture, and add ±90 to the yaw if a vehicle drives sideways. The camera looks north from
+ the south, so the reference turns its landmark 180° (`GridYaw + 180f`) to show the main façade.
+4. **Keep to the scale** in `Core/HexTileContract.cs` (`HexScale`). The goal is few, large pieces, as in Civ VI:
+
+ | Piece | Size (share of S) | Per hex |
+ |---|---|---|
+ | Building footprint | 0.12 to 0.20 | 12 to 25 in a city hex |
+ | Landmark | up to 0.40 | |
+ | Tree height | 0.12 to 0.20 | 25 to 60 in a forest, 15 to 40 in an orchard |
+ | People and animals as a tile's life | small (the reference uses about 0.075 for townspeople, grazing about 0.06 for sheep) | a few |
+
+ Soldiers and vehicles are units, not tile pieces. See "Units are a layer, not a tile".
+5. **Models** are ids (see `Core/HexModels.cs`):
+ - `tiles:<your_id>/<name>` loads your own model from `Assets/Resources/HexTiles/<your_id>/<name>.prefab`.
+ - `sandbox:<name>` is the local EZ-Tree trees, Poly Haven rocks and building kit.
+ - `proto:<name>` is the local Tripo models (characters, animals, vehicles, landmarks).
+ - A trailing `*` picks among the variants `name`, `name_2`, `name_3` and so on.
+ - **A missing model draws its stand-in** (`StandIn.Box/Tree/Pine/Palm/Rock/Figure`). Your tile must read well
+ with stand-ins alone, because most machines will not have the local models (see "What is local-only").
+ - To place a deliberate stand-in-only piece, use a model id that does not exist (for example `tiles:<your_id>/tent`).
+ It shows as `~` in the stats line.
+6. **Triangle costs.** A flat piece costs 12 triangles. A stand-in costs tens. A local model costs what its mesh has,
+ and the stats line reports the tile total. The common local models, approximately:
+
+ | Model | Triangles |
+ |---|---|
+ | `sandbox:aleppo_pine_lite` | ~1,600 |
+ | `sandbox:tabor_oak_lite`, `sandbox:carob_lite` | ~650 |
+ | `sandbox:olive_lite`, `sandbox:citrus_lite` | ~1,600 |
+ | `sandbox:cypress_lite` | ~1,600 |
+ | `sandbox:date_palm` | ~280 |
+ | `sandbox:limestone*`, `sandbox:desert_rock*` | ~700 |
+ | `sandbox:kit_<style>*` | ~700 to 1,400 |
+ | `sandbox:hq_white_city*` | ~3,500 (the hero ~9,000) |
+ | `proto:` v2 vehicles | 18,000 to 31,000 |
+ | `proto:` v2 characters (`figure-*-c##-1948-v2`) | ~3,000 to 4,000 |
+ | `proto:figure-sheep-lite-1948`, `proto:figure-donkey-lite-1948` | ~2,500 |
+
+## Seeing it, testing it
+
+Render a single prototype on the board with its ground and neighbours. The output is the mid (about 3 hexes) and close
+(1 hex) 4K shots, plus a stats line in `asset-staging/ui-local/hex-tiles/`:
+
+```bash
+Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -executeMethod Statecraft.HexTiles.Capture.HexBoardCapture.Run -prototype your_id
+```
+
+Leave out `-prototype` to render the whole board, which adds `board.png`. Add `-on <tile>` to try your prototype on
+another tile's hex without editing the board file, for example `-prototype tel_aviv_city_mixed -on tel_aviv_city`
+(an A/B variant on the city's hex). The stats line lists:
+
+- the pieces, and how many fell back to stand-ins (a missing model is marked `~`);
+- triangles against the tile's budget.
+
+Run the tests. Every registered prototype is checked automatically, with no edit to the tests:
+
+```bash
+Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -projectPath unity -runTests -testPlatform EditMode -testFilter HexPrototypeTests
+```
+
+The tests require that every prototype:
+
+- has a lower_snake_case id;
+- builds something;
+- is deterministic;
+- keeps every piece inside its inset hexagon;
+- stays within its triangle budget.
+
+They also check that every board names only known prototypes, terrains and ground layers.
+
+After any Unity run, revert the settings it rewrites before committing:
+
+```bash
+git checkout -- unity/Assets/Settings unity/ProjectSettings/ProjectSettings.asset unity/ProjectSettings/QualitySettings.asset
+```
+
+## Units are a layer, not a tile
+
+Lead designer's rules (Tal, 18 October):
+
+- **Units (characters, vehicles) are never part of a tile prototype.** A board hex has a tile `prototype` (the land) and
+ optionally a `unit` (who stands on it), plus `facing` (degrees from north).
+- **A character unit is exactly 8 characters, and only the characters.** No tents, tracks, paving or other ground
+ change: they walk on the land and move between hexes.
+- **A vehicle unit is exactly one vehicle, and no road.**
+- **Units are drawn larger than buildings**, as Civ draws them (`HexUnitScale`):
+
+ | Measure | Share of S |
+ |---|---|
+ | Figure height (`HexUnitScale.FigureHeight`) | 0.26 |
+ | Spacing between figures | 0.15 |
+ | Vehicle length | 0.48 |
+
+**Defining a unit.** One file per unit under `unity/Assets/Scripts/Map/HexTiles/Units/`, marked `[HexUnitType("your_id")]`
+and implementing:
+
+```csharp
+public interface IHexUnitType { string Title { get; } HexUnit Create(); }
+```
+
+`HexUnit` (`Core/HexUnits.cs`) has `Members`, each a `HexUnitMember`:
+
+| Field | Meaning |
+|---|---|
+| `Model` | Model id, as for tiles |
+| `StandIn` | Drawn when the model is missing (`Figure` by default, `Box` for vehicles) |
+| `Offset` | Place in the formation: x to the right, z forward, as shares of S |
+| `HeightShare` | Height as a share of S (or the length, with `ByWidth`) |
+| `CycleShare` | Distance per walk or wheel cycle, as a share of S |
+| `ByWidth` | Size by footprint instead of height (vehicles) |
+| `YawOffset` | Degrees to turn the model so its front faces the way it travels (many Tripo vehicles need -90 or +90) |
+
+**Movement.** The simulation decides the move from hex A to hex B. The view (`HexUnitMotion`) then:
+
+- glides the unit along the hex centres and turns smoothly at each centre;
+- plays the walk clip locked to distance travelled, so feet do not slide (stride is about 0.86 × figure height, so
+ set `CycleShare` to about 0.86 × `HeightShare`), and the idle clip when it stands;
+- turns vehicle wheels by distance.
+
+Tripo clips are exported in place (no root motion), so units land exactly on hex centres.
+
+**Character clips.** A character needs a `walk` take and an `idle` take. Clips are matched by name, so the names must
+contain "walk" and "idle". The converter `asset-staging/tools/kit/characters_to_fbx.py` keeps them when run with
+`CHAR_KEEP=walk`. This tool is local.
+
+**Seeing a move.** Render the move video:
+
+```bash
+Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -executeMethod Statecraft.HexTiles.Capture.HexUnitMoveCapture.Run
+```
+
+The output is `asset-staging/ui-local/hex-tiles/unit-move/unit-move.mp4`, plus its frames. The MP4 is written only
+when ffmpeg is on PATH. `-captureDir` and `-captureSize 1920x1080` are optional.
+
+## Review and hand-in
+
+- **Branch:** work on `hex/<your_id>`. The change is your one prototype file (or one `Units/<id>.cs`), plus your models
+ under `Resources/HexTiles/<your_id>/` if they are licensed for the repository (see below).
+- **Pull request:** include your mid and close captures, and your stats line.
+- **Who decides:** Tal decides which prototypes go on a board, and edits the board files.
+- **Do not edit:** `Core/`, `Capture/`, `Tests/` or another contributor's prototype. Propose a contract change in an
+ issue instead.
+
+## What is local-only (read before relying on a model)
+
+- **Tripo models are local-only while their rights are pending:**
+ - figures, animals, vehicles and landmarks (`proto:`);
+ - the decimated city kit (`sandbox:kit_*`).
+ They are never committed, shared or built into a shareable build. On other machines they draw as stand-ins.
+- **Not yet in the repository:**
+ - the EZ-Tree trees (MIT), Poly Haven rocks and ground textures (CC0) under `sandbox:`;
+ - the ground folder.
+ Adding them is an asset batch that needs Tal's approval and `ASSETS.yaml` rows. Until then the board paints flat
+ colours and those models draw as stand-ins.
+- **Licences for your own models:** they need a licence that allows the repository, and an `ASSETS.yaml` row
+ (CONTRIBUTING.md item 7). Material from the Unity Asset Store is never accepted.
+
+## Files
+
+| Path | What it is |
+|---|---|
+| `Core/HexTileContract.cs` | `HexTerrain`, `[HexPrototype]`, `IHexPrototype`, `HexScale`, the registry, hex geometry |
+| `Core/HexTileContext.cs` | The API a prototype uses, and the placement record |
+| `Core/HexModels.cs` | Model ids, variants, stand-ins, triangle counts |
+| `Core/HexBoard.cs` | Board files, the Civ-style ground (`HexBoardSurface`), ground layers |
+| `Core/HexBoardBuilder.cs` | Terrain, sea, rendering, tile edges, per-tile reports |
+| `Core/HexUnits.cs` | `HexUnit`, `HexUnitMember`, and `HexUnitMotion` (moving a unit along hex centres) |
+| `Capture/HexBoardCapture.cs` | The capture command (`-prototype <id>`, plus `-on <tile>` to try it on another tile's hex) |
+| `Capture/HexUnitMoveCapture.cs` | The unit-move video |
+| `Tests/HexPrototypeTests.cs` | The contract tests |
+| `Prototypes/` | One file per prototype hex (`TelAvivCity.cs` is the reference) |
+| `Prototypes/MountainPeaks.cs` | `mountain_peaks`, the rocks on a mountain hex |
+| `Prototypes/WheatFields.cs` | `wheat_fields` and `grazing_land` (two classes in one file: do not copy it) |
+| `Prototypes/TelAvivCityMixed.cs` | `tel_aviv_city_mixed`, the A/B variant of the reference |
+| `Units/` | One file per unit type (`[HexUnitType]`) |
+| `Boards/` | Board layouts (Tal's) |
diff --git a/tools/hex_tiles/make_board.py b/tools/hex_tiles/make_board.py
new file mode 100644
index 000000000..651476556
--- /dev/null
+++ b/tools/hex_tiles/make_board.py
@@ -0,0 +1,201 @@
+#!/usr/bin/env python3
+"""Generate a hex-tile board (Civ-style map) for a region of the game map.
+
+Reads the game's own hexes (content/map/hexes.json) and 1948 settlements (content/map/settlements_1948.yaml) and writes
+unity/Assets/Resources/HexTiles/Boards/<id>.json for the hex-tile layer (docs/hex-tiles/README.md):
+
+- terrain by elevation, game-friendly like Civ: flat below 120 m, hills to 450 m, smooth highland "mountain" above
+ (the real cliffs and ravines are not reproduced; units cross every land hex);
+- ground layer by biome;
+- tile prototype per hex: each settlement's own (city, old city, town, village, kibbutz), otherwise one chosen by
+ terrain, biome and the coast with a stable per-hex draw;
+- roads between the main towns along hex lines, the Yarkon along hex edges, and the board's standing units.
+
+The output is a plain file: Tal edits it by hand after generating, and re-running overwrites it.
+
+ python3 tools/hex_tiles/make_board.py [--id central_israel] [--lat 31.62 32.48] [--lon 34.4 35.42]
+"""
+import argparse, json, math, os, re, sys
+
+ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+NEIGHBOURS = [(1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1)]
+
+
+def hex_distance(a, b):
+ dq, dr = b[0] - a[0], b[1] - a[1]
+ return (abs(dq) + abs(dr) + abs(dq + dr)) // 2
+
+
+def hex_line(a, b):
+ """Axial hexes from a to b inclusive (cube lerp and round)."""
+ n = hex_distance(a, b)
+ out = []
+ for i in range(n + 1):
+ t = i / n if n else 0.0
+ q = a[0] + (b[0] - a[0]) * t + 1e-6
+ r = a[1] + (b[1] - a[1]) * t + 1e-6
+ s = -q - r
+ rq, rr, rs = round(q), round(r), round(s)
+ dq, dr, ds = abs(rq - q), abs(rr - r), abs(rs - s)
+ if dq > dr and dq > ds: rq = -rr - rs
+ elif dr > ds: rr = -rq - rs
+ if not out or out[-1] != (rq, rr): out.append((rq, rr))
+ return out
+
+
+def settlements(path):
+ """id, lon, lat, type from the YAML list (simple keys only, no YAML dependency)."""
+ out, cur = [], None
+ for line in open(path, encoding='utf-8'):
+ m = re.match(r'^- id:\s*(\S+)', line)
+ if m:
+ cur = {'id': m.group(1)}; out.append(cur); continue
+ m = re.match(r'^\s+(lon|lat|type):\s*(\S+)', line)
+ if m and cur is not None:
+ cur[m.group(1)] = float(m.group(2)) if m.group(1) in ('lon', 'lat') else m.group(2)
+ return [s for s in out if 'lon' in s and 'lat' in s]
+
+
+def draw(q, r, salt):
+ """A stable value in [0, 1) per hex (no RNG state)."""
+ x = (q * 73856093) ^ (r * 19349663) ^ (salt * 83492791)
+ x = (x ^ (x >> 13)) * 1274126177 & 0xFFFFFFFF
+ return ((x ^ (x >> 16)) & 0xFFFFFF) / float(1 << 24)
+
+
+# A settlement's own tile: by id first, then by type. Jewish towns read as moshava colonies, Arab towns as stone villages.
+SETTLEMENT_TILE = {'tel_aviv': 'tel_aviv_city', 'jaffa': 'jaffa_old_city', 'jerusalem': 'jerusalem_old_city'}
+TYPE_TILE = {'city': 'moshava_village', 'town': 'moshava_village', 'arab_town': 'arab_village', 'kibbutz': 'kibbutz', 'moshav': 'kibbutz'}
+
+
+def terrain_of(h):
+ if not h['land']: return 'water'
+ e = h.get('elev_m', 0.0)
+ if e >= 450: return 'mountain'
+ if e >= 120 or h['biome'] == 'hills': return 'hills'
+ return 'flat'
+
+
+GROUND = {'coastal_plain': 'grass', 'valley': 'plains', 'hills': 'hills', 'mountains': 'mountain', 'desert': 'desert'}
+
+
+def nature_tile(h, terrain, coastal):
+ q, r, b = h['q'], h['r'], h['biome']
+ u = draw(q, r, 1)
+ if b == 'desert': return 'desert_edge'
+ if terrain == 'mountain': return 'judean_highlands' if u < 0.75 else ('pine_forest' if u < 0.9 else 'olive_terraces')
+ if terrain == 'hills': return 'olive_terraces' if u < 0.45 else ('pine_forest' if u < 0.7 else 'grazing_land')
+ if coastal and u < 0.45: return 'coastal_dunes'
+ if b == 'valley': return 'wheat_fields' if u < 0.6 else ('grazing_land' if u < 0.85 else 'citrus_orchard')
+ return 'wheat_fields' if u < 0.42 else ('citrus_orchard' if u < 0.75 else 'grazing_land')
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument('--id', default='central_israel')
+ ap.add_argument('--lat', nargs=2, type=float, default=[31.62, 32.48])
+ ap.add_argument('--lon', nargs=2, type=float, default=[34.40, 35.42])
+ ap.add_argument('--sea-ring', type=int, default=1, help='sea hexes kept within this many hexes of land')
+ ap.add_argument('--around', help='crop to hexes around this settlement id instead of a lat/lon box')
+ ap.add_argument('--radius', type=int, default=3, help='with --around: playable hexes within this many steps')
+ ap.add_argument('--env', type=int, default=0, help='with --around: a ring this many hexes wide of environment (landscape only, no tiles or hex lines)')
+ a = ap.parse_args()
+
+ H = json.load(open(os.path.join(ROOT, 'content/map/hexes.json')))['hexes']
+ by = {(h['q'], h['r']): h for h in H}
+ if a.around:
+ home = next(s for s in settlements(os.path.join(ROOT, 'content/map/settlements_1948.yaml')) if s['id'] == a.around)
+ c = min(H, key=lambda h: (h['lon'] - home['lon']) ** 2 + (h['lat'] - home['lat']) ** 2)
+ reach = a.radius + a.env
+ inside = [h for h in H if hex_distance((h['q'], h['r']), (c['q'], c['r'])) <= reach]
+ lats = [h['lat'] for h in inside]; lons = [h['lon'] for h in inside]
+ a.lat, a.lon = [min(lats) - 0.01, max(lats) + 0.01], [min(lons) - 0.01, max(lons) + 0.01]
+ env_of = lambda k: hex_distance(k, (c['q'], c['r'])) > a.radius
+ else:
+ inside = [h for h in H if a.lat[0] <= h['lat'] <= a.lat[1] and a.lon[0] <= h['lon'] <= a.lon[1]]
+ env_of = lambda k: False
+ land = {(h['q'], h['r']) for h in inside if h['land']}
+ keep = [h for h in inside if h['land'] or any(hex_distance((h['q'], h['r']), k) <= a.sea_ring for k in land)]
+ cells = {(h['q'], h['r']): h for h in keep}
+
+ def nearest(lon, lat):
+ return min(cells.values(), key=lambda h: (h['lon'] - lon) ** 2 + (h['lat'] - lat) ** 2)
+
+ # Settlements first: a city outranks a town, a town a village; a second settlement on a taken hex moves to the
+ # nearest free land neighbour (Jaffa beside Tel Aviv).
+ rank = {'city': 0, 'town': 1, 'arab_town': 1, 'moshav': 2, 'kibbutz': 2}
+ owner = {}
+ for s in sorted(settlements(os.path.join(ROOT, 'content/map/settlements_1948.yaml')), key=lambda s: (rank.get(s.get('type'), 3), s['id'])):
+ if not (a.lat[0] <= s['lat'] <= a.lat[1] and a.lon[0] <= s['lon'] <= a.lon[1]): continue
+ h = nearest(s['lon'], s['lat']); k = (h['q'], h['r'])
+ if env_of(k): continue
+ if k in owner or not h['land']:
+ free = [(k[0] + dq, k[1] + dr) for dq, dr in NEIGHBOURS]
+ free = [f for f in free if f in cells and cells[f]['land'] and f not in owner]
+ if not free: continue
+ k = min(free, key=lambda f: (cells[f]['lon'] - s['lon']) ** 2 + (cells[f]['lat'] - s['lat']) ** 2)
+ owner[k] = s
+
+ out = []
+ for k, h in sorted(cells.items(), key=lambda kv: (kv[0][1], kv[0][0])):
+ terrain = terrain_of(h)
+ e = {'q': k[0], 'r': k[1], 'terrain': terrain, 'ground': 'seabed' if terrain == 'water' else GROUND.get(h['biome'], 'grass'),
+ 'prototype': '', 'note': '', 'unit': '', 'facing': 0.0, 'env': env_of(k)}
+ if e['env']:
+ # Environment: terrain and ground only; the builder dresses it as continuous landscape (no tiles, no hex lines).
+ if terrain == 'mountain': e['terrain'] = 'hills'
+ out.append(e); continue
+ if terrain != 'water':
+ coastal = any((k[0] + dq, k[1] + dr) in by and not by[(k[0] + dq, k[1] + dr)]['land'] for dq, dr in NEIGHBOURS)
+ if k in owner:
+ s = owner[k]
+ e['prototype'] = SETTLEMENT_TILE.get(s['id'], TYPE_TILE.get(s.get('type'), 'moshava_village'))
+ e['note'] = s['id']
+ if e['prototype'] in ('tel_aviv_city', 'moshava_village', 'kibbutz') and terrain == 'mountain': e['terrain'] = 'hills'
+ else:
+ e['prototype'] = nature_tile(h, terrain, coastal)
+ if e['prototype'] == 'coastal_dunes': e['ground'] = 'beach'
+ if e['prototype'] in ('wheat_fields', 'citrus_orchard', 'grazing_land', 'moshava_village', 'kibbutz', 'tel_aviv_city', 'jaffa_old_city', 'coastal_dunes') and terrain == 'mountain':
+ e['terrain'] = 'hills'
+ out.append(e)
+
+ # Roads: Civ-style, hex centre to hex centre, between the main towns (drawn along hex lines).
+ hex_of = {s['id']: k for k, s in owner.items()}
+ routes = [('tel_aviv', 'lod'), ('lod', 'ramla'), ('ramla', 'jerusalem'), ('tel_aviv', 'petah_tikva'), ('tel_aviv', 'rishon_lezion'),
+ ('rishon_lezion', 'rehovot'), ('tel_aviv', 'netanya'), ('netanya', 'hadera'), ('jaffa', 'tel_aviv')]
+ roads = []
+ for a_id, b_id in routes:
+ if a_id in hex_of and b_id in hex_of:
+ line = [p for p in hex_line(hex_of[a_id], hex_of[b_id]) if p in cells and cells[p]['land']]
+ line = [p for p in line if not env_of(p)]
+ if len(line) >= 2: roads.append({'note': f'{a_id} to {b_id}', 'hexes': [v for p in line for v in p]})
+ rivers = []
+ ta = hex_of.get('tel_aviv')
+ if ta: # the Yarkon: along the north edges of Tel Aviv's row, out to the sea
+ q, r = ta
+ rivers.append({'note': 'The Yarkon', 'corners': [q - 1, r, 0, q, r, 5, q, r, 0, q, r, 1, q + 1, r, 0, q + 1, r, 1, q + 2, r, 0, q + 2, r, 1, q + 3, r, 0]})
+
+ # Units standing on the board (a layer above the tiles): a squad by Tel Aviv, the armoured truck on the Jerusalem road.
+ def stand(unit, near, facing):
+ if near in hex_of:
+ k = hex_of[near]
+ for dq, dr in NEIGHBOURS:
+ f = (k[0] + dq, k[1] + dr)
+ e = next((x for x in out if (x['q'], x['r']) == f), None)
+ if e and e['terrain'] != 'water' and not e['unit'] and not e['env'] and e['prototype'] not in ('tel_aviv_city', 'jerusalem_old_city', 'jaffa_old_city'):
+ e['unit'], e['facing'] = unit, facing; return
+ stand('palmach_squad', 'tel_aviv', 40.0)
+ stand('sandwich_truck', 'ramla', 100.0)
+ stand('willys_jeep', 'jerusalem', 270.0)
+
+ board = {'id': a.id, 'title': f'{a.id} (generated by tools/hex_tiles/make_board.py; lat {a.lat}, lon {a.lon})', 'hexes': out, 'roads': roads, 'rivers': rivers}
+ dst = os.path.join(ROOT, 'unity/Assets/Resources/HexTiles/Boards', a.id + '.json')
+ json.dump(board, open(dst, 'w'), indent=1)
+ from collections import Counter
+ print(f'{dst}: {len(out)} hexes ({sum(1 for e in out if e["terrain"] != "water")} land), {len(roads)} roads, settlements {len(owner)}')
+ print(' terrain', dict(Counter(e['terrain'] for e in out)))
+ print(' tiles', dict(Counter(e['prototype'] for e in out if e['prototype'])))
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/unity/Assets/Editor/HexTiles.meta b/unity/Assets/Editor/HexTiles.meta
new file mode 100644
index 000000000..b94ec7b5e
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: d4677d79d0e1840ebae39ad65b27e9c1
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Editor/HexTiles/Capture.meta b/unity/Assets/Editor/HexTiles/Capture.meta
new file mode 100644
index 000000000..e110b16f4
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 5265cc60eca264f59961f36cf0d212f0
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexBoardCapture.cs b/unity/Assets/Editor/HexTiles/Capture/HexBoardCapture.cs
new file mode 100644
index 000000000..3b555f97b
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexBoardCapture.cs
@@ -0,0 +1,149 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using Statecraft.Game.Map;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.Rendering;
+using UnityEngine.Rendering.Universal;
+using Debug = UnityEngine.Debug;
+using Object = UnityEngine.Object;
+
+namespace Statecraft.HexTiles.Capture
+{
+ /// <summary>Renders a hex board in a new, unsaved scene: no game, no UI, no real map (the ground is the board's own).
+ /// Shots at -captureSize (default 3840x2160) with the game camera's pitch and FOV, the map's light and grade:
+ /// &lt;dir&gt;/board.png (the whole board) and, per prototype tile, &lt;id&gt;-mid.png (about 3 hexes) and &lt;id&gt;-close.png
+ /// (one hex); plus stats.txt with each tile's pieces, stand-ins and triangles against its budget.
+ /// -prototype &lt;id&gt; builds and shoots only that tile (with the board's ground and mountains around it).
+ /// Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity
+ /// -executeMethod Statecraft.HexTiles.Capture.HexBoardCapture.Run [-board tel_aviv] [-prototype &lt;id&gt; [-on &lt;tile&gt;]]
+ /// [-captureDir asset-staging/ui-local/hex-tiles] [-captureSize 3840x2160]</summary>
+ public static class HexBoardCapture
+ {
+ public const string BoardsFolder = "Assets/Resources/HexTiles/Boards";
+ /// <summary>The ground textures, local and git-ignored (Poly Haven CC0, asset-staging/kits/PROVENANCE.md). Without
+ /// them the board paints flat colours.</summary>
+ const string GroundFolder = "Assets/Art/Settlements/Prototype/HexSandboxGround";
+ /// <summary>A livelier grade than the shipped map's, for the hex-tile captures (the opt-in look's start values).</summary>
+ const float Pitch = 50f, Fov = 35f, BoardDistanceM = 80000f, MidDistanceM = 26000f, CloseDistanceM = 12500f;
+
+ [MenuItem("Statecraft/Hex Tiles/Capture Tel Aviv Board")]
+ public static void Run()
+ {
+ try
+ {
+ var repo = Path.GetFullPath(Path.Combine(Application.dataPath, "..", ".."));
+ var dir = Path.GetFullPath(Path.Combine(repo, Arg("-captureDir") ?? "asset-staging/ui-local/hex-tiles"));
+ var size = (Arg("-captureSize") ?? "3840x2160").Split('x');
+ Capture(Arg("-board") ?? "tel_aviv", Arg("-prototype"), dir, int.Parse(size[0]), int.Parse(size[1]));
+ }
+ catch (Exception e)
+ {
+ Debug.LogError("HEX TILES CAPTURE FAILED " + e);
+ if (Application.isBatchMode) EditorApplication.Exit(1);
+ else throw;
+ }
+ }
+
+ public static HexBoard LoadBoard(string id) => HexBoard.Load(id);
+
+ static void Capture(string boardId, string? only, string dir, int width, int height)
+ {
+ var clock = Stopwatch.StartNew();
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ var board = LoadBoard(boardId);
+ // -on <tile>: try a prototype on another tile's hex (A/B variants) without editing the board file.
+ var on = Arg("-on");
+ if (only != null && on != null) foreach (var h in board.Hexes.Values) if (h.prototype == on) h.prototype = only;
+ if (only != null && !board.Hexes.Values.Any(h => h.prototype == only)) throw new ArgumentException($"board {boardId} has no tile '{only}' (try -on <tile>)");
+ var cam = Stage();
+ var (root, reports) = HexBoardBuilder.Build(board, Ground, only: only);
+ long buildMs = clock.ElapsedMilliseconds;
+ Directory.CreateDirectory(dir);
+ try
+ {
+ var surface = new HexBoardSurface(board);
+ Vector3 OnGround(Vector3 p) => new Vector3(p.x, Mathf.Max(surface.Height(p), 0f), p.z);
+ var centres = board.Hexes.Values.Select(h => HexGeometry.Centre(h.q, h.r, HexScale.HexM)).ToList();
+ var middle = new Vector3(centres.Average(c => c.x), 0f, centres.Average(c => c.z));
+ if (only == null) Shoot(cam, OnGround(middle), BoardDistanceM, Path.Combine(dir, "board.png"), width, height);
+ // A board with an environment ring: one wider shot that takes in the landscape round the play hexes.
+ if (only == null && board.Hexes.Values.Any(h => h.env)) Shoot(cam, OnGround(middle), BoardDistanceM * 1.6f, Path.Combine(dir, "board-wide.png"), width, height);
+ foreach (var t in board.Hexes.Values.Where(h => h.prototype != "" && (only == null || h.prototype == only)))
+ {
+ var c = OnGround(HexGeometry.Centre(t.q, t.r, HexScale.HexM));
+ Shoot(cam, c, MidDistanceM, Path.Combine(dir, $"{t.prototype}-mid.png"), width, height);
+ Shoot(cam, c, CloseDistanceM, Path.Combine(dir, $"{t.prototype}-close.png"), width, height);
+ }
+ // Units: one close shot each, at the unit's own zoom.
+ foreach (var u in board.Hexes.Values.Where(h => h.unit != "" && (only == null || h.prototype == only)))
+ Shoot(cam, OnGround(HexGeometry.Centre(u.q, u.r, HexScale.HexM)), CloseDistanceM, Path.Combine(dir, $"unit-{u.unit}-close.png"), width, height);
+ var lines = new List<string> { $"board {boardId}: {board.Hexes.Count} hexes, built in {buildMs} ms, {width}x{height}" };
+ lines.AddRange(reports.Select(r => " " + r));
+ File.WriteAllLines(Path.Combine(dir, only == null ? "stats.txt" : $"{only}-stats.txt"), lines);
+ Debug.Log("HEX TILES " + string.Join(" | ", lines) + " -> " + dir);
+ }
+ finally
+ {
+ TiltShift.Reset();
+ Object.DestroyImmediate(root);
+ }
+ }
+
+ /// <summary>The map's light, a camera with the game rig's FOV and post-processing, and the map-look grade, in the
+ /// open scene. Shared by every hex-tile capture.</summary>
+ public static Camera Stage()
+ {
+ var sun = new GameObject("Sun").AddComponent<Light>(); sun.type = LightType.Directional;
+ MapLighting.Apply(sun);
+ var cam = new GameObject("Camera") { tag = "MainCamera" }.AddComponent<Camera>();
+ cam.fieldOfView = Fov; cam.nearClipPlane = 50f; cam.farClipPlane = 1_000_000f;
+ cam.clearFlags = CameraClearFlags.SolidColor; cam.backgroundColor = new Color(0.07f, 0.36f, 0.48f);
+ cam.GetUniversalAdditionalCameraData().renderPostProcessing = true;
+ var volume = new GameObject("PostFX").AddComponent<Volume>(); volume.isGlobal = true;
+ volume.profile = ScriptableObject.CreateInstance<VolumeProfile>();
+ MapGrade.Apply(volume.profile);
+ HexLook.Apply(volume.profile, sun); // the hex-tile look's warm, saturated light, as in the game under ?hex-tiles
+ return cam;
+ }
+
+ public static void Shoot(Camera cam, Vector3 lookAt, float distance, string path, int width, int height)
+ {
+ cam.transform.rotation = Quaternion.Euler(Pitch, 0f, 0f);
+ cam.transform.position = lookAt - cam.transform.forward * distance;
+ TiltShift.Apply(0f, distance);
+ ShadowFit.Apply(cam);
+ var rt = new RenderTexture(width, height, 24) { antiAliasing = 4 }; cam.targetTexture = rt; cam.Render();
+ RenderTexture.active = rt; var tex = new Texture2D(width, height, TextureFormat.RGB24, false);
+ tex.ReadPixels(new Rect(0, 0, width, height), 0, 0); tex.Apply();
+ File.WriteAllBytes(path, tex.EncodeToPNG());
+ cam.targetTexture = null; RenderTexture.active = null; Object.DestroyImmediate(rt); Object.DestroyImmediate(tex);
+ }
+
+ /// <summary>A layer's Poly Haven albedo and normal from the local ground folder, or (null, null).</summary>
+ public static (Texture2D?, Texture2D?) Ground(string texture)
+ {
+ Texture2D? Load(string file, bool normal)
+ {
+ var path = $"{GroundFolder}/{file}";
+ if (AssetImporter.GetAtPath(path) is not TextureImporter ti) return null;
+ var type = normal ? TextureImporterType.NormalMap : TextureImporterType.Default;
+ if (ti.textureType != type) { ti.textureType = type; ti.SaveAndReimport(); }
+ return AssetDatabase.LoadAssetAtPath<Texture2D>(path);
+ }
+ return (Load($"{texture}_diff_2k.jpg", false), Load($"{texture}_nor_gl_2k.jpg", true));
+ }
+
+ public static string? Arg(string name)
+ {
+ var args = Environment.GetCommandLineArgs();
+ var i = Array.IndexOf(args, name);
+ return i >= 0 && i + 1 < args.Length ? args[i + 1] : null;
+ }
+ }
+}
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexBoardCapture.cs.meta b/unity/Assets/Editor/HexTiles/Capture/HexBoardCapture.cs.meta
new file mode 100644
index 000000000..08eb846e0
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexBoardCapture.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ed15876c0334d4ec0b894b9125f08be6
\ No newline at end of file
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexModelImport.cs b/unity/Assets/Editor/HexTiles/Capture/HexModelImport.cs
new file mode 100644
index 000000000..0e94a6e04
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexModelImport.cs
@@ -0,0 +1,165 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using Statecraft.Game;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Rendering;
+using Object = UnityEngine.Object;
+
+/// <summary>Imports the sandbox's vegetation and rock models (EZ-Tree, MIT, generated by asset-staging/tools/eztree/gen.mjs;
+/// Poly Haven rocks, CC0, decimated by asset-staging/tools/rocks/decimate.py) into the git-ignored prototype folder and
+/// saves Resources/HexSandbox/&lt;species&gt;[_n].prefab for the hex tiles (model ids "sandbox:<species>"). A model folder holds &lt;name&gt;.obj and either
+/// bark.jpg + leaves.png (a tree: submesh "bark" opaque, "leaves" alpha-clipped and two-sided) or albedo.jpg (+ normal.jpg)
+/// (a rock). Sandbox only: nothing here is tracked or shipped; provenance is in asset-staging/kits/PROVENANCE.md.
+/// Unity -batchmode -CI false -GITHUB_ACTIONS false -TF_BUILD false -quit -projectPath unity -executeMethod HexSandboxImport.Run</summary>
+public static class HexSandboxImport
+{
+ const string Root = "Assets/Art/Settlements/Prototype/HexSandboxModels", Prefabs = "Assets/Art/Settlements/Prototype/Resources/" + "HexSandbox";
+
+ /// <summary>(model folder under a source, species prefab name, leaf tint). Several rocks per species become variants.</summary>
+ static readonly (string source, string model, string species, Color tint)[] Table =
+ {
+ ("asset-staging/tools/eztree/out", "tabor_oak", "tabor_oak", new Color(0.78f, 0.86f, 0.70f)),
+ ("asset-staging/tools/eztree/out", "olive", "olive", new Color(0.80f, 0.86f, 0.78f)),
+ ("asset-staging/tools/eztree/out", "aleppo_pine", "aleppo_pine", new Color(0.75f, 0.85f, 0.72f)),
+ ("asset-staging/tools/eztree/out", "acacia", "acacia", new Color(0.95f, 0.92f, 0.70f)),
+ ("asset-staging/tools/eztree/out", "date_palm", "date_palm", Color.white),
+ // Stand-ins from the same generated trees until each has its own: a dark glossy grove tree, a dark carob, a cypress
+ // (the pine drawn narrow by its species' width in HexSandboxPlanting).
+ ("asset-staging/tools/eztree/out", "olive", "citrus", new Color(0.45f, 0.62f, 0.40f)),
+ ("asset-staging/tools/eztree/out", "tabor_oak", "carob", new Color(0.55f, 0.66f, 0.48f)),
+ ("asset-staging/tools/eztree/out", "aleppo_pine", "cypress", new Color(0.50f, 0.62f, 0.48f)),
+ // Lite trees for Civ-scale hex tiles (HexTiles): about a third of the triangles, same silhouettes.
+ ("asset-staging/tools/eztree/out", "tabor_oak_lite", "tabor_oak_lite", new Color(0.78f, 0.86f, 0.70f)),
+ ("asset-staging/tools/eztree/out", "olive_lite", "olive_lite", new Color(0.80f, 0.86f, 0.78f)),
+ ("asset-staging/tools/eztree/out", "aleppo_pine_lite", "aleppo_pine_lite", new Color(0.75f, 0.85f, 0.72f)),
+ ("asset-staging/tools/eztree/out", "acacia_lite", "acacia_lite", new Color(0.95f, 0.92f, 0.70f)),
+ ("asset-staging/tools/eztree/out", "olive_lite", "citrus_lite", new Color(0.45f, 0.62f, 0.40f)),
+ ("asset-staging/tools/eztree/out", "tabor_oak_lite", "carob_lite", new Color(0.55f, 0.66f, 0.48f)),
+ ("asset-staging/tools/eztree/out", "aleppo_pine_lite", "cypress_lite", new Color(0.50f, 0.62f, 0.48f)),
+ // High-quality White City set for the reference Tel Aviv hex tile (HexTiles): b01 hero ~8k, modules ~2.2k, 2K textures.
+ ("asset-staging/tools/kit/out-hq", "b01", "hq_white_city_hero", Color.white),
+ ("asset-staging/tools/kit/out-hq", "b02a", "hq_white_city", Color.white),
+ ("asset-staging/tools/kit/out-hq", "b02b", "hq_white_city_2", Color.white),
+ ("asset-staging/tools/kit/out-hq", "b13a", "hq_white_city_3", Color.white),
+ // Building kit per city style: the 13 October Tripo modules (pending rights, local only) decimated to ~700 tris by
+ // asset-staging/tools/kit/decimate_buildings.py; HexSandboxCity places them lot by lot.
+ ("asset-staging/tools/kit/out", "b02a", "kit_white_city", Color.white),
+ ("asset-staging/tools/kit/out", "b02b", "kit_white_city_2", Color.white),
+ ("asset-staging/tools/kit/out", "b13a", "kit_white_city_3", Color.white),
+ ("asset-staging/tools/kit/out", "b11", "kit_white_city_4", Color.white),
+ ("asset-staging/tools/kit/out", "b17", "kit_jaffa", Color.white),
+ ("asset-staging/tools/kit/out", "b21", "kit_jaffa_2", Color.white),
+ ("asset-staging/tools/kit/out", "b03c", "kit_jaffa_3", Color.white),
+ ("asset-staging/tools/kit/out", "b04a", "kit_haifa", Color.white),
+ ("asset-staging/tools/kit/out", "b04b", "kit_haifa_2", Color.white),
+ ("asset-staging/tools/kit/out", "b05a", "kit_haifa_3", Color.white),
+ ("asset-staging/tools/kit/out", "b03a", "kit_jerusalem", Color.white),
+ ("asset-staging/tools/kit/out", "b03b", "kit_jerusalem_2", Color.white),
+ ("asset-staging/tools/kit/out", "b03c", "kit_jerusalem_3", Color.white),
+ ("asset-staging/tools/kit/out", "b17", "kit_jerusalem_4", Color.white),
+ ("asset-staging/tools/kit/out", "b17", "kit_negev", Color.white),
+ ("asset-staging/tools/kit/out", "b03c", "kit_negev_2", Color.white),
+ ("asset-staging/tools/kit/out", "b21", "kit_negev_3", Color.white),
+ ("asset-staging/tools/kit/out", "b05a", "kit_moshava", Color.white),
+ ("asset-staging/tools/kit/out", "b16", "kit_moshava_2", Color.white),
+ ("asset-staging/tools/kit/out", "b24", "kit_moshava_3", Color.white),
+ ("asset-staging/tools/kit/out", "b09a", "kit_kibbutz", Color.white),
+ ("asset-staging/tools/kit/out", "b07", "kit_kibbutz_2", Color.white),
+ ("asset-staging/tools/kit/out", "b24", "kit_kibbutz_3", Color.white),
+ ("asset-staging/tools/kit/out", "b28", "kit_kibbutz_4", Color.white),
+ ("asset-staging/tools/kit/out", "b17", "kit_stone_village", Color.white),
+ ("asset-staging/tools/kit/out", "b03c", "kit_stone_village_2", Color.white),
+ ("asset-staging/tools/kit/out", "b32", "kit_port", Color.white),
+ ("asset-staging/tools/rocks/out", "rock_07", "limestone", Color.white),
+ ("asset-staging/tools/rocks/out", "rock_09", "limestone_2", Color.white),
+ ("asset-staging/tools/rocks/out", "namaqualand_boulder_04", "desert_rock", Color.white),
+ ("asset-staging/tools/rocks/out", "namaqualand_rocks_01", "desert_rock_2", Color.white),
+ ("asset-staging/tools/rocks/out", "namaqualand_boulders_01", "desert_rock_3", Color.white),
+ };
+
+ [MenuItem("Statecraft/Hex Sandbox Import Models")]
+ public static void Run()
+ {
+ try
+ {
+ Directory.CreateDirectory(Path.Combine(Paths.RepoRoot, "unity", Root));
+ Directory.CreateDirectory(Path.Combine(Paths.RepoRoot, "unity", Prefabs));
+ foreach (var (source, model, species, tint) in Table) Import(Path.Combine(Paths.RepoRoot, source, model), model, species, tint);
+ AssetDatabase.SaveAssets();
+ }
+ catch (Exception e)
+ {
+ Debug.LogError("HEX SANDBOX IMPORT FAILED " + e);
+ if (Application.isBatchMode) EditorApplication.Exit(1);
+ else throw;
+ }
+ }
+
+ static void Import(string src, string model, string species, Color tint)
+ {
+ if (!File.Exists(Path.Combine(src, model + ".obj"))) throw new FileNotFoundException($"no {model}.obj in {src}");
+ var dir = $"{Root}/{model}";
+ Directory.CreateDirectory(Path.Combine(Paths.RepoRoot, "unity", dir));
+ foreach (var f in Directory.GetFiles(src)) File.Copy(f, Path.Combine(Paths.RepoRoot, "unity", dir, Path.GetFileName(f)), true);
+ AssetDatabase.Refresh();
+ bool tree = File.Exists(Path.Combine(src, "leaves.png"));
+ Texture2D Tex(string file, bool normal = false, bool alpha = false, int max = 1024)
+ {
+ var path = $"{dir}/{file}";
+ var ti = (TextureImporter)AssetImporter.GetAtPath(path);
+ ti.textureType = normal ? TextureImporterType.NormalMap : TextureImporterType.Default;
+ ti.alphaIsTransparency = alpha; ti.maxTextureSize = max; ti.mipmapEnabled = true; ti.sRGBTexture = !normal;
+ ti.SaveAndReimport();
+ return AssetDatabase.LoadAssetAtPath<Texture2D>(path);
+ }
+ var shader = Shader.Find("Universal Render Pipeline/Lit") ?? throw new InvalidOperationException("URP Lit not found");
+ Material Mat(string name, Texture2D albedo, Color colour, Texture2D? normal = null, bool clip = false)
+ {
+ var m = new Material(shader) { name = name };
+ m.SetTexture("_BaseMap", albedo); m.SetColor("_BaseColor", colour); m.SetFloat("_Smoothness", 0.05f);
+ if (normal != null) { m.SetTexture("_BumpMap", normal); m.EnableKeyword("_NORMALMAP"); }
+ if (clip)
+ {
+ m.SetFloat("_AlphaClip", 1f); m.SetFloat("_Cutoff", 0.45f); m.EnableKeyword("_ALPHATEST_ON");
+ m.SetFloat("_Cull", (float)CullMode.Off); m.renderQueue = (int)RenderQueue.AlphaTest;
+ }
+ var path = $"{dir}/{species}-{name}.mat";
+ AssetDatabase.DeleteAsset(path); AssetDatabase.CreateAsset(m, path);
+ return m;
+ }
+ var go = Object.Instantiate(AssetDatabase.LoadAssetAtPath<GameObject>($"{dir}/{model}.obj"));
+ try
+ {
+ go.name = species;
+ int tris = 0;
+ // Made once per model: Mat replaces the asset at its path, which would orphan a renderer already using it.
+ var bark = tree ? Mat("bark", Tex("bark.jpg", max: 512), Color.white) : null;
+ var leaves = tree ? Mat("leaves", Tex("leaves.png", alpha: true, max: 512), tint, clip: true) : null;
+ var rock = tree ? null : Mat("rock", Tex("albedo.jpg", max: species.StartsWith("hq_", StringComparison.Ordinal) ? 2048 : 1024), Color.white, File.Exists(Path.Combine(src, "normal.jpg")) ? Tex("normal.jpg", normal: true) : null);
+ foreach (var r in go.GetComponentsInChildren<MeshRenderer>())
+ {
+ var mesh = r.GetComponent<MeshFilter>().sharedMesh; tris += mesh.triangles.Length / 3;
+ r.shadowCastingMode = tree || (species.StartsWith("kit_", StringComparison.Ordinal) || species.StartsWith("hq_", StringComparison.Ordinal)) ? ShadowCastingMode.On : ShadowCastingMode.Off;
+ if (tree)
+ {
+ // gen.mjs writes "bark" then "leaves"; Unity names submesh materials after the OBJ's usemtl.
+ bool leafPart = r.name.Contains("leaves");
+ r.sharedMaterials = r.sharedMaterials.Select((m, i) => m != null && m.name.Contains("leaves") || leafPart ? leaves!
+ : m != null && m.name.Contains("bark") ? bark! : i == 0 ? bark! : leaves!).ToArray();
+ }
+ else
+ {
+ r.sharedMaterials = Enumerable.Repeat(rock!, r.sharedMaterials.Length).ToArray();
+ }
+ }
+ var prefab = $"{Prefabs}/{species}.prefab";
+ PrefabUtility.SaveAsPrefabAsset(go, prefab);
+ Debug.Log($"HEX SANDBOX MODEL {species} <- {model} tris={tris} tree={tree}");
+ }
+ finally { Object.DestroyImmediate(go); }
+ }
+}
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexModelImport.cs.meta b/unity/Assets/Editor/HexTiles/Capture/HexModelImport.cs.meta
new file mode 100644
index 000000000..14ebb70aa
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexModelImport.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: e8f95aa540e2f4260ab894b84246dbb2
\ No newline at end of file
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexRealMapCapture.cs b/unity/Assets/Editor/HexTiles/Capture/HexRealMapCapture.cs
new file mode 100644
index 000000000..07ed6303e
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexRealMapCapture.cs
@@ -0,0 +1,70 @@
+#nullable enable
+using System;
+using System.IO;
+using System.Linq;
+using Statecraft.Game.Map;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using Debug = UnityEngine.Debug;
+using Object = UnityEngine.Object;
+
+namespace Statecraft.HexTiles.Capture
+{
+ /// <summary>The hex board on the game's real map (Map.unity, built as the game builds it, never saved): the board's
+ /// hexes are the game's own q/r, so its root sits at (0, sea level, map length) with no turn or scale. Under the
+ /// board the real ground is eased down to the board's own hex-shaped ground (blending out over about one hex), the
+ /// board's terrain is cut away everywhere but its land hexes so the real coast, sea and country show around it, and
+ /// the real settlement markers inside the board are hidden (the tiles replace them). Editor proof of the in-game
+ /// layer: shots country.png (the board inside Israel), area.png, and per tile &lt;id&gt;-real.png.
+ /// Unity -batchmode ... -executeMethod Statecraft.HexTiles.Capture.HexRealMapCapture.Run [-board tel_aviv]</summary>
+ public static class HexRealMapCapture
+ {
+ const string ScenePath = "Assets/Map.unity";
+
+ [MenuItem("Statecraft/Hex Tiles/Capture Board On Real Map")]
+ public static void Run()
+ {
+ try
+ {
+ var repo = Path.GetFullPath(Path.Combine(Application.dataPath, "..", ".."));
+ var dir = Path.GetFullPath(Path.Combine(repo, HexBoardCapture.Arg("-captureDir") ?? "asset-staging/ui-local/hex-tiles/real-map"));
+ var size = (HexBoardCapture.Arg("-captureSize") ?? "3840x2160").Split('x');
+ Capture(HexBoardCapture.Arg("-board") ?? HexTilesLook.Board, dir, int.Parse(size[0]), int.Parse(size[1]));
+ }
+ catch (Exception e)
+ {
+ Debug.LogError("HEX REAL MAP FAILED " + e);
+ if (Application.isBatchMode) EditorApplication.Exit(1);
+ else throw;
+ }
+ }
+
+ static void Capture(string boardId, string dir, int width, int height)
+ {
+ EditorSceneManager.OpenScene(ScenePath, OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>() ?? throw new InvalidOperationException("Map.unity has no MapScene");
+ map.Build();
+ var board = HexBoardCapture.LoadBoard(boardId);
+ // The same placement the game uses behind ?hex-tiles (HexRealMap), here with the editor's ground textures.
+ var (root, reports) = HexRealMap.Place(map, board, HexBoardCapture.Ground);
+ var surface = new HexBoardSurface(board);
+ var origin = root.transform.position;
+ var centres = board.Hexes.Values.Select(h => HexGeometry.Centre(h.q, h.r, HexScale.HexM)).ToList();
+ Directory.CreateDirectory(dir);
+ var cam = Camera.main ?? throw new InvalidOperationException("no main camera");
+ try
+ {
+ Vector3 World(Vector3 b) => origin + new Vector3(b.x, Mathf.Max(surface.Height(b), 0f), b.z);
+ var middle = new Vector3(centres.Average(c => c.x), 0f, centres.Average(c => c.z));
+ HexBoardCapture.Shoot(cam, World(middle), 230000f, Path.Combine(dir, "country.png"), width, height);
+ HexBoardCapture.Shoot(cam, World(middle), 125000f, Path.Combine(dir, "area.png"), width, height);
+ foreach (var h in board.Hexes.Values.Where(h => h.prototype is "tel_aviv_city" or "jerusalem_old_city" or "jaffa_old_city" or "kibbutz" || h.unit != "")
+ .GroupBy(h => h.unit != "" ? "unit-" + h.unit : h.prototype).Select(g => g.First()))
+ HexBoardCapture.Shoot(cam, World(HexGeometry.Centre(h.q, h.r, HexScale.HexM)), 20000f, Path.Combine(dir, $"{(h.unit != "" ? "unit-" + h.unit : h.prototype)}-real.png"), width, height);
+ Debug.Log($"HEX REAL MAP board {boardId} at {origin}, {reports.Count} tiles and units -> {dir}");
+ }
+ finally { TiltShift.Reset(); Object.DestroyImmediate(root); }
+ }
+ }
+}
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexRealMapCapture.cs.meta b/unity/Assets/Editor/HexTiles/Capture/HexRealMapCapture.cs.meta
new file mode 100644
index 000000000..4aa9a9557
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexRealMapCapture.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 1da99d5625a7a43c79e07d70a06ee64b
\ No newline at end of file
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexTilesAssets.cs b/unity/Assets/Editor/HexTiles/Capture/HexTilesAssets.cs
new file mode 100644
index 000000000..22b54ec96
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexTilesAssets.cs
@@ -0,0 +1,40 @@
+#nullable enable
+using System.IO;
+using UnityEditor;
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Capture
+{
+ /// <summary>Editor-made assets the hex-tile map needs in a player build: the material templates (tracked, in
+ /// Resources/HexTiles/Materials, so their shaders and variants ship), and a local copy of the ground textures in the
+ /// git-ignored prototype Resources (Poly Haven CC0 and our generated crop rows; local until their asset batch).
+ /// Unity -batchmode ... -executeMethod Statecraft.HexTiles.Capture.HexTilesAssets.Run</summary>
+ public static class HexTilesAssets
+ {
+ const string Materials = "Assets/Resources/" + HexMaterials.Folder;
+ const string GroundSource = "Assets/Art/Settlements/Prototype/HexSandboxGround", GroundLocal = "Assets/Art/Settlements/Prototype/Resources/HexTiles/Ground";
+
+ [MenuItem("Statecraft/Hex Tiles/Make Materials And Local Ground")]
+ public static void Run()
+ {
+ Directory.CreateDirectory(Materials);
+ foreach (var name in new[] { HexMaterials.Terrain, HexMaterials.TerrainHoles, HexMaterials.Lit, HexMaterials.Sea, HexMaterials.Edges })
+ {
+ var path = $"{Materials}/{name}.mat";
+ var m = HexMaterials.New(name); // no template yet: built from the shader with the right keywords
+ if (name == HexMaterials.Lit) m.SetFloat("_Smoothness", 0.05f);
+ AssetDatabase.DeleteAsset(path); AssetDatabase.CreateAsset(m, path);
+ }
+ if (Directory.Exists(GroundSource))
+ {
+ Directory.CreateDirectory(GroundLocal);
+ foreach (var f in Directory.GetFiles(GroundSource, "*.jpg")) File.Copy(f, Path.Combine(GroundLocal, Path.GetFileName(f)), true);
+ AssetDatabase.Refresh();
+ foreach (var f in Directory.GetFiles(GroundLocal, "*_nor_gl_2k.jpg"))
+ if (AssetImporter.GetAtPath(f) is TextureImporter ti && ti.textureType != TextureImporterType.NormalMap) { ti.textureType = TextureImporterType.NormalMap; ti.SaveAndReimport(); }
+ }
+ AssetDatabase.SaveAssets();
+ Debug.Log("HEX TILES ASSETS materials and local ground ready");
+ }
+ }
+}
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexTilesAssets.cs.meta b/unity/Assets/Editor/HexTiles/Capture/HexTilesAssets.cs.meta
new file mode 100644
index 000000000..6ca427bd8
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexTilesAssets.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 368a97c7d02b649e2bdb1c71449eff7c
\ No newline at end of file
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexUnitMoveCapture.cs b/unity/Assets/Editor/HexTiles/Capture/HexUnitMoveCapture.cs
new file mode 100644
index 000000000..878b5cde7
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexUnitMoveCapture.cs
@@ -0,0 +1,103 @@
+#nullable enable
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Linq;
+using Statecraft.Game.Map;
+using UnityEditor;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using Debug = UnityEngine.Debug;
+using Object = UnityEngine.Object;
+
+namespace Statecraft.HexTiles.Capture
+{
+ /// <summary>Renders a unit marching across hexes on a board, as a frame sequence and an MP4 (ffmpeg, when on PATH):
+ /// the Palmach squad (eight 13 October Tripo soldiers with walk and idle clips) marches east into the next hex, turns
+ /// at its centre and goes on south-east, while the sandwich armoured truck drives north up the plain, wheels turning.
+ /// Units are a layer above the tiles, so the land under them never changes. The camera frames both.
+ /// Unity -batchmode ... -executeMethod Statecraft.HexTiles.Capture.HexUnitMoveCapture.Run [-captureDir ...] [-captureSize 1920x1080]</summary>
+ public static class HexUnitMoveCapture
+ {
+ const int Fps = 24, HoldFrames = 14, MoveFrames = 132;
+ const float FollowDistanceM = 24000f;
+ /// <summary>The squad marches east then south-east; the armoured truck drives north up the coast at the same time.</summary>
+ static readonly (string unit, (int q, int r)[] route)[] Moves =
+ {
+ ("palmach_squad", new[] { (-2, 18), (-1, 18), (-1, 19) }),
+ ("sandwich_truck", new[] { (0, 19), (0, 18), (0, 17) }),
+ };
+
+ [MenuItem("Statecraft/Hex Tiles/Capture Unit Move")]
+ public static void Run()
+ {
+ try
+ {
+ var repo = Path.GetFullPath(Path.Combine(Application.dataPath, "..", ".."));
+ var dir = Path.GetFullPath(Path.Combine(repo, HexBoardCapture.Arg("-captureDir") ?? "asset-staging/ui-local/hex-tiles/unit-move"));
+ var size = (HexBoardCapture.Arg("-captureSize") ?? "1920x1080").Split('x');
+ Capture(dir, int.Parse(size[0]), int.Parse(size[1]));
+ }
+ catch (Exception e)
+ {
+ Debug.LogError("HEX UNIT MOVE FAILED " + e);
+ if (Application.isBatchMode) EditorApplication.Exit(1);
+ else throw;
+ }
+ }
+
+ static void Capture(string dir, int width, int height)
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ var board = HexBoardCapture.LoadBoard("tel_aviv");
+ foreach (var h in board.Hexes.Values) h.unit = ""; // the moving units replace the board's standing ones
+ var cam = HexBoardCapture.Stage();
+ var (root, _) = HexBoardBuilder.Build(board, HexBoardCapture.Ground);
+ var units = new GameObject("Units").transform;
+ var surface = new HexBoardSurface(board);
+ var motions = Moves.Select(m => new HexUnitMotion(HexUnitTypes.Create(m.unit).Create(), m.route, surface, units)).ToList();
+ if (Directory.Exists(dir)) foreach (var f in Directory.GetFiles(dir, "frame-*.png")) File.Delete(f);
+ Directory.CreateDirectory(dir);
+ var clock = Stopwatch.StartNew();
+ int frame = 0;
+ try
+ {
+ // Every unit covers its own path over the same frames; the camera frames them all.
+ void Shot(float progress, bool moving)
+ {
+ var at = Vector3.zero;
+ foreach (var m in motions) at += m.Pose(progress * m.Length, moving);
+ HexBoardCapture.Shoot(cam, at / motions.Count, FollowDistanceM, Path.Combine(dir, $"frame-{frame++:0000}.png"), width, height);
+ }
+ for (int i = 0; i < HoldFrames; i++) Shot(0f, false);
+ for (int i = 0; i <= MoveFrames; i++)
+ {
+ float u = i / (float)MoveFrames;
+ Shot(u * u * (3f - 2f * u), i > 0 && i < MoveFrames); // start and stop gently
+ }
+ for (int i = 0; i < HoldFrames; i++) Shot(1f, false);
+ }
+ finally { Object.DestroyImmediate(units.gameObject); Object.DestroyImmediate(root); TiltShift.Reset(); }
+ var mp4 = Path.Combine(dir, "unit-move.mp4");
+ var ok = Encode(dir, mp4);
+ Debug.Log($"HEX UNIT MOVE {frame} frames in {clock.ElapsedMilliseconds} ms, paths {string.Join(", ", motions.Select(m => m.Length.ToString("0")))} m -> {(ok ? mp4 : dir)}");
+ }
+
+ static bool Encode(string dir, string mp4)
+ {
+ foreach (var ffmpeg in new[] { "ffmpeg", "/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg", Path.Combine(Environment.GetEnvironmentVariable("HOME") ?? "", "miniconda3/bin/ffmpeg") })
+ {
+ try
+ {
+ var p = Process.Start(new ProcessStartInfo(ffmpeg, $"-y -framerate {Fps} -i \"{dir}/frame-%04d.png\" -c:v libx264 -pix_fmt yuv420p -crf 18 \"{mp4}\"")
+ { UseShellExecute = false, RedirectStandardError = true, CreateNoWindow = true });
+ if (p == null) continue;
+ p.StandardError.ReadToEnd(); p.WaitForExit();
+ if (p.ExitCode == 0) return true;
+ }
+ catch (System.ComponentModel.Win32Exception) { }
+ }
+ return false;
+ }
+ }
+}
diff --git a/unity/Assets/Editor/HexTiles/Capture/HexUnitMoveCapture.cs.meta b/unity/Assets/Editor/HexTiles/Capture/HexUnitMoveCapture.cs.meta
new file mode 100644
index 000000000..7883bc1bb
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Capture/HexUnitMoveCapture.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 741b80594cb4847ada5f47fe87169925
\ No newline at end of file
diff --git a/unity/Assets/Editor/HexTiles/Statecraft.HexTiles.Editor.asmdef b/unity/Assets/Editor/HexTiles/Statecraft.HexTiles.Editor.asmdef
new file mode 100644
index 000000000..dff577eba
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Statecraft.HexTiles.Editor.asmdef
@@ -0,0 +1,9 @@
+{
+ "name": "Statecraft.HexTiles.Editor",
+ "rootNamespace": "Statecraft.HexTiles",
+ "references": ["Statecraft.Game", "Unity.RenderPipelines.Core.Runtime", "Unity.RenderPipelines.Universal.Runtime"],
+ "includePlatforms": ["Editor"],
+ "allowUnsafeCode": false,
+ "autoReferenced": true,
+ "noEngineReferences": false
+}
diff --git a/unity/Assets/Editor/HexTiles/Statecraft.HexTiles.Editor.asmdef.meta b/unity/Assets/Editor/HexTiles/Statecraft.HexTiles.Editor.asmdef.meta
new file mode 100644
index 000000000..28a05f694
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Statecraft.HexTiles.Editor.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 65beb282e1e5c4e3ea7ee7cfa07e1f95
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Editor/HexTiles/Tests.meta b/unity/Assets/Editor/HexTiles/Tests.meta
new file mode 100644
index 000000000..0f0fb585f
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Tests.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 595c4e4fa59c142be850b6293cadb95d
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Editor/HexTiles/Tests/HexPrototypeTests.cs b/unity/Assets/Editor/HexTiles/Tests/HexPrototypeTests.cs
new file mode 100644
index 000000000..5a7b648d2
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Tests/HexPrototypeTests.cs
@@ -0,0 +1,91 @@
+#nullable enable
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.RegularExpressions;
+using NUnit.Framework;
+using Statecraft.HexTiles;
+using Statecraft.HexTiles.Capture;
+using UnityEditor;
+
+/// <summary>The contract every hex prototype keeps, checked for each one registered (so a new file is tested with no
+/// edit here): a lower_snake_case id; the same placements for the same seed; every piece inside its inset hexagon; at
+/// most its triangle budget (with the models on this machine, else stand-ins); and every board names known prototypes.</summary>
+public class HexPrototypeTests
+{
+ static IEnumerable<string> Ids() => HexPrototypes.All.Keys.OrderBy(k => k);
+
+ static HexTileContext Built(string id, int seed = 1948)
+ {
+ var ctx = new HexTileContext(2, -1, new FlatSurface(), seed);
+ HexPrototypes.Create(id).Build(ctx);
+ return ctx;
+ }
+
+ [Test] public void SomePrototypesAreRegistered() => Assert.That(HexPrototypes.All.Count, Is.GreaterThan(0));
+
+ [TestCaseSource(nameof(Ids))]
+ public void IdIsLowerSnakeCase(string id) => Assert.That(Regex.IsMatch(id, "^[a-z][a-z0-9_]*$"), id);
+
+ [TestCaseSource(nameof(Ids))]
+ public void BuildsSomething(string id) => Assert.That(Built(id).Placements.Count, Is.GreaterThan(0), id);
+
+ [TestCaseSource(nameof(Ids))]
+ public void IsDeterministic(string id)
+ {
+ var a = Built(id).Placements.Select(p => (p.Model, p.Matrix)).ToList();
+ var b = Built(id).Placements.Select(p => (p.Model, p.Matrix)).ToList();
+ CollectionAssert.AreEqual(a, b, id);
+ }
+
+ [TestCaseSource(nameof(Ids))]
+ public void StaysInsideItsHex(string id)
+ {
+ var ctx = Built(id);
+ foreach (var p in ctx.Placements)
+ Assert.That(HexGeometry.InHex(p.Position, ctx.Centre, ctx.SizeM, ctx.InsetM - 1f), $"{id}: {p.Model} at {p.Position} is outside its inset hexagon");
+ }
+
+ [TestCaseSource(nameof(Ids))]
+ public void KeepsToItsTriangleBudget(string id)
+ {
+ var proto = HexPrototypes.Create(id);
+ var ctx = Built(id);
+ int tris = ctx.Placements.Sum(p => p.StandIn == StandIn.Flat ? 12 : HexModels.Triangles(p.Model, p.StandIn, p.Position));
+ Assert.That(tris, Is.LessThanOrEqualTo(proto.TriangleBudget), $"{id}: {tris} triangles");
+ }
+
+ [TestCase("https://x/?hex-tiles", "central_israel")]
+ [TestCase("https://x/?a=1&hex-tiles=1", "central_israel")]
+ [TestCase("https://x/?hex-tiles=tel_aviv_crop&b=2", "tel_aviv_crop")]
+ [TestCase("https://x/?hex-tilesx", null)]
+ [TestCase("https://x/#?hex-tiles", null)]
+ [TestCase("https://x/", null)]
+ public void SwitchPicksTheBoardOnTheWeb(string url, string? board) =>
+ Assert.That(HexTilesLook.RequestedBoard(url, new string[0], true), Is.EqualTo(board));
+
+ [Test]
+ public void SwitchPicksTheBoardOnDesktop()
+ {
+ Assert.That(HexTilesLook.RequestedBoard(null, new[] { "app" }, false), Is.Null);
+ Assert.That(HexTilesLook.RequestedBoard(null, new[] { "app", "-hex-tiles" }, false), Is.EqualTo(HexTilesLook.Board));
+ Assert.That(HexTilesLook.RequestedBoard(null, new[] { "app", "-hex-tiles", "-ui-preview" }, false), Is.EqualTo(HexTilesLook.Board));
+ Assert.That(HexTilesLook.RequestedBoard(null, new[] { "app", "-hex-tiles", "tel_aviv_crop" }, false), Is.EqualTo("tel_aviv_crop"));
+ }
+
+ [Test]
+ public void BoardsNameKnownPrototypesAndTerrains()
+ {
+ foreach (var guid in AssetDatabase.FindAssets("t:TextAsset", new[] { HexBoardCapture.BoardsFolder }))
+ {
+ var path = AssetDatabase.GUIDToAssetPath(guid);
+ var name = System.IO.Path.GetFileNameWithoutExtension(path);
+ var board = HexBoardCapture.LoadBoard(name);
+ foreach (var h in board.Hexes.Values)
+ {
+ Assert.That(new[] { "flat", "hills", "mountain", "water" }, Does.Contain(h.terrain), $"{name} ({h.q},{h.r})");
+ Assert.That(HexGround.Ids, Does.Contain(h.ground), $"{name} ({h.q},{h.r})");
+ if (h.prototype != "") Assert.That(HexPrototypes.All.ContainsKey(h.prototype), $"{name} ({h.q},{h.r}): no prototype '{h.prototype}'");
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Editor/HexTiles/Tests/HexPrototypeTests.cs.meta b/unity/Assets/Editor/HexTiles/Tests/HexPrototypeTests.cs.meta
new file mode 100644
index 000000000..9e21f1345
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Tests/HexPrototypeTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c3183473079254a65833b3719f91f764
\ No newline at end of file
diff --git a/unity/Assets/Editor/HexTiles/Tests/Statecraft.HexTiles.Tests.asmdef b/unity/Assets/Editor/HexTiles/Tests/Statecraft.HexTiles.Tests.asmdef
new file mode 100644
index 000000000..eb65ab490
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Tests/Statecraft.HexTiles.Tests.asmdef
@@ -0,0 +1,8 @@
+{
+ "name": "Statecraft.HexTiles.Tests",
+ "references": ["Statecraft.HexTiles.Editor", "Statecraft.Game", "UnityEngine.TestRunner", "UnityEditor.TestRunner"],
+ "includePlatforms": ["Editor"],
+ "overrideReferences": true,
+ "precompiledReferences": ["nunit.framework.dll"],
+ "defineConstraints": ["UNITY_INCLUDE_TESTS"]
+}
diff --git a/unity/Assets/Editor/HexTiles/Tests/Statecraft.HexTiles.Tests.asmdef.meta b/unity/Assets/Editor/HexTiles/Tests/Statecraft.HexTiles.Tests.asmdef.meta
new file mode 100644
index 000000000..8ee5dbb7c
--- /dev/null
+++ b/unity/Assets/Editor/HexTiles/Tests/Statecraft.HexTiles.Tests.asmdef.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 1b9a8372a3a944e8e9688407ac7a1316
+AssemblyDefinitionImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles.meta b/unity/Assets/Resources/HexTiles.meta
new file mode 100644
index 000000000..73ce21d9e
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f9620b43c2972405b8c53300a23b9fb7
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Boards.meta b/unity/Assets/Resources/HexTiles/Boards.meta
new file mode 100644
index 000000000..f157a34f4
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 5cba12a9d15104fd69a987d37e91b7e6
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Boards/central_israel.json b/unity/Assets/Resources/HexTiles/Boards/central_israel.json
new file mode 100644
index 000000000..d70742126
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards/central_israel.json
@@ -0,0 +1,1225 @@
+{
+ "id": "central_israel",
+ "title": "central_israel (generated by tools/hex_tiles/make_board.py; lat [31.62, 32.48], lon [34.4, 35.42])",
+ "hexes": [
+ {
+ "q": 0,
+ "r": 13,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 13,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "hadera",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 13,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 13,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 4,
+ "r": 13,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 5,
+ "r": 13,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 6,
+ "r": 13,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 14,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 14,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 14,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 14,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 4,
+ "r": 14,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 5,
+ "r": 14,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 6,
+ "r": 14,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 15,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 15,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "netanya",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 15,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 15,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 15,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 4,
+ "r": 15,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 5,
+ "r": 15,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 16,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 16,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 16,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 4,
+ "r": 16,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 5,
+ "r": 16,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 17,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 17,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 17,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 17,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 17,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 17,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 4,
+ "r": 17,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 18,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 18,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 18,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 4,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 19,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "tel_aviv_city",
+ "note": "tel_aviv",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "petah_tikva",
+ "unit": "palmach_squad",
+ "facing": 40.0
+ },
+ {
+ "q": -1,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 19,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 19,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 19,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 20,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "jaffa_old_city",
+ "note": "jaffa",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "rishon_lezion",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 20,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 20,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 20,
+ "terrain": "mountain",
+ "ground": "mountain",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 3,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 21,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "arab_village",
+ "note": "ramla",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "arab_village",
+ "note": "lod",
+ "unit": "sandwich_truck",
+ "facing": 100.0
+ },
+ {
+ "q": -2,
+ "r": 21,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 21,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 21,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 21,
+ "terrain": "mountain",
+ "ground": "mountain",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 21,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 22,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "rehovot",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 22,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 22,
+ "terrain": "mountain",
+ "ground": "mountain",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 22,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 2,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -7,
+ "r": 23,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 23,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 23,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 23,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 23,
+ "terrain": "mountain",
+ "ground": "mountain",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 23,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "jerusalem_old_city",
+ "note": "jerusalem",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "willys_jeep",
+ "facing": 270.0
+ },
+ {
+ "q": -8,
+ "r": 24,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -7,
+ "r": 24,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 24,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 24,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 24,
+ "terrain": "mountain",
+ "ground": "mountain",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 24,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 1,
+ "r": 24,
+ "terrain": "flat",
+ "ground": "desert",
+ "prototype": "desert_edge",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -9,
+ "r": 25,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -8,
+ "r": 25,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -7,
+ "r": 25,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 25,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 25,
+ "terrain": "mountain",
+ "ground": "mountain",
+ "prototype": "judean_highlands",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 25,
+ "terrain": "mountain",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ }
+ ],
+ "roads": [
+ {
+ "note": "tel_aviv to lod",
+ "hexes": [
+ -3,
+ 19,
+ -3,
+ 20,
+ -3,
+ 21
+ ]
+ },
+ {
+ "note": "lod to ramla",
+ "hexes": [
+ -3,
+ 21,
+ -4,
+ 21
+ ]
+ },
+ {
+ "note": "ramla to jerusalem",
+ "hexes": [
+ -4,
+ 21,
+ -3,
+ 21,
+ -3,
+ 22,
+ -2,
+ 22,
+ -1,
+ 22,
+ -1,
+ 23,
+ 0,
+ 23
+ ]
+ },
+ {
+ "note": "tel_aviv to petah_tikva",
+ "hexes": [
+ -3,
+ 19,
+ -2,
+ 19
+ ]
+ },
+ {
+ "note": "tel_aviv to rishon_lezion",
+ "hexes": [
+ -3,
+ 19,
+ -3,
+ 20
+ ]
+ },
+ {
+ "note": "rishon_lezion to rehovot",
+ "hexes": [
+ -3,
+ 20,
+ -3,
+ 21,
+ -4,
+ 22
+ ]
+ },
+ {
+ "note": "tel_aviv to netanya",
+ "hexes": [
+ -3,
+ 19,
+ -2,
+ 18,
+ -1,
+ 17,
+ -1,
+ 16,
+ 0,
+ 15
+ ]
+ },
+ {
+ "note": "netanya to hadera",
+ "hexes": [
+ 0,
+ 15,
+ 1,
+ 14,
+ 1,
+ 13
+ ]
+ },
+ {
+ "note": "jaffa to tel_aviv",
+ "hexes": [
+ -4,
+ 20,
+ -3,
+ 19
+ ]
+ }
+ ],
+ "rivers": [
+ {
+ "note": "The Yarkon",
+ "corners": [
+ -4,
+ 19,
+ 0,
+ -3,
+ 19,
+ 5,
+ -3,
+ 19,
+ 0,
+ -3,
+ 19,
+ 1,
+ -2,
+ 19,
+ 0,
+ -2,
+ 19,
+ 1,
+ -1,
+ 19,
+ 0,
+ -1,
+ 19,
+ 1,
+ 0,
+ 19,
+ 0
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/unity/Assets/Resources/HexTiles/Boards/central_israel.json.meta b/unity/Assets/Resources/HexTiles/Boards/central_israel.json.meta
new file mode 100644
index 000000000..ce4b2d305
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards/central_israel.json.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 68bcc9fdd727b4adab05e97e74f209c9
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Boards/tel_aviv.json b/unity/Assets/Resources/HexTiles/Boards/tel_aviv.json
new file mode 100644
index 000000000..5230ea2c6
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards/tel_aviv.json
@@ -0,0 +1,456 @@
+{
+ "id": "tel_aviv",
+ "title": "Tel Aviv prototype board (radius 3, game q/r)",
+ "hexes": [
+ {
+ "q": -3,
+ "r": 16,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 16,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 17,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 17,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 17,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 17,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "Sand dunes north of the city",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 17,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 18,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 18,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 18,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "plains",
+ "prototype": "wheat_fields",
+ "note": "A Palmach squad on the farmland north-east of the city",
+ "unit": "palmach_squad",
+ "facing": 40.0
+ },
+ {
+ "q": -1,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 19,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 19,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 19,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "plains",
+ "prototype": "tel_aviv_city",
+ "note": "Tel Aviv core",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": 0,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "An armoured truck heading for the Jerusalem road",
+ "unit": "sandwich_truck",
+ "facing": 300.0
+ },
+ {
+ "q": -6,
+ "r": 20,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 20,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "Jaffa orange groves toward Rishon",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "arab_village",
+ "note": "A stone hill village toward Lydda",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -1,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "pine_forest",
+ "note": "JNF pine on the first foothills",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 21,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "Dunes south of Jaffa",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "plains",
+ "prototype": "moshava_village",
+ "note": "A moshava toward Rishon LeZion",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -2,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -6,
+ "r": 22,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -5,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -4,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ },
+ {
+ "q": -3,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "context",
+ "unit": "",
+ "facing": 0.0
+ }
+ ],
+ "rivers": [
+ {
+ "note": "The Yarkon, along the north edges of the Tel Aviv row, out to the sea",
+ "corners": [
+ -4,
+ 19,
+ 0,
+ -3,
+ 19,
+ 5,
+ -3,
+ 19,
+ 0,
+ -3,
+ 19,
+ 1,
+ -2,
+ 19,
+ 0,
+ -2,
+ 19,
+ 1,
+ -1,
+ 19,
+ 0,
+ -1,
+ 19,
+ 1,
+ 0,
+ 19,
+ 0
+ ]
+ }
+ ],
+ "roads": [
+ {
+ "note": "Tel Aviv to the Jerusalem road",
+ "hexes": [
+ -3,
+ 19,
+ -2,
+ 19,
+ -1,
+ 19,
+ 0,
+ 19
+ ]
+ },
+ {
+ "note": "Tel Aviv south to the moshava",
+ "hexes": [
+ -3,
+ 19,
+ -3,
+ 20,
+ -3,
+ 21
+ ]
+ },
+ {
+ "note": "To the hill village",
+ "hexes": [
+ -3,
+ 20,
+ -2,
+ 20
+ ]
+ },
+ {
+ "note": "North across the Yarkon",
+ "hexes": [
+ -3,
+ 19,
+ -2,
+ 18,
+ -1,
+ 17
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/unity/Assets/Resources/HexTiles/Boards/tel_aviv.json.meta b/unity/Assets/Resources/HexTiles/Boards/tel_aviv.json.meta
new file mode 100644
index 000000000..b636ae163
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards/tel_aviv.json.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: f72cb2aa49b1f4829b27fc09f798e2f9
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Boards/tel_aviv_crop.json b/unity/Assets/Resources/HexTiles/Boards/tel_aviv_crop.json
new file mode 100644
index 000000000..b171817e7
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards/tel_aviv_crop.json
@@ -0,0 +1,1024 @@
+{
+ "id": "tel_aviv_crop",
+ "title": "tel_aviv_crop (generated by tools/hex_tiles/make_board.py; lat [31.64424, 32.47821], lon [34.23557, 35.3493]; then hand-tuned: (-1,20) and (0,18) pine_forest, (-2,21) grazing_land for variety)",
+ "hexes": [
+ {
+ "q": 0,
+ "r": 13,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 1,
+ "r": 13,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 13,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 13,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 0,
+ "r": 14,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 1,
+ "r": 14,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 14,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 14,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -1,
+ "r": 15,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 0,
+ "r": 15,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 1,
+ "r": 15,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 15,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 15,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -2,
+ "r": 16,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -1,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "beach",
+ "prototype": "coastal_dunes",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 0,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 1,
+ "r": 16,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 16,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 16,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -2,
+ "r": 17,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -1,
+ "r": 17,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 0,
+ "r": 17,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 1,
+ "r": 17,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 17,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 17,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -3,
+ "r": 18,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -2,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -1,
+ "r": 18,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "wheat_fields",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 0,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 1,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 18,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -4,
+ "r": 19,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -3,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "tel_aviv_city",
+ "note": "tel_aviv",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -2,
+ "r": 19,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "petah_tikva",
+ "unit": "palmach_squad",
+ "facing": 40.0,
+ "env": false
+ },
+ {
+ "q": -1,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 0,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 1,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 3,
+ "r": 19,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -5,
+ "r": 20,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -4,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "jaffa_old_city",
+ "note": "jaffa",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -3,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "rishon_lezion",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -2,
+ "r": 20,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -1,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "pine_forest",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": 0,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 1,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 2,
+ "r": 20,
+ "terrain": "hills",
+ "ground": "mountain",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -6,
+ "r": 21,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -5,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "citrus_orchard",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -4,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "arab_village",
+ "note": "ramla",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -3,
+ "r": 21,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "arab_village",
+ "note": "lod",
+ "unit": "sandwich_truck",
+ "facing": 100.0,
+ "env": false
+ },
+ {
+ "q": -2,
+ "r": 21,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -1,
+ "r": 21,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 0,
+ "r": 21,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 1,
+ "r": 21,
+ "terrain": "hills",
+ "ground": "mountain",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -6,
+ "r": 22,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -5,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "grazing_land",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -4,
+ "r": 22,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "moshava_village",
+ "note": "rehovot",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -3,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "olive_terraces",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": false
+ },
+ {
+ "q": -2,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -1,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": 0,
+ "r": 22,
+ "terrain": "hills",
+ "ground": "mountain",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -7,
+ "r": 23,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -6,
+ "r": 23,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -5,
+ "r": 23,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -4,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -3,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -2,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -1,
+ "r": 23,
+ "terrain": "hills",
+ "ground": "mountain",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -8,
+ "r": 24,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -7,
+ "r": 24,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -6,
+ "r": 24,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -5,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -4,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -3,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -2,
+ "r": 24,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -9,
+ "r": 25,
+ "terrain": "water",
+ "ground": "seabed",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -8,
+ "r": 25,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -7,
+ "r": 25,
+ "terrain": "flat",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -6,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "grass",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -5,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -4,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ },
+ {
+ "q": -3,
+ "r": 25,
+ "terrain": "hills",
+ "ground": "hills",
+ "prototype": "",
+ "note": "",
+ "unit": "",
+ "facing": 0.0,
+ "env": true
+ }
+ ],
+ "roads": [
+ {
+ "note": "tel_aviv to lod",
+ "hexes": [
+ -3,
+ 19,
+ -3,
+ 20,
+ -3,
+ 21
+ ]
+ },
+ {
+ "note": "lod to ramla",
+ "hexes": [
+ -3,
+ 21,
+ -4,
+ 21
+ ]
+ },
+ {
+ "note": "tel_aviv to petah_tikva",
+ "hexes": [
+ -3,
+ 19,
+ -2,
+ 19
+ ]
+ },
+ {
+ "note": "tel_aviv to rishon_lezion",
+ "hexes": [
+ -3,
+ 19,
+ -3,
+ 20
+ ]
+ },
+ {
+ "note": "rishon_lezion to rehovot",
+ "hexes": [
+ -3,
+ 20,
+ -3,
+ 21,
+ -4,
+ 22
+ ]
+ },
+ {
+ "note": "jaffa to tel_aviv",
+ "hexes": [
+ -4,
+ 20,
+ -3,
+ 19
+ ]
+ }
+ ],
+ "rivers": [
+ {
+ "note": "The Yarkon",
+ "corners": [
+ -4,
+ 19,
+ 0,
+ -3,
+ 19,
+ 5,
+ -3,
+ 19,
+ 0,
+ -3,
+ 19,
+ 1,
+ -2,
+ 19,
+ 0,
+ -2,
+ 19,
+ 1,
+ -1,
+ 19,
+ 0,
+ -1,
+ 19,
+ 1,
+ 0,
+ 19,
+ 0
+ ]
+ }
+ ]
+}
diff --git a/unity/Assets/Resources/HexTiles/Boards/tel_aviv_crop.json.meta b/unity/Assets/Resources/HexTiles/Boards/tel_aviv_crop.json.meta
new file mode 100644
index 000000000..ff221150a
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Boards/tel_aviv_crop.json.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 91cad5031890543b49f6c98fff914332
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Materials.meta b/unity/Assets/Resources/HexTiles/Materials.meta
new file mode 100644
index 000000000..074e49691
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 1929197a4b1cf4b1d826a08ccd25d648
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexEdges.mat b/unity/Assets/Resources/HexTiles/Materials/HexEdges.mat
new file mode 100644
index 000000000..5298b272a
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexEdges.mat
@@ -0,0 +1,74 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: HexEdges
+ m_Shader: {fileID: 4800000, guid: 650dd9526735d5b46b79224bc6e94025, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords:
+ - _SURFACE_TYPE_TRANSPARENT
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 0
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: 3000
+ stringTagMap:
+ RenderType: Transparent
+ disabledShaderPasses:
+ - DepthOnly
+ - SHADOWCASTER
+ - MOTIONVECTORS
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _BaseMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _AddPrecomputedVelocity: 0
+ - _AlphaClip: 0
+ - _AlphaToMask: 0
+ - _Blend: 0
+ - _BlendOp: 0
+ - _Cull: 2
+ - _Cutoff: 0.5
+ - _DstBlend: 10
+ - _DstBlendAlpha: 10
+ - _QueueOffset: 0
+ - _SampleGI: 0
+ - _SrcBlend: 5
+ - _SrcBlendAlpha: 1
+ - _Surface: 1
+ - _XRMotionVectorsPass: 1
+ - _ZWrite: 0
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ - _Color: {r: 1, g: 1, b: 1, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
+--- !u!114 &4305725006763822463
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexEdges.mat.meta b/unity/Assets/Resources/HexTiles/Materials/HexEdges.mat.meta
new file mode 100644
index 000000000..1eb588b9e
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexEdges.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 049af6185344349df964355912e8a214
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexLit.mat b/unity/Assets/Resources/HexTiles/Materials/HexLit.mat
new file mode 100644
index 000000000..52857c066
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexLit.mat
@@ -0,0 +1,137 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &-6589213451243191791
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: HexLit
+ m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords: []
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 0
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap:
+ RenderType: Opaque
+ disabledShaderPasses:
+ - MOTIONVECTORS
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _BaseMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _BumpMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailAlbedoMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailMask:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailNormalMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _EmissionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MetallicGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _OcclusionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _ParallaxMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _SpecGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_Lightmaps:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_LightmapsInd:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_ShadowMasks:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _AddPrecomputedVelocity: 0
+ - _AlphaClip: 0
+ - _AlphaToMask: 0
+ - _Blend: 0
+ - _BlendModePreserveSpecular: 1
+ - _BumpScale: 1
+ - _ClearCoatMask: 0
+ - _ClearCoatSmoothness: 0
+ - _Cull: 2
+ - _Cutoff: 0.5
+ - _DetailAlbedoMapScale: 1
+ - _DetailNormalMapScale: 1
+ - _DstBlend: 0
+ - _DstBlendAlpha: 0
+ - _EnvironmentReflections: 1
+ - _GlossMapScale: 0
+ - _Glossiness: 0
+ - _GlossyReflections: 0
+ - _Metallic: 0
+ - _OcclusionStrength: 1
+ - _Parallax: 0.005
+ - _QueueOffset: 0
+ - _ReceiveShadows: 1
+ - _Smoothness: 0.05
+ - _SmoothnessTextureChannel: 0
+ - _SpecularHighlights: 1
+ - _SrcBlend: 1
+ - _SrcBlendAlpha: 1
+ - _Surface: 0
+ - _WorkflowMode: 1
+ - _XRMotionVectorsPass: 1
+ - _ZWrite: 1
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ - _Color: {r: 1, g: 1, b: 1, a: 1}
+ - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+ - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexLit.mat.meta b/unity/Assets/Resources/HexTiles/Materials/HexLit.mat.meta
new file mode 100644
index 000000000..a68d2d401
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexLit.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 664afe968d0294b68a28465d333b0faf
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexSea.mat b/unity/Assets/Resources/HexTiles/Materials/HexSea.mat
new file mode 100644
index 000000000..d36e9a0fa
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexSea.mat
@@ -0,0 +1,141 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: HexSea
+ m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords:
+ - _ALPHAPREMULTIPLY_ON
+ - _SURFACE_TYPE_TRANSPARENT
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 0
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: 3000
+ stringTagMap:
+ RenderType: Transparent
+ disabledShaderPasses:
+ - DepthOnly
+ - SHADOWCASTER
+ - MOTIONVECTORS
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _BaseMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _BumpMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailAlbedoMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailMask:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _DetailNormalMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _EmissionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MetallicGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _OcclusionMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _ParallaxMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _SpecGlossMap:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_Lightmaps:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_LightmapsInd:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - unity_ShadowMasks:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _AddPrecomputedVelocity: 0
+ - _AlphaClip: 0
+ - _AlphaToMask: 0
+ - _Blend: 0
+ - _BlendModePreserveSpecular: 1
+ - _BumpScale: 1
+ - _ClearCoatMask: 0
+ - _ClearCoatSmoothness: 0
+ - _Cull: 2
+ - _Cutoff: 0.5
+ - _DetailAlbedoMapScale: 1
+ - _DetailNormalMapScale: 1
+ - _DstBlend: 10
+ - _DstBlendAlpha: 10
+ - _EnvironmentReflections: 1
+ - _GlossMapScale: 0
+ - _Glossiness: 0
+ - _GlossyReflections: 0
+ - _Metallic: 0
+ - _OcclusionStrength: 1
+ - _Parallax: 0.005
+ - _QueueOffset: 0
+ - _ReceiveShadows: 1
+ - _Smoothness: 0.5
+ - _SmoothnessTextureChannel: 0
+ - _SpecularHighlights: 1
+ - _SrcBlend: 1
+ - _SrcBlendAlpha: 1
+ - _Surface: 1
+ - _WorkflowMode: 1
+ - _XRMotionVectorsPass: 1
+ - _ZWrite: 0
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ - _Color: {r: 1, g: 1, b: 1, a: 1}
+ - _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
+ - _SpecColor: {r: 0.19999996, g: 0.19999996, b: 0.19999996, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
+--- !u!114 &1676882310916126565
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexSea.mat.meta b/unity/Assets/Resources/HexTiles/Materials/HexSea.mat.meta
new file mode 100644
index 000000000..af28971c6
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexSea.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 37cbad055c1a0469087b423f6b9ca75c
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexTerrain.mat b/unity/Assets/Resources/HexTiles/Materials/HexTerrain.mat
new file mode 100644
index 000000000..f554aa025
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexTerrain.mat
@@ -0,0 +1,117 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!114 &-3511314588516722750
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: HexTerrain
+ m_Shader: {fileID: 4800000, guid: 69c1f799e772cb6438f56c23efccb782, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords:
+ - _NORMALMAP
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 0
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap: {}
+ disabledShaderPasses: []
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _Control:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask0:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask1:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask2:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask3:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal0:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal1:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal2:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal3:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat0:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat1:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat2:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat3:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _TerrainHolesTexture:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _EnableHeightBlend: 0
+ - _EnableInstancedPerPixelNormal: 1
+ - _HeightTransition: 0
+ - _Metallic0: 0
+ - _Metallic1: 0
+ - _Metallic2: 0
+ - _Metallic3: 0
+ - _NumLayersCount: 1
+ - _Smoothness0: 0.5
+ - _Smoothness1: 0.5
+ - _Smoothness2: 0.5
+ - _Smoothness3: 0.5
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexTerrain.mat.meta b/unity/Assets/Resources/HexTiles/Materials/HexTerrain.mat.meta
new file mode 100644
index 000000000..d8bac73ef
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexTerrain.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: afa8d72164fa14a17939292b2ec0e129
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexTerrainHoles.mat b/unity/Assets/Resources/HexTiles/Materials/HexTerrainHoles.mat
new file mode 100644
index 000000000..a4ec51d33
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexTerrainHoles.mat
@@ -0,0 +1,118 @@
+%YAML 1.1
+%TAG !u! tag:unity3d.com,2011:
+--- !u!21 &2100000
+Material:
+ serializedVersion: 8
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_Name: HexTerrainHoles
+ m_Shader: {fileID: 4800000, guid: 69c1f799e772cb6438f56c23efccb782, type: 3}
+ m_Parent: {fileID: 0}
+ m_ModifiedSerializedProperties: 0
+ m_ValidKeywords:
+ - _ALPHATEST_ON
+ - _NORMALMAP
+ m_InvalidKeywords: []
+ m_LightmapFlags: 4
+ m_EnableInstancingVariants: 0
+ m_DoubleSidedGI: 0
+ m_CustomRenderQueue: -1
+ stringTagMap: {}
+ disabledShaderPasses: []
+ m_LockedProperties:
+ m_SavedProperties:
+ serializedVersion: 3
+ m_TexEnvs:
+ - _Control:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _MainTex:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask0:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask1:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask2:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Mask3:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal0:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal1:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal2:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Normal3:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat0:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat1:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat2:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _Splat3:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ - _TerrainHolesTexture:
+ m_Texture: {fileID: 0}
+ m_Scale: {x: 1, y: 1}
+ m_Offset: {x: 0, y: 0}
+ m_Ints: []
+ m_Floats:
+ - _EnableHeightBlend: 0
+ - _EnableInstancedPerPixelNormal: 1
+ - _HeightTransition: 0
+ - _Metallic0: 0
+ - _Metallic1: 0
+ - _Metallic2: 0
+ - _Metallic3: 0
+ - _NumLayersCount: 1
+ - _Smoothness0: 0.5
+ - _Smoothness1: 0.5
+ - _Smoothness2: 0.5
+ - _Smoothness3: 0.5
+ m_Colors:
+ - _BaseColor: {r: 1, g: 1, b: 1, a: 1}
+ m_BuildTextureStacks: []
+ m_AllowLocking: 1
+--- !u!114 &4301519296966771095
+MonoBehaviour:
+ m_ObjectHideFlags: 11
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 0}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: d0353a89b1f911e48b9e16bdc9f2e058, type: 3}
+ m_Name:
+ m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Editor::UnityEditor.Rendering.Universal.AssetVersion
+ version: 10
diff --git a/unity/Assets/Resources/HexTiles/Materials/HexTerrainHoles.mat.meta b/unity/Assets/Resources/HexTiles/Materials/HexTerrainHoles.mat.meta
new file mode 100644
index 000000000..4a045637f
--- /dev/null
+++ b/unity/Assets/Resources/HexTiles/Materials/HexTerrainHoles.mat.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 111b2dbaeb55d47c0aa561f147ac2a4c
+NativeFormatImporter:
+ externalObjects: {}
+ mainObjectFileID: 2100000
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/HexTiles.meta b/unity/Assets/Scripts/Map/HexTiles.meta
new file mode 100644
index 000000000..da92f880d
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 2f5c8aee6b23b40f6b78d066826dabf0
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core.meta b/unity/Assets/Scripts/Map/HexTiles/Core.meta
new file mode 100644
index 000000000..5a8a91c72
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f7bb02ddad3d54555a26e30631bebccc
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexBoard.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoard.cs
new file mode 100644
index 000000000..83a6f1ac4
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoard.cs
@@ -0,0 +1,216 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>One hex of a board file. q and r are the game's own axial coordinates (content/map/hexes.json), so a board
+ /// maps one to one onto the map later. terrain: flat, hills, mountain or water. ground: a HexGround layer id. prototype:
+ /// a HexPrototype id, or empty for a context hex (ground only; a mountain context hex gets "mountain_peaks"). unit: an
+/// optional HexUnitType standing on the hex (units are a layer, never part of the tile), facing in degrees from north.</summary>
+ [Serializable] public sealed class BoardHex
+ {
+ public int q, r; public string terrain = "flat"; public string ground = "grass"; public string prototype = ""; public string note = "";
+ /// <summary>A unit standing on this hex (a HexUnitType id), drawn on its own layer above the tile; its heading.</summary>
+ public string unit = ""; public float facing;
+ /// <summary>Environment, not play: dressed as continuous landscape (no tile, no hex lines) round the playable hexes.</summary>
+ public bool env;
+ }
+
+ /// <summary>A board file (Boards/&lt;id&gt;.json): a fixed, hand-edited layout, so captures compare like for like.</summary>
+ /// <summary>A road through hex centres, Civ-style: q0, r0, q1, r1, ... (painted as a dirt road, centre to centre).</summary>
+ [Serializable] public sealed class BoardRoad { public string note = ""; public int[] hexes = Array.Empty<int>(); }
+
+ /// <summary>A river along hex edges, Civ-style: q, r, corner triples (corner 0 = north, clockwise), joined in order;
+ /// the ground is carved into a channel below sea level along it, so it fills with water.</summary>
+ [Serializable] public sealed class BoardRiver { public string note = ""; public int[] corners = Array.Empty<int>(); }
+
+ [Serializable] public sealed class HexBoardFile
+ {
+ public string id = ""; public string title = ""; public BoardHex[] hexes = Array.Empty<BoardHex>();
+ public BoardRoad[] roads = Array.Empty<BoardRoad>(); public BoardRiver[] rivers = Array.Empty<BoardRiver>();
+ }
+
+ public sealed class HexBoard
+ {
+ public readonly HexBoardFile File;
+ public readonly Dictionary<(int q, int r), BoardHex> Hexes;
+ public HexBoard(HexBoardFile file) { File = file; Hexes = file.hexes.ToDictionary(h => (h.q, h.r)); }
+
+ /// <summary>Each river as world points along hex corners.</summary>
+ public List<Vector3[]> RiverLines(float sizeM = HexScale.HexM) => (File.rivers ?? Array.Empty<BoardRiver>()).Select(rv =>
+ Enumerable.Range(0, rv.corners.Length / 3).Select(i => HexGeometry.Corners(HexGeometry.Centre(rv.corners[3 * i], rv.corners[3 * i + 1], sizeM), sizeM)[rv.corners[3 * i + 2]]).ToArray()).ToList();
+
+ /// <summary>Each road as world points through hex centres.</summary>
+ public List<Vector3[]> RoadLines(float sizeM = HexScale.HexM) => (File.roads ?? Array.Empty<BoardRoad>()).Select(rd =>
+ Enumerable.Range(0, rd.hexes.Length / 2).Select(i => HexGeometry.Centre(rd.hexes[2 * i], rd.hexes[2 * i + 1], sizeM)).ToArray()).ToList();
+ public static HexBoard FromJson(string json) => new HexBoard(JsonUtility.FromJson<HexBoardFile>(json));
+
+ public const string BoardsFolder = "HexTiles/Boards";
+ /// <summary>A board shipped in Resources/HexTiles/Boards/&lt;id&gt;.json (runtime and editor alike).</summary>
+ public static HexBoard Load(string id) =>
+ FromJson((Resources.Load<TextAsset>(BoardsFolder + "/" + id) ?? throw new System.IO.FileNotFoundException($"no board Resources/{BoardsFolder}/{id}.json")).text);
+
+ /// <summary>Ground textures from Resources/HexTiles/Ground/&lt;texture&gt;_diff_2k and _nor_gl_2k (local while the
+ /// textures await their asset batch); missing ones paint the layer's flat colour.</summary>
+ public static (Texture2D?, Texture2D?) GroundFromResources(string texture) =>
+ (Resources.Load<Texture2D>($"HexTiles/Ground/{texture}_diff_2k"), Resources.Load<Texture2D>($"HexTiles/Ground/{texture}_nor_gl_2k"));
+
+ public static HexTerrain TerrainOf(BoardHex h) => h.terrain switch
+ {
+ "hills" => HexTerrain.Hills, "mountain" => HexTerrain.Mountain, "water" => HexTerrain.Water, _ => HexTerrain.Flat,
+ };
+ }
+
+ /// <summary>Heights are game-friendly, as Civ's: hills a broad dome up to ~0.5 km, highland "mountain" a raised plateau
+ /// with a smooth ~0.6 km dome (no cliffs or ravines), so units and vehicles cross every land hex.
+ /// The board's ground (Civ-style): every hex has a height profile by its terrain (water below sea level,
+ /// flat a little above, hills a broad dome, mountains a raised base for the peak props), blended smoothly across edges
+ /// so coasts and hill feet round off; outside the board is sea. Water is height below 0. Pure, so tiles, tests and the
+ /// Unity terrain all read the same numbers.</summary>
+ public sealed class HexBoardSurface : IHexSurface
+ {
+ public const float SeaY = 0f, WaterY = -520f, FlatY = 80f, HillsY = 450f, MountainBaseY = 420f, MountainDomeY = 560f;
+ const float BlendFrom = 0.5f, BlendTo = 1.12f, NoiseM = 9000f, SlopeStepM = 60f;
+
+ readonly HexBoard board;
+ readonly float size;
+ readonly List<Vector3[]> rivers;
+ /// <summary>River channel half-width and bank width (metres): water within the channel, banks easing down to it.</summary>
+ public const float RiverChannelM = 110f, RiverBankM = 420f, RiverBedY = -14f;
+
+ public HexBoardSurface(HexBoard board, float sizeM = HexScale.HexM) { this.board = board; size = sizeM; rivers = board.RiverLines(sizeM); }
+
+ public float Height(Vector3 p)
+ {
+ float h = Terrain(p);
+ foreach (var line in rivers)
+ {
+ float d = DistanceToLine(p, line);
+ if (d < RiverBankM) h = Mathf.Lerp(Mathf.Min(h, RiverBedY), h, Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(RiverChannelM, RiverBankM, d)));
+ }
+ return h;
+ }
+
+ public static float DistanceToLine(Vector3 p, IReadOnlyList<Vector3> line)
+ {
+ float best = float.MaxValue;
+ for (int i = 0; i + 1 < line.Count; i++)
+ {
+ Vector2 a = new Vector2(line[i].x, line[i].z), b = new Vector2(line[i + 1].x, line[i + 1].z), q = new Vector2(p.x, p.z);
+ var ab = b - a; float t = Mathf.Clamp01(Vector2.Dot(q - a, ab) / Mathf.Max(ab.sqrMagnitude, 1e-4f));
+ best = Mathf.Min(best, (q - (a + ab * t)).magnitude);
+ }
+ return best;
+ }
+
+ float Terrain(Vector3 p)
+ {
+ var (q0, r0) = HexGeometry.Axial(p, size);
+ float sum = 0f, wsum = 0f;
+ for (int i = -1; i < 6; i++)
+ {
+ var (dq, dr) = i < 0 ? (0, 0) : i < 6 ? HexGeometry.Neighbours[i] : Ring2[i - 6];
+ int q = q0 + dq, r = r0 + dr;
+ var c = HexGeometry.Centre(q, r, size);
+ float d = new Vector2(p.x - c.x, p.z - c.z).magnitude / size;
+ float w = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(BlendTo, BlendFrom, d));
+ if (w <= 0f) continue;
+ sum += w * Profile(q, r, d, p); wsum += w;
+ }
+ return wsum > 0f ? sum / wsum : WaterY;
+ }
+
+ float Profile(int q, int r, float d, Vector3 p)
+ {
+ var terrain = board.Hexes.TryGetValue((q, r), out var h) ? HexBoard.TerrainOf(h) : HexTerrain.Water;
+ float n = Mathf.PerlinNoise(p.x / NoiseM + 31.7f, p.z / NoiseM + 11.3f) - 0.5f;
+ float dome = Mathf.Clamp01(1f - d * d);
+ return terrain switch
+ {
+ HexTerrain.Water => WaterY + 40f * n,
+ HexTerrain.Hills => FlatY + HillsY * dome * (0.8f + 0.5f * n) + 140f * Mathf.PerlinNoise(p.x / 2600f + 5.1f, p.z / 2600f + 9.7f) * dome,
+ HexTerrain.Mountain => FlatY + MountainBaseY + MountainDomeY * dome,
+ _ => FlatY + 50f * n,
+ };
+ }
+
+ public bool IsWater(Vector3 p) => Height(p) < SeaY + 4f;
+
+ public float SlopeDeg(Vector3 p)
+ {
+ float dx = Height(p + new Vector3(SlopeStepM, 0f, 0f)) - Height(p - new Vector3(SlopeStepM, 0f, 0f));
+ float dz = Height(p + new Vector3(0f, 0f, SlopeStepM)) - Height(p - new Vector3(0f, 0f, SlopeStepM));
+ return Mathf.Atan(new Vector2(dx, dz).magnitude / (2f * SlopeStepM)) * Mathf.Rad2Deg;
+ }
+
+ /// <summary>Per-layer ground weights at p: each hex's own layer blended like the heights; sand on the shore, seabed
+ /// under water.</summary>
+ public void GroundWeights(Vector3 p, IReadOnlyList<string> layers, float[] w)
+ {
+ Array.Clear(w, 0, w.Length);
+ float y = Height(p);
+ int beach = IndexOf(layers, "beach"), seabed = IndexOf(layers, "seabed"), green = IndexOf(layers, "grass");
+ if (y < SeaY - 20f) { w[seabed] = 1f; return; }
+ if (y < SeaY + 30f) { w[beach] = 1f; return; }
+ var (q0, r0) = HexGeometry.Axial(p, size);
+ float wsum = 0f;
+ float warpX = (Mathf.PerlinNoise(p.x / 6000f + 2.7f, p.z / 6000f + 8.1f) - 0.5f) * 0.9f * size;
+ float warpZ = (Mathf.PerlinNoise(p.x / 6000f + 6.3f, p.z / 6000f + 1.9f) - 0.5f) * 0.9f * size;
+ bool inPlay = board.Hexes.TryGetValue((q0, r0), out var own) && !own.env;
+ for (int i = -1, n = inPlay ? 6 : 18; i < n; i++) // ring 2 can only reach an environment pixel
+ {
+ var (dq, dr) = i < 0 ? (0, 0) : i < 6 ? HexGeometry.Neighbours[i] : Ring2[i - 6];
+ int q = q0 + dq, r = r0 + dr;
+ if (!board.Hexes.TryGetValue((q, r), out var h) || HexBoard.TerrainOf(h) == HexTerrain.Water) continue;
+ if (h.env && inPlay) continue; // the landscape never bleeds into a play hex
+ var c = HexGeometry.Centre(q, r, size);
+ // Play hexes keep a crisp edge (it reaches past the corners, so three hexes always share a corner). The
+ // environment ring blends wide over a noise-warped distance, so its grounds meander like a landscape.
+ float k;
+ if (h.env) k = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.45f, 0.35f, new Vector2(p.x + warpX - c.x, p.z + warpZ - c.z).magnitude / size)) * 0.6f;
+ else k = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.04f, 0.78f, new Vector2(p.x - c.x, p.z - c.z).magnitude / size));
+ int l = IndexOf(layers, h.ground); if (l < 0 || k <= 0f) continue;
+ if (h.env && green >= 0 && h.ground != "grass" && h.ground != "desert")
+ {
+ // Landscape: meandering green meadows through the dry ground, which also breaks up texture tiling.
+ float f = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.42f, 0.62f, Mathf.PerlinNoise(p.x / 4200f + 4.4f, p.z / 4200f + 0.6f)));
+ w[green] += k * f; w[l] += k * (1f - f); wsum += k;
+ continue;
+ }
+ w[l] += k; wsum += k;
+ }
+ if (wsum <= 0f) { w[beach] = 1f; return; }
+ for (int l = 0; l < w.Length; l++) w[l] /= wsum;
+ }
+
+ static readonly (int q, int r)[] Ring2 = { (2, 0), (2, -1), (2, -2), (1, -2), (0, -2), (-1, -1), (-2, 0), (-2, 1), (-2, 2), (-1, 2), (0, 2), (1, 1) };
+
+ static int IndexOf(IReadOnlyList<string> list, string id) { for (int i = 0; i < list.Count; i++) if (list[i] == id) return i; return -1; }
+ }
+
+ /// <summary>Ground texture layers: an id, the Poly Haven texture (local, git-ignored; HexGroundTextures supplies it in the
+ /// editor), tile size, tint, and a flat colour used when the texture is not on this machine.</summary>
+ public static class HexGround
+ {
+ public static readonly (string id, string texture, float tileM, Color tint, Color fallback)[] Layers =
+ {
+ ("grass", "aerial_grass_rock", 3400f, new Color(1.00f, 1.42f, 0.62f), new Color(0.47f, 0.60f, 0.27f)),
+ ("plains", "grass_ground", 4600f, new Color(1.28f, 1.30f, 0.66f), new Color(0.62f, 0.62f, 0.33f)),
+ ("hills", "aerial_ground_rock", 4000f, new Color(1.00f, 1.36f, 0.62f), new Color(0.55f, 0.56f, 0.36f)),
+ ("mountain", "rocky_terrain_02", 6000f, new Color(1.45f, 1.38f, 1.22f), new Color(0.52f, 0.49f, 0.44f)),
+ ("desert", "aerial_sand", 4500f, new Color(1.38f, 1.20f, 0.88f), new Color(0.82f, 0.70f, 0.50f)),
+ ("beach", "aerial_beach_01", 2200f, new Color(1.30f, 1.24f, 1.05f), new Color(0.86f, 0.80f, 0.64f)),
+ ("seabed", "aerial_beach_01", 3000f, new Color(0.55f, 0.95f, 0.95f), new Color(0.35f, 0.45f, 0.45f)),
+ // Painted by tiles and roads (ctx.PaintGround / PaintStroke), generated here (asset-staging/tools/kit/make_crop_textures.py).
+ ("wheat", "hex_crop_wheat", 1700f, Color.white, new Color(0.84f, 0.70f, 0.38f)),
+ ("green_crop", "hex_crop_green", 1700f, Color.white, new Color(0.41f, 0.55f, 0.23f)),
+ ("ploughed", "hex_crop_ploughed", 1500f, Color.white, new Color(0.50f, 0.38f, 0.27f)),
+ ("dirt", "hex_dirt", 700f, Color.white, new Color(0.59f, 0.50f, 0.38f)),
+ };
+
+ public static IReadOnlyList<string> Ids => Layers.Select(l => l.id).ToArray();
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexBoard.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoard.cs.meta
new file mode 100644
index 000000000..b44b98b0a
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoard.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ee3e651b971604d62bd2bb6e65bbbdb6
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexBoardBuilder.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoardBuilder.cs
new file mode 100644
index 000000000..d7b65aec1
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoardBuilder.cs
@@ -0,0 +1,385 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Game.Map;
+using UnityEngine;
+using UnityEngine.Rendering;
+using Object = UnityEngine.Object;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>Per tile: what was built and whether it kept to its budget.</summary>
+ public sealed class HexTileReport
+ {
+ public string Prototype = "", Title = "", Models = ""; public int Q, R, Pieces, StandIns, Triangles, Budget;
+ public bool OverBudget => Triangles > Budget;
+ public override string ToString() =>
+ $"{Prototype} ({Q},{R}) \"{Title}\": {Pieces} pieces ({StandIns} stand-ins), {Triangles} tris{(Budget == int.MaxValue ? "" : $" of {Budget} " + (OverBudget ? "OVER BUDGET" : "ok"))}\n models: {Models}";
+ }
+
+ /// <summary>Builds a board in the open scene under one root: a Unity Terrain shaped and painted from the hexes
+ /// (HexBoardSurface, HexGround), a sea plane, every tile's prototype, and the faint tile edges. Everything it makes is
+ /// owned by the root (HexBoardAssets) and destroyed with it. Textures come from <paramref name="textures"/> (null = flat
+ /// colours), so the core needs no editor API.</summary>
+ public static class HexBoardBuilder
+ {
+ public const string RootName = "HexBoard", MountainPrototype = "mountain_peaks";
+
+ /// <summary>How the board sits in its scene: alone (its own sea, ground everywhere), or on the real map (no sea of
+ /// its own, terrain holes outside its land hexes so the real map shows around and under the sea).</summary>
+ public sealed class Options { public bool OwnSea = true; public bool HolesOutsideLand; public Transform? Parent; public Vector3 Origin; }
+
+ public static (GameObject root, List<HexTileReport> reports) Build(HexBoard board, Func<string, (Texture2D? albedo, Texture2D? normal)>? textures, int seed = 1948, string? only = null, Options? options = null)
+ {
+ options ??= new Options();
+ var root = new GameObject(RootName);
+ // Everything below is built in board space (HexGeometry, origin at the hex grid's north-west corner): the root
+ // carries the board into the scene, so the real map only needs Origin = (0, sea level, map length).
+ if (options.Parent != null) root.transform.SetParent(options.Parent, false);
+ root.transform.position = options.Origin;
+ var assets = root.AddComponent<HexBoardAssets>();
+ var surface = new HexBoardSurface(board);
+ var reports = new List<HexTileReport>();
+ var placements = new List<HexPlacement>();
+ var paints = new List<(HexPaint paint, int q, int r)>();
+ foreach (var h in board.Hexes.Values.OrderBy(h => h.q).ThenBy(h => h.r))
+ {
+ string id = h.prototype != "" ? h.prototype : HexBoard.TerrainOf(h) == HexTerrain.Mountain ? MountainPrototype : "";
+ if (id == "" || (only != null && id != only && id != MountainPrototype)) continue;
+ var proto = HexPrototypes.Create(id);
+ var ctx = new HexTileContext(h.q, h.r, surface, seed);
+ proto.Build(ctx);
+ placements.AddRange(ctx.Placements);
+ paints.AddRange(ctx.Paints.Select(p => (p, h.q, h.r)));
+ reports.Add(new HexTileReport
+ {
+ Prototype = id, Title = proto.Title, Q = h.q, R = h.r, Pieces = ctx.Placements.Count, Budget = proto.TriangleBudget,
+ StandIns = ctx.Placements.Count(p => p.StandIn == StandIn.Flat || HexModels.Prefab(HexModels.Resolve(p.Model, p.Position)) == null),
+ Triangles = ctx.Placements.Sum(p => p.StandIn == StandIn.Flat ? 12 : HexModels.Triangles(p.Model, p.StandIn, p.Position)),
+ // Which models drew and which fell back to stand-ins ("~" marks a missing model).
+ Models = string.Join(", ", ctx.Placements.GroupBy(p => p.StandIn == StandIn.Flat ? "flat" : (HexModels.Prefab(HexModels.Resolve(p.Model, p.Position)) == null ? "~" : "") + p.Model)
+ .OrderBy(g => g.Key).Select(g => $"{g.Key} x{g.Count()}")),
+ });
+ }
+ // The environment ring: continuous landscape round the playable hexes (no tiles, no hex lines).
+ placements.AddRange(HexEnvironment.Dress(board, surface, seed));
+ // Ground second: the tiles' paints (fields, sand, tracks) and the board's roads go into the terrain's splat.
+ BuildTerrain(root.transform, board, surface, textures, assets, paints, options.HolesOutsideLand);
+ if (options.OwnSea) BuildSea(root.transform, board, assets);
+ HexBoardRenderer.Emit(root.transform, placements, assets);
+ // Units: their own layer above the tiles, standing at idle on their hex's centre.
+ var units = new GameObject("HexBoardUnits").transform; units.SetParent(root.transform, false);
+ foreach (var h in board.Hexes.Values.Where(h => h.unit != "").OrderBy(h => h.q).ThenBy(h => h.r))
+ {
+ if (only != null && h.prototype != only) continue;
+ var type = HexUnitTypes.Create(h.unit);
+ var unit = type.Create();
+ var motion = new HexUnitMotion(unit, new[] { (h.q, h.r) }, surface, units, HexScale.HexM, h.facing);
+ motion.Pose(0f, false);
+ reports.Add(new HexTileReport
+ {
+ Prototype = "unit:" + h.unit, Title = type.Title, Q = h.q, R = h.r, Pieces = unit.Members.Count, Budget = int.MaxValue,
+ StandIns = unit.Members.Count(m => HexModels.Prefab(m.Model) == null),
+ Triangles = unit.Members.Sum(m => HexModels.Triangles(m.Model, m.StandIn, Vector3.zero)),
+ Models = string.Join(", ", unit.Members.GroupBy(m => (HexModels.Prefab(m.Model) == null ? "~" : "") + m.Model).Select(g => $"{g.Key} x{g.Count()}")),
+ });
+ }
+ HexBoardEdges.Build(root.transform, board, surface, assets);
+ return (root, reports);
+ }
+
+ /// <summary>The board's world bounds: every hex plus one hex of sea around it.</summary>
+ public static Rect Bounds(HexBoard board, float sizeM = HexScale.HexM)
+ {
+ var cs = board.Hexes.Values.Select(h => HexGeometry.Centre(h.q, h.r, sizeM)).ToList();
+ float m = sizeM * 2.2f;
+ float x0 = cs.Min(c => c.x) - m, x1 = cs.Max(c => c.x) + m, z0 = cs.Min(c => c.z) - m, z1 = cs.Max(c => c.z) + m;
+ return new Rect(x0, z0, x1 - x0, z1 - z0);
+ }
+
+ const int HeightRes = 1025, AlphaRes = 2048;
+ const float MinY = -600f, MaxY = 2400f;
+
+ /// <summary>Road width on the ground, metres (a Civ road reads as a thin track from far away).</summary>
+ public const float RoadM = 170f;
+
+ static void BuildTerrain(Transform root, HexBoard board, HexBoardSurface surface, Func<string, (Texture2D?, Texture2D?)>? textures, HexBoardAssets assets,
+ List<(HexPaint paint, int q, int r)> paints, bool holesOutsideLand)
+ {
+ var rect = Bounds(board);
+ var data = assets.Own(new TerrainData { heightmapResolution = HeightRes });
+ data.size = new Vector3(rect.width, MaxY - MinY, rect.height);
+ var heights = new float[HeightRes, HeightRes];
+ for (int z = 0; z < HeightRes; z++)
+ for (int x = 0; x < HeightRes; x++)
+ {
+ var p = new Vector3(rect.x + rect.width * x / (HeightRes - 1f), 0f, rect.y + rect.height * z / (HeightRes - 1f));
+ heights[z, x] = Mathf.InverseLerp(MinY, MaxY, surface.Height(p));
+ }
+ data.SetHeights(0, 0, heights);
+ var ids = HexGround.Ids;
+ data.terrainLayers = HexGround.Layers.Select(l =>
+ {
+ var (albedo, normal) = textures?.Invoke(l.texture) ?? (null, null);
+ var layer = assets.Own(new TerrainLayer
+ {
+ name = "hex-" + l.id, diffuseTexture = albedo != null ? albedo : assets.Own(Solid(l.fallback)), normalMapTexture = normal,
+ tileSize = new Vector2(l.tileM, l.tileM), normalScale = 0.6f, smoothness = 0f, metallic = 0f,
+ diffuseRemapMin = Vector4.zero, diffuseRemapMax = albedo != null ? new Vector4(l.tint.r, l.tint.g, l.tint.b, 1f) : Vector4.one,
+ });
+ return layer;
+ }).ToArray();
+ data.alphamapResolution = AlphaRes;
+ var alpha = new float[AlphaRes, AlphaRes, ids.Count];
+ var w = new float[ids.Count];
+ for (int z = 0; z < AlphaRes; z++)
+ for (int x = 0; x < AlphaRes; x++)
+ {
+ surface.GroundWeights(new Vector3(rect.x + rect.width * x / (AlphaRes - 1f), 0f, rect.y + rect.height * z / (AlphaRes - 1f)), ids, w);
+ for (int l = 0; l < ids.Count; l++) alpha[z, x, l] = w[l];
+ }
+ // Paints, clipped to their own hex (a tile owns its ground), then roads, which run across hexes.
+ foreach (var (paint, q, r) in paints) Paint(alpha, rect, ids, paint, HexGeometry.Centre(q, r, HexScale.HexM), surface);
+ foreach (var line in board.RoadLines())
+ for (int i = 0; i + 1 < line.Length; i++)
+ Paint(alpha, rect, ids, new HexPaint("dirt", line[i], line[i + 1], RoadM, 0f, 0f, 0.5f, 1f, true), null, surface);
+ data.SetAlphamaps(0, 0, alpha);
+ if (holesOutsideLand)
+ {
+ // Holes everywhere but the board's land (and a sliver of shore), so the real map shows around it.
+ int hr = data.holesResolution;
+ var solid = new bool[hr, hr];
+ for (int z = 0; z < hr; z++)
+ for (int x = 0; x < hr; x++)
+ {
+ var p = new Vector3(rect.x + rect.width * (x + 0.5f) / hr, 0f, rect.y + rect.height * (z + 0.5f) / hr);
+ var (q, r) = HexGeometry.Axial(p, HexScale.HexM);
+ solid[z, x] = board.Hexes.TryGetValue((q, r), out var h) && HexBoard.TerrainOf(h) != HexTerrain.Water && surface.Height(p) > -2f;
+ }
+ data.SetHoles(0, 0, solid);
+ }
+ var go = Terrain.CreateTerrainGameObject(data);
+ var t = go.GetComponent<Terrain>();
+ // An overlay overlaps the real map; it must not join its grid of adjacent terrain tiles.
+ if (holesOutsideLand) t.allowAutoConnect = false;
+ go.name = "HexBoardTerrain";
+ go.transform.SetParent(root, false);
+ go.transform.localPosition = new Vector3(rect.x, MinY, rect.y);
+ var m = assets.Own(HexMaterials.New(holesOutsideLand ? HexMaterials.TerrainHoles : HexMaterials.Terrain));
+ t.materialTemplate = m; t.heightmapPixelError = 2f; t.basemapDistance = 1e7f; t.drawTreesAndFoliage = false;
+ }
+
+ /// <summary>Blends one paint into the splat: weight 1 inside, easing to 0 over its soft edge; never on water; when
+ /// <paramref name="clipCentre"/> is given, only inside that hex.</summary>
+ static void Paint(float[,,] alpha, Rect rect, IReadOnlyList<string> ids, HexPaint p, Vector3? clipCentre, HexBoardSurface surface)
+ {
+ int layer = -1; for (int i = 0; i < ids.Count; i++) if (ids[i] == p.Layer) layer = i;
+ if (layer < 0) return;
+ int n = alpha.GetLength(0), layers = alpha.GetLength(2);
+ float reach = p.Line ? p.Width : 0.75f * Mathf.Max(p.Width, p.Depth);
+ float x0 = Mathf.Min(p.A.x, p.B.x) - reach, x1 = Mathf.Max(p.A.x, p.B.x) + reach, z0 = Mathf.Min(p.A.z, p.B.z) - reach, z1 = Mathf.Max(p.A.z, p.B.z) + reach;
+ int i0 = Mathf.Max(0, Mathf.FloorToInt((x0 - rect.x) / rect.width * (n - 1))), i1 = Mathf.Min(n - 1, Mathf.CeilToInt((x1 - rect.x) / rect.width * (n - 1)));
+ int j0 = Mathf.Max(0, Mathf.FloorToInt((z0 - rect.y) / rect.height * (n - 1))), j1 = Mathf.Min(n - 1, Mathf.CeilToInt((z1 - rect.y) / rect.height * (n - 1)));
+ var inv = Quaternion.Euler(0f, -p.Yaw, 0f);
+ for (int j = j0; j <= j1; j++)
+ for (int i = i0; i <= i1; i++)
+ {
+ var w = new Vector3(rect.x + rect.width * i / (n - 1f), 0f, rect.y + rect.height * j / (n - 1f));
+ if (clipCentre is Vector3 c && !HexGeometry.InHex(w, c, HexScale.HexM)) continue;
+ if (surface.IsWater(w)) continue;
+ float k;
+ if (p.Line)
+ {
+ float d = HexBoardSurface.DistanceToLine(w, new[] { p.A, p.B });
+ k = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(p.Width * 0.5f, p.Width * 0.5f * (1f - p.Soft), d));
+ }
+ else
+ {
+ var l = inv * (w - p.A);
+ float soft = Mathf.Max(1f, p.Soft * Mathf.Min(p.Width, p.Depth));
+ float kx = Mathf.InverseLerp(p.Width * 0.5f, p.Width * 0.5f - soft, Mathf.Abs(l.x));
+ float kz = Mathf.InverseLerp(p.Depth * 0.5f, p.Depth * 0.5f - soft, Mathf.Abs(l.z));
+ k = Mathf.SmoothStep(0f, 1f, Mathf.Min(kx, kz));
+ }
+ k *= p.Strength;
+ if (k <= 0f) continue;
+ for (int l2 = 0; l2 < layers; l2++) alpha[j, i, l2] = alpha[j, i, l2] * (1f - k) + (l2 == layer ? k : 0f);
+ }
+ }
+
+ static void BuildSea(Transform root, HexBoard board, HexBoardAssets assets)
+ {
+ var rect = Bounds(board);
+ var mesh = assets.Own(new Mesh { name = "hex-sea" });
+ mesh.SetVertices(new[] { new Vector3(rect.xMin, 0, rect.yMin), new Vector3(rect.xMax, 0, rect.yMin), new Vector3(rect.xMin, 0, rect.yMax), new Vector3(rect.xMax, 0, rect.yMax) });
+ mesh.SetTriangles(new[] { 0, 2, 1, 1, 2, 3 }, 0); mesh.RecalculateNormals(); mesh.RecalculateBounds();
+ var m = assets.Own(Transparent(new Color(0.06f, 0.42f, 0.58f, 0.78f), lit: true)); // Civ turquoise
+ m.SetFloat("_Smoothness", 0.85f);
+ var go = new GameObject("HexBoardSea", typeof(MeshFilter), typeof(MeshRenderer));
+ go.transform.SetParent(root, false);
+ go.GetComponent<MeshFilter>().sharedMesh = mesh;
+ var r = go.GetComponent<MeshRenderer>(); r.sharedMaterial = m; r.shadowCastingMode = ShadowCastingMode.Off;
+ }
+
+ public static Material Transparent(Color c, bool lit)
+ {
+ var m = HexMaterials.New(lit ? HexMaterials.Sea : HexMaterials.Edges);
+ m.SetColor("_BaseColor", c);
+ return m;
+ }
+
+ static Texture2D Solid(Color c)
+ {
+ var t = new Texture2D(4, 4, TextureFormat.RGB24, true) { name = "hex-solid" };
+ t.SetPixels(Enumerable.Repeat(c, 16).ToArray()); t.Apply();
+ return t;
+ }
+ }
+
+ /// <summary>Lives on the board root and destroys what the board made (meshes, materials, textures, terrain data).</summary>
+ [ExecuteAlways]
+ public sealed class HexBoardAssets : MonoBehaviour
+ {
+ readonly List<Object> owned = new List<Object>();
+ readonly List<Action> teardown = new List<Action>();
+ public T Own<T>(T o) where T : Object { owned.Add(o); return o; }
+ /// <summary>Runs when the board is destroyed, last registered first (e.g. restoring the real map's heights).</summary>
+ public void OnTeardown(Action undo) => teardown.Add(undo);
+ void OnDestroy() => Teardown();
+
+ /// <summary>Restores everything the board changed, now and once (Destroy is deferred to the frame's end, so a
+ /// board rebuilt in the same frame must not find the old one's changes still in place).</summary>
+ public void Teardown()
+ {
+ for (int i = teardown.Count - 1; i >= 0; i--) teardown[i]();
+ teardown.Clear();
+ foreach (var o in owned) if (o != null) { if (Application.isPlaying) Destroy(o); else DestroyImmediate(o); }
+ owned.Clear();
+ }
+ }
+
+ /// <summary>Draws placements: static models and stand-ins combined into one renderer per material, skinned models
+ /// (figures, animals) instantiated and posed at their idle's first frame.</summary>
+ public static class HexBoardRenderer
+ {
+ public static void Emit(Transform root, IEnumerable<HexPlacement> placements, HexBoardAssets assets)
+ {
+ var parent = new GameObject("HexBoardPieces").transform; parent.SetParent(root, false);
+ var groups = new Dictionary<Material, List<CombineInstance>>();
+ var parts = new Dictionary<(string, Fit), HexModels.Part[]>();
+ var tints = new Dictionary<Color, Material>();
+ var pieces = new Dictionary<(Mesh, Matrix4x4), MeshRenderer>();
+ Material Tinted(Color c)
+ {
+ if (tints.TryGetValue(c, out var m)) return m;
+ m = assets.Own(HexMaterials.New(HexMaterials.Lit)); m.name = "hex-" + ColorUtility.ToHtmlStringRGB(c);
+ m.SetColor("_BaseColor", c); m.SetFloat("_Smoothness", 0.05f);
+ return tints[c] = m;
+ }
+ void Add(Material m, Mesh mesh, int sub, Matrix4x4 world)
+ {
+ // A player cannot combine meshes imported without Read/Write (the Tripo and kit models): draw those as
+ // their own renderers sharing the mesh (the SRP batcher keeps the cost down); combine the rest.
+ if (!mesh.isReadable)
+ {
+ // One renderer per placed mesh; each of its submeshes gets its own material as the parts arrive.
+ var key = (mesh, world);
+ if (!pieces.TryGetValue(key, out var piece))
+ {
+ var go = new GameObject(mesh.name, typeof(MeshFilter), typeof(MeshRenderer));
+ go.transform.SetParent(parent, false);
+ go.transform.localPosition = world.GetColumn(3);
+ go.transform.localRotation = world.rotation;
+ go.transform.localScale = world.lossyScale;
+ go.GetComponent<MeshFilter>().sharedMesh = mesh;
+ piece = go.GetComponent<MeshRenderer>();
+ piece.sharedMaterials = Enumerable.Repeat(m, mesh.subMeshCount).ToArray();
+ pieces[key] = piece;
+ }
+ var mats = piece.sharedMaterials; mats[sub] = m; piece.sharedMaterials = mats;
+ return;
+ }
+ if (!groups.TryGetValue(m, out var list)) groups[m] = list = new List<CombineInstance>();
+ list.Add(new CombineInstance { mesh = mesh, subMeshIndex = sub, transform = world }); // board space = parent's local space
+ }
+ foreach (var p in placements)
+ {
+ var id = HexModels.Resolve(p.Model, p.Position);
+ var prefab = p.StandIn == StandIn.Flat ? null : HexModels.Prefab(id);
+ if (prefab != null && HexModels.Skinned(prefab))
+ {
+ var go = Object.Instantiate(prefab, parent);
+ var b = HexModels.Bounds(go);
+ float k = HexModels.Normaliser(b.size, p.Fit).x;
+ go.transform.localPosition = p.Position; go.transform.localRotation = p.Matrix.rotation;
+ go.transform.localScale = Vector3.one * k * p.Matrix.lossyScale.x;
+ foreach (var a in go.GetComponentsInChildren<Animator>(true)) HexStandIns.SampleIdle(a);
+ continue;
+ }
+ if (prefab != null)
+ {
+ if (!parts.TryGetValue((id, p.Fit), out var ps)) parts[(id, p.Fit)] = ps = HexModels.Parts(prefab, p.Fit);
+ foreach (var part in ps) Add(part.Material, part.Mesh, part.SubMesh, p.Matrix * part.Local);
+ continue;
+ }
+ foreach (var (mesh, colour, local) in HexModels.StandInParts(p.StandIn))
+ {
+ var c = p.StandIn == StandIn.Flat || (p.Tint != Color.white && colour != "bark") ? p.Tint : HexStandIns.Palette[colour];
+ Add(Tinted(c), mesh, 0, p.Matrix * local);
+ }
+ }
+ foreach (var (m, list) in groups)
+ {
+ var mesh = assets.Own(new Mesh { name = "hex-" + m.name, indexFormat = IndexFormat.UInt32 });
+ mesh.CombineMeshes(list.ToArray(), true, true);
+ var go = new GameObject("hex-" + m.name, typeof(MeshFilter), typeof(MeshRenderer));
+ go.transform.SetParent(parent, false);
+ go.GetComponent<MeshFilter>().sharedMesh = mesh;
+ go.GetComponent<MeshRenderer>().sharedMaterial = m;
+ }
+ }
+ }
+
+ /// <summary>Faint tile edges on land, Civ-style: a pale transparent ribbon along every land hex edge, draped on the ground.</summary>
+ public static class HexBoardEdges
+ {
+ const int Segments = 12; const float LiftM = 14f, WidthM = 60f;
+
+ public static void Build(Transform root, HexBoard board, HexBoardSurface surface, HexBoardAssets assets, float sizeM = HexScale.HexM)
+ {
+ var verts = new List<Vector3>(); var tris = new List<int>();
+ foreach (var h in board.Hexes.Values)
+ {
+ if (HexBoard.TerrainOf(h) == HexTerrain.Water || h.env) continue; // the environment ring has no hex lines
+ var corners = HexGeometry.Corners(HexGeometry.Centre(h.q, h.r, sizeM), sizeM);
+ for (int e = 0; e < 6; e++)
+ {
+ // Each shared land edge once: draw it from the hex whose neighbour across it sorts later or is not land.
+ var n = HexGeometry.Neighbours[(7 - e) % 6]; // corner e..e+1 faces this neighbour (north-east first)
+ bool other = board.Hexes.TryGetValue((h.q + n.q, h.r + n.r), out var nb) && HexBoard.TerrainOf(nb) != HexTerrain.Water && !nb.env;
+ if (other && (h.q, h.r).CompareTo((nb!.q, nb.r)) > 0) continue;
+ Vector3 a = corners[e], b = corners[(e + 1) % 6];
+ var side = Vector3.Cross(Vector3.up, (b - a).normalized) * (WidthM * 0.5f);
+ for (int s = 0; s < Segments; s++)
+ {
+ Vector3 p0 = Vector3.Lerp(a, b, s / (float)Segments), p1 = Vector3.Lerp(a, b, (s + 1) / (float)Segments);
+ if (surface.IsWater(p0) && surface.IsWater(p1)) continue;
+ p0.y = Mathf.Max(surface.Height(p0), 0f) + LiftM; p1.y = Mathf.Max(surface.Height(p1), 0f) + LiftM;
+ int i = verts.Count;
+ verts.Add(p0 - side); verts.Add(p0 + side); verts.Add(p1 - side); verts.Add(p1 + side);
+ tris.AddRange(new[] { i, i + 2, i + 1, i + 1, i + 2, i + 3 });
+ }
+ }
+ }
+ var mesh = assets.Own(new Mesh { name = "hex-edges", indexFormat = IndexFormat.UInt32 });
+ mesh.SetVertices(verts); mesh.SetTriangles(tris, 0); mesh.RecalculateBounds();
+ var m = assets.Own(HexBoardBuilder.Transparent(new Color(1f, 0.97f, 0.88f, 0.28f), lit: false));
+ m.SetFloat("_Cull", (float)CullMode.Off);
+ var go = new GameObject("HexBoardEdges", typeof(MeshFilter), typeof(MeshRenderer));
+ go.transform.SetParent(root, false);
+ go.GetComponent<MeshFilter>().sharedMesh = mesh;
+ var r = go.GetComponent<MeshRenderer>(); r.sharedMaterial = m; r.shadowCastingMode = ShadowCastingMode.Off;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexBoardBuilder.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoardBuilder.cs.meta
new file mode 100644
index 000000000..a01044229
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexBoardBuilder.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ef4425fbca563437683518dce807cf60
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexEnvironment.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexEnvironment.cs
new file mode 100644
index 000000000..d9edaa75b
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexEnvironment.cs
@@ -0,0 +1,85 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>Dresses the board's environment hexes (BoardHex.env) as one continuous landscape round the playable
+ /// hexes: woods, scattered trees and rock outcrops whose density follows a noise field in world space, so they run
+ /// across hex boundaries with no tile shape, no inset and no hex lines (the builder skips their edges). Deterministic.</summary>
+ public static class HexEnvironment
+ {
+ const float GridM = 820f, WoodScaleM = 7000f, DetailScaleM = 1900f;
+
+ public static IEnumerable<HexPlacement> Dress(HexBoard board, IHexSurface surface, int seed = 1948)
+ {
+ foreach (var h in board.Hexes.Values)
+ {
+ if (!h.env || HexBoard.TerrainOf(h) == HexTerrain.Water) continue;
+ var ctx = new HexTileContext(h.q, h.r, surface, seed ^ 0x5eed, HexScale.HexM, insetShare: 0f);
+ var c = ctx.Centre;
+ bool hills = HexBoard.TerrainOf(h) != HexTerrain.Flat;
+ int n = Mathf.CeilToInt(HexScale.HexM / GridM);
+ for (int i = -n; i <= n; i++)
+ for (int j = -n; j <= n; j++)
+ {
+ // A world-aligned jittered grid, so neighbouring hexes continue the same pattern.
+ float gx = Mathf.Round(c.x / GridM) * GridM + i * GridM, gz = Mathf.Round(c.z / GridM) * GridM + j * GridM;
+ uint hsh = unchecked((uint)(Mathf.FloorToInt(gx) * 73856093 ^ Mathf.FloorToInt(gz) * 19349663 ^ seed));
+ float r1 = (hsh & 0xFFFF) / 65535f, r2 = ((hsh >> 16) & 0xFFFF) / 65535f;
+ var p = new Vector3(gx + (r1 - 0.5f) * GridM * 0.8f, 0f, gz + (r2 - 0.5f) * GridM * 0.8f);
+ if (!HexGeometry.InHex(p, c, HexScale.HexM)) continue;
+ float wood = Mathf.PerlinNoise(p.x / WoodScaleM + 3.3f, p.z / WoodScaleM + 7.7f);
+ float detail = Mathf.PerlinNoise(p.x / DetailScaleM + 1.1f, p.z / DetailScaleM + 2.2f);
+ // Woods in clumps with open country between (a few lone trees), never an even sprinkle.
+ float density = hills ? Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.48f, 0.6f, wood)) : Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.56f, 0.68f, wood)) * 0.85f;
+ density = Mathf.Max(density * (0.6f + 0.6f * detail), 0.035f);
+ if (r1 * 0.7f + r2 * 0.3f > density) continue;
+ string model = hills ? (detail > 0.55f ? "sandbox:aleppo_pine_lite" : "sandbox:tabor_oak_lite") : (detail > 0.6f ? "sandbox:carob_lite" : "sandbox:olive_lite");
+ ctx.PlaceByHeight(model, p, r1 * 360f, (0.11f + 0.04f * r2) * HexScale.HexM, hills && detail > 0.55f ? StandIn.Pine : StandIn.Tree, null, 0.3f, 40f);
+ }
+ if (hills)
+ for (int k = 0; k < 2; k++)
+ if (ctx.Rng.NextDouble() < 0.6)
+ ctx.PlaceByWidth("sandbox:limestone*", ctx.RandomPoint(), ctx.Range(0f, 360f), ctx.Range(0.06f, 0.1f) * HexScale.HexM, StandIn.Rock, null, 60f);
+ foreach (var placement in ctx.Placements) yield return placement;
+ }
+ }
+ }
+
+ /// <summary>The hex-tile look's picture, Civ's warm and saturated diorama light (Tal: "fascinating to watch and to be
+ /// in", not depressing): a livelier grade, a warmer, brighter sun and brighter ambient. Apply returns the undo.</summary>
+ public static class HexLook
+ {
+ public const float Saturation = 30f, Contrast = 16f, PostExposure = 0.32f, Temperature = 12f, SunBoost = 1.22f;
+
+ public static System.Action Apply(UnityEngine.Rendering.VolumeProfile? profile, Light? sun)
+ {
+ var undo = new List<System.Action>();
+ if (profile != null && profile.TryGet(out UnityEngine.Rendering.Universal.ColorAdjustments ca))
+ {
+ var o = (ca.saturation.value, ca.saturation.overrideState, ca.contrast.value, ca.contrast.overrideState, ca.postExposure.value, ca.postExposure.overrideState);
+ ca.saturation.Override(Saturation); ca.contrast.Override(Contrast); ca.postExposure.Override(PostExposure);
+ undo.Add(() => { ca.saturation.value = o.Item1; ca.saturation.overrideState = o.Item2; ca.contrast.value = o.Item3; ca.contrast.overrideState = o.Item4; ca.postExposure.value = o.Item5; ca.postExposure.overrideState = o.Item6; });
+ }
+ if (profile != null)
+ {
+ bool added = !profile.TryGet(out UnityEngine.Rendering.Universal.WhiteBalance wb);
+ if (added) wb = profile.Add<UnityEngine.Rendering.Universal.WhiteBalance>();
+ var o = (wb.temperature.value, wb.temperature.overrideState);
+ wb.temperature.Override(Temperature);
+ undo.Add(() => { if (added) profile.Remove<UnityEngine.Rendering.Universal.WhiteBalance>(); else { wb.temperature.value = o.Item1; wb.temperature.overrideState = o.Item2; } });
+ }
+ if (sun != null)
+ {
+ float i0 = sun.intensity; var c0 = sun.color;
+ sun.intensity = i0 * SunBoost; sun.color = Color.Lerp(c0, new Color(1f, 0.88f, 0.70f), 0.35f);
+ undo.Add(() => { if (sun != null) { sun.intensity = i0; sun.color = c0; } });
+ }
+ var sky = RenderSettings.ambientSkyColor; var eq = RenderSettings.ambientEquatorColor;
+ RenderSettings.ambientSkyColor = sky * 1.18f; RenderSettings.ambientEquatorColor = eq * 1.15f;
+ undo.Add(() => { RenderSettings.ambientSkyColor = sky; RenderSettings.ambientEquatorColor = eq; });
+ return () => { for (int i = undo.Count - 1; i >= 0; i--) undo[i](); };
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexEnvironment.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexEnvironment.cs.meta
new file mode 100644
index 000000000..97c312f63
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexEnvironment.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 1264d225d9df548af9cd3a6d99ae86f0
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexMaterials.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexMaterials.cs
new file mode 100644
index 000000000..c3f3c0e9c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexMaterials.cs
@@ -0,0 +1,42 @@
+#nullable enable
+using System;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>The board's material templates, shipped in Resources/HexTiles/Materials (made by the editor menu
+ /// Statecraft/Hex Tiles/Make Materials) so a player build keeps their shaders and keyword variants: Shader.Find returns
+ /// null in players and the URP Terrain/Lit and transparent variants would be stripped. Each call returns a copy the
+ /// caller owns. In the editor, a missing template falls back to its shader by name.</summary>
+ public static class HexMaterials
+ {
+ public const string Folder = "HexTiles/Materials";
+ public const string Terrain = "HexTerrain", TerrainHoles = "HexTerrainHoles", Lit = "HexLit", Sea = "HexSea", Edges = "HexEdges";
+
+ public static Material New(string name)
+ {
+ var template = Resources.Load<Material>(Folder + "/" + name);
+ if (template != null) return new Material(template) { name = name };
+ var shader = Shader.Find(name switch
+ {
+ Terrain or TerrainHoles => "Universal Render Pipeline/Terrain/Lit",
+ Edges => "Universal Render Pipeline/Unlit",
+ _ => "Universal Render Pipeline/Lit",
+ }) ?? throw new InvalidOperationException($"no material Resources/{Folder}/{name} and no shader for it");
+ var m = new Material(shader) { name = name };
+ if (name is Sea or Edges) MakeTransparent(m);
+ if (name is Terrain or TerrainHoles) m.EnableKeyword("_NORMALMAP");
+ if (name == TerrainHoles) m.EnableKeyword("_ALPHATEST_ON");
+ return m;
+ }
+
+ /// <summary>URP Lit/Unlit set to alpha-blended transparency (the settings the shipped templates carry).</summary>
+ public static void MakeTransparent(Material m)
+ {
+ m.SetFloat("_Surface", 1f); m.SetFloat("_Blend", 0f);
+ m.SetFloat("_SrcBlend", (float)UnityEngine.Rendering.BlendMode.SrcAlpha); m.SetFloat("_DstBlend", (float)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
+ m.SetFloat("_ZWrite", 0f); m.SetOverrideTag("RenderType", "Transparent"); m.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
+ m.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexMaterials.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexMaterials.cs.meta
new file mode 100644
index 000000000..3c33c090c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexMaterials.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 7e3d541a704f246b9aa4be38b2e986f9
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexModels.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexModels.cs
new file mode 100644
index 000000000..c6d3abf74
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexModels.cs
@@ -0,0 +1,139 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using Object = UnityEngine.Object;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>Model ids and what they draw. An id is a Resources path, with prefixes for the existing local libraries:
+ /// "tiles:&lt;path&gt;" Resources/HexTiles/&lt;path&gt; (a contributor's own models, one folder per prototype)
+ /// "sandbox:&lt;name&gt;" Resources/HexSandbox/&lt;name&gt; (EZ-Tree trees, Poly Haven rocks, decimated Tripo building kit)
+ /// "proto:&lt;name&gt;" Resources/SettlementPrototypes/&lt;name&gt; (Tripo heroes, figures, animals, vehicles)
+ /// A trailing "*" picks among &lt;name&gt;, &lt;name&gt;_2, &lt;name&gt;_3 ... per placement. A missing model draws its stand-in, so a
+ /// tile works on a machine without the local (git-ignored, pending-rights) models.</summary>
+ public static class HexModels
+ {
+ public readonly struct Part
+ {
+ public readonly Mesh Mesh; public readonly int SubMesh; public readonly Material Material; public readonly Matrix4x4 Local;
+ public Part(Mesh mesh, int subMesh, Material material, Matrix4x4 local) { Mesh = mesh; SubMesh = subMesh; Material = material; Local = local; }
+ }
+
+ static readonly Dictionary<string, GameObject?> prefabs = new Dictionary<string, GameObject?>(StringComparer.Ordinal);
+ static readonly Dictionary<string, string[]> variants = new Dictionary<string, string[]>(StringComparer.Ordinal);
+
+ public static string PathOf(string id) =>
+ id.StartsWith("tiles:", StringComparison.Ordinal) ? "HexTiles/" + id.Substring(6)
+ : id.StartsWith("sandbox:", StringComparison.Ordinal) ? "HexSandbox/" + id.Substring(8)
+ : id.StartsWith("proto:", StringComparison.Ordinal) ? "SettlementPrototypes/" + id.Substring(6)
+ : "HexTiles/" + id;
+
+ public static GameObject? Prefab(string id)
+ {
+ if (string.IsNullOrEmpty(id)) return null;
+ if (prefabs.TryGetValue(id, out var p)) return p;
+ return prefabs[id] = Resources.Load<GameObject>(PathOf(id));
+ }
+
+ /// <summary>The concrete id for a placement: a "*" id picks a present variant by the placement's position.</summary>
+ public static string Resolve(string id, Vector3 at)
+ {
+ if (!id.EndsWith("*", StringComparison.Ordinal)) return id;
+ if (!variants.TryGetValue(id, out var names))
+ {
+ var stem = id.Substring(0, id.Length - 1);
+ var list = new List<string>();
+ for (int v = 1; v < 32; v++) { var name = v == 1 ? stem : $"{stem}_{v}"; if (Prefab(name) == null) break; list.Add(name); }
+ variants[id] = names = list.ToArray();
+ }
+ if (names.Length == 0) return id.Substring(0, id.Length - 1);
+ uint h = unchecked((uint)(Mathf.FloorToInt(at.x) * 73856093 ^ Mathf.FloorToInt(at.z) * 19349663));
+ return names[h % (uint)names.Length];
+ }
+
+ public static bool Skinned(GameObject prefab) => prefab.GetComponentInChildren<SkinnedMeshRenderer>(true) != null;
+
+ /// <summary>The prefab's static meshes in the placement's unit frame (footprint centred, base at y = 0) for
+ /// <paramref name="fit"/>: Width and Height scale uniformly by the footprint's larger side or the height, Stretch
+ /// by each axis. Skinned prefabs are instantiated instead (HexBoardRenderer).</summary>
+ public static Part[] Parts(GameObject prefab, Fit fit)
+ {
+ var go = Object.Instantiate(prefab);
+ try
+ {
+ var b = Bounds(go);
+ var size = new Vector3(Mathf.Max(b.size.x, 1e-4f), Mathf.Max(b.size.y, 1e-4f), Mathf.Max(b.size.z, 1e-4f));
+ var s = Normaliser(size, fit);
+ var norm = Matrix4x4.Scale(s) * Matrix4x4.Translate(new Vector3(-b.center.x, -b.min.y, -b.center.z));
+ return go.GetComponentsInChildren<MeshFilter>()
+ .Where(f => f.sharedMesh != null && f.GetComponent<MeshRenderer>() != null)
+ .SelectMany(f => f.GetComponent<MeshRenderer>().sharedMaterials.Select((m, i) => (f, m, i)))
+ .Where(x => x.m != null && x.i < x.f.sharedMesh.subMeshCount)
+ .Select(x => new Part(x.f.sharedMesh, x.i, x.m, norm * x.f.transform.localToWorldMatrix)).ToArray();
+ }
+ finally { Object.DestroyImmediate(go); }
+ }
+
+ public static Vector3 Normaliser(Vector3 size, Fit fit) => fit switch
+ {
+ Fit.Width => Vector3.one / Mathf.Max(size.x, size.z),
+ Fit.Height => Vector3.one / size.y,
+ _ => new Vector3(1f / size.x, 1f / size.y, 1f / size.z),
+ };
+
+ public static Bounds Bounds(GameObject go)
+ {
+ var rs = go.GetComponentsInChildren<Renderer>();
+ if (rs.Length == 0) return new Bounds(Vector3.zero, Vector3.one);
+ var b = rs[0].bounds; foreach (var r in rs) b.Encapsulate(r.bounds);
+ return b;
+ }
+
+ /// <summary>Triangles one placement of <paramref name="id"/> draws (its stand-in's when the model is missing).</summary>
+ public static int Triangles(string id, StandIn standIn, Vector3 at)
+ {
+ var prefab = Prefab(Resolve(id, at));
+ if (prefab == null) return StandInTriangles(standIn);
+ int t = 0;
+ foreach (var f in prefab.GetComponentsInChildren<MeshFilter>(true)) if (f.sharedMesh != null) t += IndexTriangles(f.sharedMesh);
+ foreach (var s in prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true)) if (s.sharedMesh != null) t += IndexTriangles(s.sharedMesh);
+ return t;
+ }
+
+ // --- stand-ins: HexStandIns' unit shapes, proportioned per kind ---
+
+ static readonly Dictionary<StandIn, (Mesh mesh, string colour, Matrix4x4 local)[]> standIns = new Dictionary<StandIn, (Mesh, string, Matrix4x4)[]>();
+
+ public static (Mesh mesh, string colour, Matrix4x4 local)[] StandInParts(StandIn kind)
+ {
+ // Editor scene changes can release procedural meshes while this static cache survives.
+ if (standIns.TryGetValue(kind, out var p) && p.All(part => part.mesh != null)) return p;
+ (Mesh, string, Matrix4x4)[] From(HexStandIns.Shape shape, Vector3 scale) =>
+ HexStandIns.Build(shape).Select(part => (part.mesh, part.colour, Matrix4x4.Scale(scale))).ToArray();
+ return standIns[kind] = kind switch
+ {
+ StandIn.Box => From(HexStandIns.Shape.Box, new Vector3(1f, 0.65f, 1f)),
+ StandIn.Tree => From(HexStandIns.Shape.Olive, new Vector3(0.8f, 1f, 0.8f)),
+ StandIn.Pine => From(HexStandIns.Shape.Cypress, new Vector3(0.45f, 1f, 0.45f)),
+ StandIn.Palm => From(HexStandIns.Shape.Palm, new Vector3(0.6f, 1f, 0.6f)),
+ StandIn.Rock => From(HexStandIns.Shape.Rock, new Vector3(1f, 0.6f, 1f)),
+ StandIn.Figure => new[] { (Resources.GetBuiltinResource<Mesh>("Capsule.fbx"), "hull", Matrix4x4.Translate(new Vector3(0f, 0.5f, 0f)) * Matrix4x4.Scale(new Vector3(0.3f, 0.5f, 0.3f))) },
+ _ => From(HexStandIns.Shape.Field, Vector3.one),
+ };
+ }
+
+ public static int StandInTriangles(StandIn kind) => StandInParts(kind).Sum(p => IndexTriangles(p.mesh));
+
+ /// <summary>Triangles from index counts, which a player can read on any mesh (mesh.triangles needs Read/Write).</summary>
+ public static int IndexTriangles(Mesh m)
+ {
+ // A player refuses even index counts on meshes imported without Read/Write; the counts only feed editor stats.
+ if (!m.isReadable && !Application.isEditor) return 0;
+ long n = 0;
+ for (int i = 0; i < m.subMeshCount; i++) n += m.GetIndexCount(i);
+ return (int)(n / 3);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexModels.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexModels.cs.meta
new file mode 100644
index 000000000..19600449d
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexModels.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c4b6c2c42bd4a4aa7a20d54cf7fa9552
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexRealMap.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexRealMap.cs
new file mode 100644
index 000000000..a5b2adeb8
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexRealMap.cs
@@ -0,0 +1,84 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Statecraft.Game.Map;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>Puts a hex board on the game's real map. The board's hexes are the game's own q/r on the same lattice
+ /// (HexGrid), so its root sits at (0, sea level, map length) with no turn or scale. Under the board's land the real
+ /// ground is eased down to the board's hex-shaped ground (blending out over about one hex; its water is left to the
+ /// real sea), the board's terrain is cut away everywhere but its land, and the real settlement markers and building
+ /// prototypes on that land are hidden. Destroying the returned root puts the real heights and renderers back.</summary>
+ public static class HexRealMap
+ {
+ const float SinkM = 30f, BlendFromShare = 0.9f, BlendToShare = 1.7f;
+
+ public static (GameObject root, List<HexTileReport> reports) Place(MapScene map, HexBoard board, Func<string, (Texture2D?, Texture2D?)>? textures, Transform? parent = null, Action? restoreDressing = null)
+ {
+ float sea = Shader.GetGlobalVector(MapShaderGlobals.Map).z; // the map's sea level, set when it is built
+ var origin = new Vector3(0f, sea, map.Frame.LengthM);
+ var surface = new HexBoardSurface(board);
+ // Distance to the nearest board hex centre, looking only at the two rings round the hex under the point.
+ float Near(Vector3 b)
+ {
+ var (q0, r0) = HexGeometry.Axial(b, HexScale.HexM);
+ float best = float.MaxValue;
+ for (int dq = -2; dq <= 2; dq++)
+ for (int dr = Mathf.Max(-2, -dq - 2); dr <= Mathf.Min(2, -dq + 2); dr++)
+ {
+ if (!board.Hexes.ContainsKey((q0 + dq, r0 + dr))) continue;
+ var c = HexGeometry.Centre(q0 + dq, r0 + dr, HexScale.HexM);
+ best = Mathf.Min(best, new Vector2(b.x - c.x, b.z - c.z).magnitude);
+ }
+ return best;
+ }
+
+ // 1. Ease the real ground down to the board's ground under and around its land; remember it for teardown.
+ var t = map.Terrain; var data = t.terrainData; var tp = t.transform.position;
+ int res = data.heightmapResolution;
+ var rect = HexBoardBuilder.Bounds(board);
+ int x0 = Mathf.Clamp(Mathf.FloorToInt((origin.x + rect.xMin - tp.x) / data.size.x * (res - 1)), 0, res - 1);
+ int x1 = Mathf.Clamp(Mathf.CeilToInt((origin.x + rect.xMax - tp.x) / data.size.x * (res - 1)), 0, res - 1);
+ int z0 = Mathf.Clamp(Mathf.FloorToInt((origin.z + rect.yMin - tp.z) / data.size.z * (res - 1)), 0, res - 1);
+ int z1 = Mathf.Clamp(Mathf.CeilToInt((origin.z + rect.yMax - tp.z) / data.size.z * (res - 1)), 0, res - 1);
+ var before = data.GetHeights(x0, z0, x1 - x0 + 1, z1 - z0 + 1);
+ var heights = (float[,])before.Clone();
+ for (int z = 0; z < heights.GetLength(0); z++)
+ for (int x = 0; x < heights.GetLength(1); x++)
+ {
+ var b = new Vector3(tp.x + data.size.x * (x0 + x) / (res - 1f), 0f, tp.z + data.size.z * (z0 + z) / (res - 1f)) - origin;
+ float w = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(BlendToShare * HexScale.HexM, BlendFromShare * HexScale.HexM, Near(b)));
+ if (w <= 0f) continue;
+ float hb = surface.Height(b);
+ if (hb < 0f) continue; // the board's water: the real sea and its depth shading stay
+ heights[z, x] = Mathf.Lerp(heights[z, x], Mathf.Clamp01((sea + hb - SinkM - tp.y) / data.size.y), w);
+ }
+ data.SetHeights(x0, z0, heights);
+
+ // 2. The board on top.
+ var (root, reports) = HexBoardBuilder.Build(board, textures, options: new HexBoardBuilder.Options { OwnSea = false, HolesOutsideLand = true, Origin = origin, Parent = parent });
+ var assets = root.GetComponent<HexBoardAssets>();
+ // Dressing was disabled before placement. Restore it after the renderer states below, so the kits can
+ // hide their placeholder markers again (teardown runs last registered first).
+ if (restoreDressing != null) assets.OnTeardown(restoreDressing);
+ assets.OnTeardown(() => { if (data != null) data.SetHeights(x0, z0, before); });
+
+ // 3. Hide the real markers and building prototypes standing on the board's land (its tiles replace them).
+ var hidden = new List<Renderer>();
+ foreach (var r in map.GetComponentsInChildren<Renderer>(false))
+ {
+ if (r.transform.IsChildOf(root.transform) || r.GetComponent<Terrain>() != null || !r.enabled) continue;
+ var b = r.bounds.center - origin;
+ if (r.bounds.size.x > 3f * HexScale.HexM) continue; // map-wide meshes (sea, skirt, overlays) stay
+ var (q, rr) = HexGeometry.Axial(b, HexScale.HexM);
+ if (!board.Hexes.TryGetValue((q, rr), out var h) || HexBoard.TerrainOf(h) == HexTerrain.Water) continue;
+ r.enabled = false; hidden.Add(r);
+ }
+ assets.OnTeardown(() => { foreach (var r in hidden) if (r != null) r.enabled = true; });
+ return (root, reports);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexRealMap.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexRealMap.cs.meta
new file mode 100644
index 000000000..6e2060d62
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexRealMap.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 579ef1de6329c46af9e38ec33f2b67d4
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexStandIns.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexStandIns.cs
new file mode 100644
index 000000000..5ddac152d
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexStandIns.cs
@@ -0,0 +1,72 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>The stand-in shapes drawn when a model is not on the machine: faceted low-poly unit shapes (footprint
+ /// centred on the origin within a unit square, base at y = 0, 1 tall), each part with a palette colour. Self-contained
+ /// so the hex tiles need nothing from other map layers.</summary>
+ public static class HexStandIns
+ {
+ public static readonly IReadOnlyDictionary<string, Color> Palette = new Dictionary<string, Color>
+ {
+ ["bark"] = new Color(0.36f, 0.27f, 0.20f), ["olive"] = new Color(0.47f, 0.52f, 0.36f), ["cypress"] = new Color(0.16f, 0.30f, 0.18f),
+ ["palm"] = new Color(0.33f, 0.48f, 0.22f), ["rock"] = new Color(0.62f, 0.57f, 0.50f), ["plaster"] = new Color(0.95f, 0.93f, 0.87f),
+ ["green"] = new Color(0.55f, 0.62f, 0.30f), ["hull"] = new Color(0.20f, 0.28f, 0.30f),
+ };
+
+ public enum Shape { Box, Olive, Cypress, Palm, Rock, Field }
+
+ public static (Mesh mesh, string colour)[] Build(Shape shape) => shape switch
+ {
+ Shape.Box => new[] { (Frustum(4, (0f, 0.7071f), (1f, 0.7071f), 45f), "plaster") },
+ Shape.Olive => new[] { (Frustum(5, (0f, 0.06f), (0.35f, 0.05f)), "bark"), (Frustum(6, (0.3f, 0.3f), (0.6f, 0.48f), (1f, 0.18f)), "olive") },
+ Shape.Cypress => new[] { (Frustum(5, (0f, 0.04f), (0.12f, 0.03f)), "bark"), (Frustum(6, (0.1f, 0.1f), (0.35f, 0.17f), (1f, 0f)), "cypress") },
+ Shape.Palm => new[] { (Frustum(5, (0f, 0.03f), (0.85f, 0.024f)), "bark"), (Frustum(8, (0.8f, 0.04f), (0.88f, 0.42f), (1f, 0.05f)), "palm") },
+ Shape.Rock => new[] { (Frustum(5, (0f, 0.5f), (1f, 0.28f)), "rock") },
+ _ => new[] { (Frustum(4, (0f, 0.7071f), (1f, 0.7071f), 45f), "green") },
+ };
+
+ /// <summary>A stack of rings (height, radius) joined by flat-shaded sides, closed top and bottom.</summary>
+ static Mesh Frustum(int sides, params (float y, float r)[] rings) => Frustum(sides, 0f, rings);
+
+ static Mesh Frustum(int sides, (float y, float r) a, (float y, float r) b, float turnDeg) => Frustum(sides, turnDeg, a, b);
+
+ static Mesh Frustum(int sides, float turnDeg, params (float y, float r)[] rings)
+ {
+ var v = new List<Vector3>(); var t = new List<int>();
+ Vector3 P(int ring, int i)
+ {
+ float a = Mathf.Deg2Rad * (turnDeg + 360f * i / sides);
+ return new Vector3(Mathf.Cos(a) * rings[ring].r, rings[ring].y, Mathf.Sin(a) * rings[ring].r);
+ }
+ void Tri(Vector3 p, Vector3 q, Vector3 r) { int n = v.Count; v.Add(p); v.Add(q); v.Add(r); t.Add(n); t.Add(n + 1); t.Add(n + 2); }
+ for (int k = 0; k + 1 < rings.Length; k++)
+ for (int i = 0; i < sides; i++)
+ {
+ Vector3 a0 = P(k, i), a1 = P(k, i + 1), b0 = P(k + 1, i), b1 = P(k + 1, i + 1);
+ Tri(a0, b1, a1); Tri(a0, b0, b1); // clockwise from outside (Unity's front face)
+ }
+ var bottom = new Vector3(0f, rings[0].y, 0f); var top = new Vector3(0f, rings[rings.Length - 1].y, 0f);
+ for (int i = 0; i < sides; i++)
+ {
+ Tri(bottom, P(0, i), P(0, i + 1));
+ if (rings[rings.Length - 1].r > 0f) Tri(top, P(rings.Length - 1, i + 1), P(rings.Length - 1, i));
+ }
+ var m = new Mesh { name = "hex-standin" };
+ m.SetVertices(v); m.SetTriangles(t, 0); m.RecalculateNormals(); m.RecalculateBounds();
+ return m;
+ }
+
+ /// <summary>Poses an animated model at its idle's first frame (the first clip whose name has "idle", else the first).</summary>
+ public static void SampleIdle(Animator a)
+ {
+ var clips = a.runtimeAnimatorController != null ? a.runtimeAnimatorController.animationClips : System.Array.Empty<AnimationClip>();
+ AnimationClip? clip = null;
+ foreach (var c in clips) if (c != null && c.name.IndexOf("idle", System.StringComparison.OrdinalIgnoreCase) >= 0) { clip = c; break; }
+ if (clip == null && clips.Length > 0) clip = clips[0];
+ if (clip != null) clip.SampleAnimation(a.gameObject, 0f);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexStandIns.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexStandIns.cs.meta
new file mode 100644
index 000000000..841cb93a8
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexStandIns.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 0e9249542ac7345da8fd6050cbd77498
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContext.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContext.cs
new file mode 100644
index 000000000..1ddcae46d
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContext.cs
@@ -0,0 +1,175 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>The fallback shape drawn when a model is not on this machine (Tripo models are local-only; a collaborator
+ /// sees stand-ins), and the shape of flat pieces.</summary>
+ public enum StandIn { Box, Tree, Pine, Palm, Rock, Figure, Flat }
+
+ /// <summary>How a model's size is read: by its largest footprint side (buildings, rocks), by its height (figures, trees),
+ /// or stretched to width x height (flat pieces and stand-ins only).</summary>
+ public enum Fit { Width, Height, Stretch }
+
+ /// <summary>One placed piece: a model id (HexModels), the stand-in if it is missing, a tint for stand-ins and flats,
+ /// and the world matrix of its unit frame (footprint centred on the origin, base at y = 0).</summary>
+ public readonly struct HexPlacement
+ {
+ public readonly string Model; public readonly StandIn StandIn; public readonly Fit Fit; public readonly Color Tint;
+ public readonly Matrix4x4 Matrix; public readonly int Q, R;
+ public HexPlacement(string model, StandIn standIn, Fit fit, Color tint, Matrix4x4 matrix, int q, int r)
+ { Model = model; StandIn = standIn; Fit = fit; Tint = tint; Matrix = matrix; Q = q; R = r; }
+ public Vector3 Position => Matrix.GetColumn(3);
+ }
+
+ /// <summary>A stroke of ground texture (HexGround layer) painted into the terrain instead of placing a piece: a soft
+ /// rectangle (a field, a dune, a yard) or a soft line (a track). Blends into neighbouring ground, as Civ paints fields.</summary>
+ public readonly struct HexPaint
+ {
+ public readonly string Layer; public readonly Vector3 A, B; public readonly float Width, Depth, Yaw, Soft, Strength; public readonly bool Line;
+ public HexPaint(string layer, Vector3 a, Vector3 b, float width, float depth, float yaw, float soft, float strength, bool line)
+ { Layer = layer; A = a; B = b; Width = width; Depth = depth; Yaw = yaw; Soft = soft; Strength = strength; Line = line; }
+ }
+
+ /// <summary>The ground a tile is built on: height, slope and water at a world point. The board's own (HexBoardSurface)
+ /// in captures; a flat one in tests.</summary>
+ public interface IHexSurface
+ {
+ float Height(Vector3 p);
+ float SlopeDeg(Vector3 p);
+ bool IsWater(Vector3 p);
+ }
+
+ public sealed class FlatSurface : IHexSurface
+ {
+ public float Height(Vector3 p) => 0f;
+ public float SlopeDeg(Vector3 p) => 0f;
+ public bool IsWater(Vector3 p) => false;
+ }
+
+ /// <summary>Everything a prototype may use: where its hex is, a generator seeded by (q, r), the ground, and Place.
+ /// Every Place checks that the whole footprint stays inside the inset hexagon and on dry, not too steep ground, seats
+ /// the piece at the lowest corner, and records it; it returns false (and places nothing) otherwise.</summary>
+ public sealed class HexTileContext
+ {
+ public readonly int Q, R;
+ public readonly Vector3 Centre;
+ public readonly float SizeM, InsetM;
+ public readonly System.Random Rng;
+ public readonly IHexSurface Surface;
+ readonly List<HexPlacement> placements = new List<HexPlacement>();
+ readonly List<HexPaint> paints = new List<HexPaint>();
+ public IReadOnlyList<HexPlacement> Placements => placements;
+ public IReadOnlyList<HexPaint> Paints => paints;
+
+ /// <summary>Paints a soft rectangle of a ground layer (HexGround.Layers id: wheat, green_crop, ploughed, dirt,
+ /// desert, beach, grass ...) centred at <paramref name="at"/>, clipped to this hex. Costs no triangles; use it for
+ /// fields, dunes, yards and anything that is ground rather than an object. <paramref name="soft"/> is the edge blend
+ /// as a share of the smaller side.</summary>
+ public void PaintGround(string layer, Vector3 at, float yawDeg, float widthM, float depthM, float soft = 0.12f, float strength = 1f) =>
+ paints.Add(new HexPaint(layer, at, at, widthM, depthM, yawDeg, soft, strength, false));
+
+ /// <summary>Paints a soft line of a ground layer from a to b (a track, a path), clipped to this hex.</summary>
+ public void PaintStroke(string layer, Vector3 a, Vector3 b, float widthM, float strength = 1f) =>
+ paints.Add(new HexPaint(layer, a, b, widthM, 0f, 0f, 0.45f, strength, true));
+
+ public HexTileContext(int q, int r, IHexSurface surface, int seed = 1948, float sizeM = HexScale.HexM, float insetShare = HexScale.InsetShare)
+ {
+ Q = q; R = r; SizeM = sizeM; InsetM = sizeM * insetShare; Surface = surface;
+ Centre = HexGeometry.Centre(q, r, sizeM);
+ Rng = new System.Random(seed ^ (q * 73856093) ^ (r * 19349663));
+ }
+
+ /// <summary>S, the hex circumradius in metres; scale pieces as shares of it (HexScale).</summary>
+ public float S => SizeM;
+
+ public float GroundY(Vector3 p) => Surface.Height(p);
+ public bool IsWater(Vector3 p) => Surface.IsWater(p);
+ public float SlopeDeg(Vector3 p) => Surface.SlopeDeg(p);
+
+ /// <summary>Inside the inset hexagon, less <paramref name="marginM"/> more.</summary>
+ public bool Inside(Vector3 p, float marginM = 0f) => HexGeometry.InHex(p, Centre, SizeM, InsetM + marginM);
+
+ /// <summary>Inside the unit spot (HexScale.UnitSpotShare of S about the centre), widened by <paramref name="marginM"/>;
+ /// context tiles keep tall pieces out of it, so any unit can stand on them.</summary>
+ public bool InUnitSpot(Vector3 p, float marginM = 0f) => new Vector2(p.x - Centre.x, p.z - Centre.z).magnitude < HexScale.UnitSpotShare * SizeM + marginM;
+
+ /// <summary>A point from the centre: <paramref name="bearingDeg"/> clockwise from north, <paramref name="share"/> of S.</summary>
+ public Vector3 At(float bearingDeg, float share)
+ {
+ float a = Mathf.Deg2Rad * (90f - bearingDeg);
+ return Centre + new Vector3(Mathf.Cos(a), 0f, Mathf.Sin(a)) * (share * SizeM);
+ }
+
+ /// <summary>A uniform random point inside the inset hexagon less <paramref name="marginM"/>.</summary>
+ public Vector3 RandomPoint(float marginM = 0f)
+ {
+ for (int i = 0; i < 64; i++)
+ {
+ var p = Centre + new Vector3((float)(Rng.NextDouble() * 2 - 1) * SizeM, 0f, (float)(Rng.NextDouble() * 2 - 1) * SizeM);
+ if (Inside(p, marginM)) return p;
+ }
+ return Centre;
+ }
+
+ public float Range(float min, float max) => min + (float)Rng.NextDouble() * (max - min);
+
+ /// <summary>A model sized by its largest footprint side, <paramref name="widthM"/> (buildings, rocks).</summary>
+ public bool PlaceByWidth(string model, Vector3 at, float yawDeg, float widthM, StandIn standIn, Color? tint = null, float maxSlopeDeg = 30f) =>
+ PlaceByWidthExact(model, at, yawDeg, widthM * HexScale.PieceScale, standIn, tint, maxSlopeDeg);
+
+ bool PlaceByWidthExact(string model, Vector3 at, float yawDeg, float widthM, StandIn standIn, Color? tint, float maxSlopeDeg) =>
+ Place(model, at, yawDeg, new Vector3(widthM, widthM, widthM), Fit.Width, standIn, tint, widthM, maxSlopeDeg);
+
+ /// <summary>A model sized by its height, <paramref name="heightM"/> (figures, trees); its footprint for the inside
+ /// test is taken as <paramref name="footprintShare"/> of the height.</summary>
+ public bool PlaceByHeight(string model, Vector3 at, float yawDeg, float heightM, StandIn standIn, Color? tint = null, float footprintShare = 0.5f, float maxSlopeDeg = 35f)
+ {
+ heightM *= HexScale.PieceScale;
+ return Place(model, at, yawDeg, new Vector3(heightM, heightM, heightM), Fit.Height, standIn, tint, heightM * footprintShare, maxSlopeDeg);
+ }
+
+ /// <summary>A flat piece (a field, a road, a plaza) of width x depth, its top a few metres above the highest ground.</summary>
+ public bool PlaceFlat(Vector3 at, float yawDeg, float widthM, float depthM, Color tint, float maxRiseM = 60f)
+ {
+ var rot = Quaternion.Euler(0f, yawDeg, 0f);
+ float lo = float.MaxValue, hi = float.MinValue;
+ foreach (var c in Footprint(widthM, depthM))
+ {
+ var q = at + rot * c;
+ if (!Inside(q) || IsWater(q)) return false;
+ float y = GroundY(q); lo = Mathf.Min(lo, y); hi = Mathf.Max(hi, y);
+ }
+ if (hi - lo > maxRiseM) return false;
+ const float depth = 12f;
+ placements.Add(new HexPlacement("", StandIn.Flat, Fit.Stretch, tint,
+ Matrix4x4.TRS(new Vector3(at.x, lo - depth, at.z), rot, new Vector3(widthM, hi - lo + depth + 5f, depthM)), Q, R));
+ return true;
+ }
+
+ bool Place(string model, Vector3 at, float yawDeg, Vector3 scale, Fit fit, StandIn standIn, Color? tint, float footprintM, float maxSlopeDeg)
+ {
+ var rot = Quaternion.Euler(0f, yawDeg, 0f);
+ float lo = float.MaxValue, hi = float.MinValue;
+ foreach (var c in Footprint(footprintM, footprintM))
+ {
+ var q = at + rot * c;
+ if (!Inside(q) || IsWater(q) || SlopeDeg(q) > maxSlopeDeg) return false;
+ float y = GroundY(q); lo = Mathf.Min(lo, y); hi = Mathf.Max(hi, y);
+ }
+ float sink = 0.02f * footprintM + (hi - lo) * 0.5f;
+ placements.Add(new HexPlacement(model, standIn, fit, tint ?? Color.white,
+ Matrix4x4.TRS(new Vector3(at.x, (lo + hi) * 0.5f - sink, at.z), rot, scale), Q, R));
+ return true;
+ }
+
+ static IEnumerable<Vector3> Footprint(float w, float d)
+ {
+ yield return Vector3.zero;
+ yield return new Vector3(w, 0f, d) * 0.5f; yield return new Vector3(-w, 0f, d) * 0.5f;
+ yield return new Vector3(w, 0f, -d) * 0.5f; yield return new Vector3(-w, 0f, -d) * 0.5f;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContext.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContext.cs.meta
new file mode 100644
index 000000000..0d3220770
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContext.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 9d17ccd523c4c4fc7b6a1cdde5bb68f4
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContract.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContract.cs
new file mode 100644
index 000000000..1c49e52e9
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContract.cs
@@ -0,0 +1,117 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>What the board raises under a tile. Civ-style: the ground follows the hexes, not a real heightmap.</summary>
+ public enum HexTerrain { Flat, Hills, Mountain, Water }
+
+ /// <summary>Marks a class as a hex prototype with a unique, stable id (lower_snake_case). The board finds prototypes by
+ /// this attribute, so adding one is adding one file: no table or switch elsewhere is edited.</summary>
+ [AttributeUsage(AttributeTargets.Class, Inherited = false)]
+ public sealed class HexPrototypeAttribute : Attribute
+ {
+ public string Id { get; }
+ public HexPrototypeAttribute(string id) => Id = id;
+ }
+
+ /// <summary>One kind of hex tile (a city quarter, a forest, a unit on the march ...). Build places pieces through the
+ /// context only, and must be deterministic: the same context seed gives the same placements (tested).</summary>
+ public interface IHexPrototype
+ {
+ /// <summary>A short human title for captures and stats.</summary>
+ string Title { get; }
+ /// <summary>The ground shape this tile wants when a board does not say otherwise.</summary>
+ HexTerrain Terrain { get; }
+ /// <summary>Ground texture layer (HexGround.Layers) when a board does not say otherwise.</summary>
+ string Ground { get; }
+ /// <summary>Most triangles the tile may draw (models after decimation; tested). See HexScale.Budget.</summary>
+ int TriangleBudget { get; }
+ void Build(HexTileContext ctx);
+ }
+
+ /// <summary>The shared scale, in hex units, so every tile reads at the same size (Civ VI as the reference: few, large
+ /// pieces). S = HexM is the hex circumradius; a hex is sqrt(3) S across flat to flat. Start values, tuned from captures.</summary>
+ public static class HexScale
+ {
+ public const float HexM = 5000f;
+ /// <summary>Keep pieces this share of S inside the hexagon, so tile edges read.</summary>
+ public const float InsetShare = 0.07f;
+ /// <summary>Every placed piece is drawn this much larger than its prototype asks (Tal, 19 Oct: "the models a bit
+ /// bigger"): Civ reads tiles by a few large pieces. Tune here, not in each prototype.</summary>
+ public const float PieceScale = 1.35f;
+ /// <summary>Buildings: footprint 0.12 to 0.2 S; 12 to 25 per city hex. A hero landmark up to 0.4 S.</summary>
+ public const float BuildingMin = 0.12f, BuildingMax = 0.20f, LandmarkMax = 0.40f;
+ /// <summary>Trees: height 0.12 to 0.2 S; 25 to 60 in a forest hex, 15 to 40 in an orchard.</summary>
+ public const float TreeMin = 0.12f, TreeMax = 0.20f;
+ /// <summary>Figures (units, people, animals): height 0.14 to 0.22 S, larger than buildings as Civ draws units;
+ /// 3 to 7 to a unit.</summary>
+ public const float FigureMin = 0.14f, FigureMax = 0.22f;
+ /// <summary>The unit spot: keep tall pieces (buildings, trees, rocks) out of this radius about the centre, where a
+ /// unit stands (units are a layer above every tile). Flats (fields, roads) may run under it. ctx.InUnitSpot tests it.</summary>
+ public const float UnitSpotShare = 0.3f;
+ /// <summary>Default triangle budgets per tile kind (after decimation): city 40k, forest 60k, units 60k, fields 20k.</summary>
+ public const int BudgetCity = 40000, BudgetForest = 60000, BudgetUnits = 60000, BudgetFields = 20000;
+ }
+
+ /// <summary>All prototypes in loaded assemblies, by id.</summary>
+ public static class HexPrototypes
+ {
+ static Dictionary<string, Type>? all;
+
+ public static IReadOnlyDictionary<string, Type> All => all ??= AppDomain.CurrentDomain.GetAssemblies()
+ .SelectMany(a => { try { return a.GetTypes(); } catch (System.Reflection.ReflectionTypeLoadException e) { return e.Types.Where(t => t != null)!; } })
+ .Where(t => t != null && !t.IsAbstract && typeof(IHexPrototype).IsAssignableFrom(t))
+ .Select(t => (t, attr: (HexPrototypeAttribute?)Attribute.GetCustomAttribute(t, typeof(HexPrototypeAttribute))))
+ .Where(p => p.attr != null)
+ .ToDictionary(p => p.attr!.Id, p => p.t!, StringComparer.Ordinal);
+
+ public static IHexPrototype Create(string id) =>
+ All.TryGetValue(id, out var t) ? (IHexPrototype)Activator.CreateInstance(t)! : throw new KeyNotFoundException($"no hex prototype '{id}' (known: {string.Join(", ", All.Keys)})");
+ }
+
+ /// <summary>Pointy-top hex geometry in world x/z (HexGrid's lattice, z = -y): circumradius S, flat sides east and west.</summary>
+ public static class HexGeometry
+ {
+ public const float Sqrt3 = 1.7320508f;
+
+ public static Vector3 Centre(int q, int r, float sizeM)
+ {
+ var c = Statecraft.Game.Map.HexGrid.Centre(q, r, sizeM);
+ return new Vector3(c.x, 0f, -c.y);
+ }
+
+ /// <summary>Inside the hexagon about <paramref name="centre"/>, shrunk by <paramref name="insetM"/> on every side.</summary>
+ public static bool InHex(Vector3 p, Vector3 centre, float sizeM, float insetM = 0f)
+ {
+ float a = sizeM * 0.8660254f - insetM, dx = p.x - centre.x, dz = p.z - centre.z;
+ return Mathf.Abs(dx) <= a && Mathf.Abs(dx * 0.5f + dz * 0.8660254f) <= a && Mathf.Abs(-dx * 0.5f + dz * 0.8660254f) <= a;
+ }
+
+ /// <summary>The axial hex containing p (cube rounding of HexGrid's inverse).</summary>
+ public static (int q, int r) Axial(Vector3 p, float sizeM)
+ {
+ float x = p.x, y = -p.z;
+ float qf = (Sqrt3 / 3f * x - y / 3f) / sizeM, rf = (2f / 3f * y) / sizeM, sf = -qf - rf;
+ int q = Mathf.RoundToInt(qf), r = Mathf.RoundToInt(rf), s = Mathf.RoundToInt(sf);
+ float dq = Mathf.Abs(q - qf), dr = Mathf.Abs(r - rf), ds = Mathf.Abs(s - sf);
+ if (dq > dr && dq > ds) q = -r - s; else if (dr > ds) r = -q - s;
+ return (q, r);
+ }
+
+ public static readonly (int q, int r)[] Neighbours = { (1, 0), (1, -1), (0, -1), (-1, 0), (-1, 1), (0, 1) };
+
+ public static int Distance(int q0, int r0, int q1, int r1)
+ {
+ int dq = q1 - q0, dr = r1 - r0;
+ return (Math.Abs(dq) + Math.Abs(dr) + Math.Abs(dq + dr)) / 2;
+ }
+
+ /// <summary>The six corners, starting north, clockwise seen from above.</summary>
+ public static Vector3[] Corners(Vector3 centre, float sizeM) =>
+ Enumerable.Range(0, 6).Select(i => { float a = Mathf.Deg2Rad * (90f - 60f * i); return centre + new Vector3(Mathf.Cos(a), 0f, Mathf.Sin(a)) * sizeM; }).ToArray();
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContract.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContract.cs.meta
new file mode 100644
index 000000000..86cb1ecba
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexTileContract.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ef50b6e98e5e840e896369dcf7a606bc
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexUnits.cs b/unity/Assets/Scripts/Map/HexTiles/Core/HexUnits.cs
new file mode 100644
index 000000000..0b1c69207
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexUnits.cs
@@ -0,0 +1,193 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine;
+using Object = UnityEngine.Object;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>One member of a unit: a model (a rigged figure or an animated vehicle), its place in the formation (metres
+ /// in the unit's frame: x to the right, z forward, as shares of S), its height share of S, and how far it travels per
+ /// cycle of its move clip (a walk cycle's stride, a wheel's turn), also as a share of S.</summary>
+ public sealed class HexUnitMember
+ {
+ public string Model = ""; public StandIn StandIn = StandIn.Figure; public Vector2 Offset; public float HeightShare = 0.18f;
+ public float CycleShare = 0.15f; public bool ByWidth;
+ /// <summary>Degrees to turn this model so its front faces the direction of travel (vehicles often face +X).</summary>
+ public float YawOffset;
+ }
+
+ /// <summary>Unit sizes, larger than buildings and spread over much of the hex as Civ V draws units (Tal, 18 Oct): a
+ /// character unit is exactly
+ /// <see cref="Characters"/> figures and nothing else; a vehicle unit is one vehicle. Shares of S.</summary>
+ public static class HexUnitScale
+ {
+ public const int Characters = 8;
+ public const float FigureHeight = 0.38f, FigureSpacing = 0.25f, VehicleLength = 0.55f;
+ /// <summary>Distance per walk cycle as a share of figure height (a stride of about 1.5 m for 1.75 m tall).</summary>
+ public const float StridePerHeight = 0.86f;
+ }
+
+ /// <summary>Marks a unit type with a unique id (lower_snake_case). Units live in Units/, one file each.</summary>
+ [AttributeUsage(AttributeTargets.Class, Inherited = false)]
+ public sealed class HexUnitTypeAttribute : Attribute
+ {
+ public string Id { get; }
+ public HexUnitTypeAttribute(string id) => Id = id;
+ }
+
+ public interface IHexUnitType
+ {
+ string Title { get; }
+ HexUnit Create();
+ }
+
+ public static class HexUnitTypes
+ {
+ static Dictionary<string, Type>? all;
+
+ public static IReadOnlyDictionary<string, Type> All => all ??= AppDomain.CurrentDomain.GetAssemblies()
+ .SelectMany(a => { try { return a.GetTypes(); } catch (System.Reflection.ReflectionTypeLoadException e) { return e.Types.Where(t => t != null)!; } })
+ .Where(t => t != null && !t.IsAbstract && typeof(IHexUnitType).IsAssignableFrom(t))
+ .Select(t => (t, attr: (HexUnitTypeAttribute?)Attribute.GetCustomAttribute(t, typeof(HexUnitTypeAttribute))))
+ .Where(p => p.attr != null)
+ .ToDictionary(p => p.attr!.Id, p => p.t!, StringComparer.Ordinal);
+
+ public static IHexUnitType Create(string id) =>
+ All.TryGetValue(id, out var t) ? (IHexUnitType)Activator.CreateInstance(t)! : throw new KeyNotFoundException($"no hex unit type '{id}' (known: {string.Join(", ", All.Keys)})");
+
+ /// <summary>A formation of <paramref name="models"/> cycled over HexUnitScale.Characters figures: rows of 3, 2, 3
+ /// (a wedge), spaced HexUnitScale.FigureSpacing, all facing forward.</summary>
+ public static HexUnit Squad(string title, params string[] models)
+ {
+ var unit = new HexUnit { Title = title };
+ var slots = new[] { (-1f, 1f), (0f, 1.15f), (1f, 1f), (-0.5f, 0f), (0.5f, 0f), (-1f, -1f), (0f, -0.85f), (1f, -1f) };
+ for (int i = 0; i < HexUnitScale.Characters; i++)
+ unit.Members.Add(new HexUnitMember
+ {
+ Model = models[i % models.Length], StandIn = StandIn.Figure,
+ Offset = new Vector2(slots[i].Item1, slots[i].Item2) * HexUnitScale.FigureSpacing,
+ HeightShare = HexUnitScale.FigureHeight, CycleShare = HexUnitScale.FigureHeight * HexUnitScale.StridePerHeight,
+ });
+ return unit;
+ }
+ }
+
+ /// <summary>A unit: the members that move together across hexes. Units are their own layer, never part of a tile's
+ /// art: the tile draws the land, the unit layer draws who stands on it, so a unit can leave one tile and enter the next.</summary>
+ public sealed class HexUnit
+ {
+ public string Title = ""; public List<HexUnitMember> Members = new List<HexUnitMember>();
+ }
+
+ /// <summary>Moves a unit along a path of hex centres. Presentation only: the simulation decides the move (A to B);
+ /// this glides the group between centres, turning smoothly at each, and drives each member's clip by distance
+ /// travelled (stride-locked: the feet and wheels never slide), with the idle clip when it stands. Tripo clips are
+ /// exported in place (no root motion), so position is the code's and every move ends exactly on a hex centre.</summary>
+ public sealed class HexUnitMotion
+ {
+ sealed class Live { public HexUnitMember M = null!; public GameObject Go = null!, Rig = null!; public AnimationClip? Move, Idle; public float Scale; }
+
+ readonly List<Live> live = new List<Live>();
+ readonly List<Vector3> path;
+ readonly IHexSurface surface;
+ readonly float size, length;
+ /// <summary>Degrees the models' front is turned from +Z (Tripo exports through Blender face -Y, imported +Z: 0).</summary>
+ public float ModelYaw = 0f;
+
+ readonly float facing;
+ public IReadOnlyList<GameObject> Objects => live.Select(l => l.Go).ToList();
+
+ /// <summary><paramref name="facingDeg"/> is the heading (degrees from north) of a unit standing on a one-hex path.</summary>
+ public HexUnitMotion(HexUnit unit, IReadOnlyList<(int q, int r)> hexes, IHexSurface surface, Transform parent, float sizeM = HexScale.HexM, float facingDeg = 0f)
+ {
+ this.surface = surface; size = sizeM; facing = facingDeg;
+ path = hexes.Select(h => HexGeometry.Centre(h.q, h.r, sizeM)).ToList();
+ for (int i = 1; i < path.Count; i++) length += Vector3.Distance(path[i - 1], path[i]);
+ Material? fallbackMaterial = null;
+ foreach (var m in unit.Members)
+ {
+ var prefab = HexModels.Prefab(m.Model);
+ GameObject go;
+ if (prefab != null)
+ {
+ go = Object.Instantiate(prefab, parent);
+ }
+ else
+ {
+ go = GameObject.CreatePrimitive(m.StandIn == StandIn.Box ? PrimitiveType.Cube : PrimitiveType.Capsule);
+ go.transform.SetParent(parent, false);
+ Object.DestroyImmediate(go.GetComponent<Collider>());
+ if (fallbackMaterial == null)
+ {
+ var assets = parent.GetComponentInParent<HexBoardAssets>() ?? parent.gameObject.AddComponent<HexBoardAssets>();
+ fallbackMaterial = assets.Own(HexMaterials.New(HexMaterials.Lit));
+ }
+ go.GetComponent<MeshRenderer>().sharedMaterial = fallbackMaterial;
+ }
+ var b = HexModels.Bounds(go);
+ float scale = m.ByWidth ? m.HeightShare * sizeM / Mathf.Max(b.size.x, b.size.z) : m.HeightShare * sizeM / Mathf.Max(b.size.y, 1e-4f);
+ go.transform.localScale = Vector3.one * scale;
+ var animator = go.GetComponentInChildren<Animator>();
+ var clips = animator != null && animator.runtimeAnimatorController != null ? animator.runtimeAnimatorController.animationClips : Array.Empty<AnimationClip>();
+ live.Add(new Live
+ {
+ M = m, Go = go, Rig = animator != null ? animator.gameObject : go, Scale = scale,
+ Move = clips.FirstOrDefault(c => c.name.IndexOf("walk", StringComparison.OrdinalIgnoreCase) >= 0) ?? clips.FirstOrDefault(c => c.name.IndexOf("idle", StringComparison.OrdinalIgnoreCase) < 0),
+ Idle = clips.FirstOrDefault(c => c.name.IndexOf("idle", StringComparison.OrdinalIgnoreCase) >= 0),
+ });
+ }
+ }
+
+ /// <summary>Total path length in metres.</summary>
+ public float Length => length;
+
+ /// <summary>Poses the unit <paramref name="distance"/> metres along the path (clamped), moving or standing.</summary>
+ public Vector3 Pose(float distance, bool moving)
+ {
+ distance = Mathf.Clamp(distance, 0f, length);
+ var (centre, heading) = Along(distance);
+ var turn = Quaternion.Euler(0f, heading, 0f);
+ foreach (var l in live)
+ {
+ var p = centre + turn * new Vector3(l.M.Offset.x * size, 0f, l.M.Offset.y * size);
+ p.y = surface.Height(p);
+ // Board space: the units' parent sits in the board root (or at the origin for a board on its own).
+ l.Go.transform.localPosition = p; l.Go.transform.localRotation = Quaternion.Euler(0f, heading + ModelYaw + l.M.YawOffset, 0f);
+ var clip = moving ? l.Move ?? l.Idle : l.Idle ?? l.Move;
+ if (clip == null) continue;
+ float cycle = l.M.CycleShare * size;
+ float t = moving ? Mathf.Repeat(distance / cycle, 1f) * clip.length : 0f;
+ clip.SampleAnimation(l.Rig, t); // clips are authored on the Animator's object
+ }
+ return new Vector3(centre.x, surface.Height(centre), centre.z);
+ }
+
+ /// <summary>The point and heading (degrees from north) at a distance along the path; headings blend over the last
+ /// and first 0.35 S of each leg, so the unit turns smoothly at a hex centre instead of snapping.</summary>
+ (Vector3 at, float heading) Along(float d)
+ {
+ for (int i = 1; i < path.Count; i++)
+ {
+ float leg = Vector3.Distance(path[i - 1], path[i]);
+ if (d <= leg || i == path.Count - 1)
+ {
+ float u = Mathf.Clamp01(d / leg);
+ var at = Vector3.Lerp(path[i - 1], path[i], u);
+ float h = Bearing(path[i - 1], path[i]);
+ float blend = 0.35f * size;
+ if (i + 1 < path.Count && leg - d < blend)
+ h = Mathf.LerpAngle(h, Bearing(path[i], path[i + 1]), 0.5f * (1f - (leg - d) / blend));
+ if (i > 1 && d < blend)
+ h = Mathf.LerpAngle(Bearing(path[i - 2], path[i - 1]), h, 0.5f + 0.5f * d / blend);
+ return (at, h);
+ }
+ d -= leg;
+ }
+ return (path[0], facing);
+ }
+
+ static float Bearing(Vector3 a, Vector3 b) => Mathf.Atan2(b.x - a.x, b.z - a.z) * Mathf.Rad2Deg;
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Core/HexUnits.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Core/HexUnits.cs.meta
new file mode 100644
index 000000000..a42fefd0c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Core/HexUnits.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: f4284d26e5f414b95baaf39d48818693
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/HexTilesLook.cs b/unity/Assets/Scripts/Map/HexTiles/HexTilesLook.cs
new file mode 100644
index 000000000..5da7303cf
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/HexTilesLook.cs
@@ -0,0 +1,80 @@
+#nullable enable
+using System;
+using System.Text.RegularExpressions;
+using Statecraft.Game.Map;
+using UnityEngine;
+
+namespace Statecraft.HexTiles
+{
+ /// <summary>The hex-tile map (docs/hex-tiles/README.md), opt-in while it covers only central Israel and its models
+ /// are local: Web ?hex-tiles or ?hex-tiles=1, desktop -hex-tiles; a board id picks another board (Web
+ /// ?hex-tiles=tel_aviv_crop, desktop -hex-tiles tel_aviv_crop). Puts the board on the real map (HexRealMap) under one
+ /// "HexTiles" root beside the map's own; off with nothing applied touches nothing, so the shipped map is unchanged.
+ /// Presentation only: no simulation state is read or written.</summary>
+ public static class HexTilesLook
+ {
+ public const string RootName = "HexTiles", Board = "central_israel";
+ /// <summary>The map's own dressing layers (KitLayer's VisualToggles) that the board stands in for.</summary>
+ static readonly string[] DressingToggles = { "kits", "trees" };
+ static readonly Regex Flag = new Regex(@"(?:^|&)hex-tiles(?:=(?<board>[a-z][a-z0-9_]*|1))?(?=&|$)", RegexOptions.CultureInvariant);
+
+ public static bool Requested() =>
+ Requested(Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer);
+
+ /// <summary>Web: only a top-level query parameter counts, bare or "=1" (MapLook's rule). Desktop: the exact argument.</summary>
+ public static bool Requested(string? url, string[] args, bool webgl) => RequestedBoard(url, args, webgl) != null;
+
+ /// <summary>The board asked for: null when the switch is off, else the given board id or the default board.</summary>
+ public static string? RequestedBoard(string? url, string[] args, bool webgl)
+ {
+ if (!webgl)
+ {
+ int i = Array.IndexOf(args, "-hex-tiles");
+ if (i < 0) return null;
+ return i + 1 < args.Length && Regex.IsMatch(args[i + 1], "^[a-z][a-z0-9_]*$") ? args[i + 1] : Board;
+ }
+ var address = (url ?? "").Split('#')[0];
+ var start = address.IndexOf('?');
+ if (start < 0) return null;
+ var m = Flag.Match(address.Substring(start + 1));
+ if (!m.Success) return null;
+ var id = m.Groups["board"].Value;
+ return id == "" || id == "1" ? Board : id;
+ }
+
+ /// <summary>Removes an earlier board (which restores the real map), then builds it when <paramref name="enabled"/>.</summary>
+ public static void Apply(MapScene map, bool enabled)
+ {
+ if (map == null) return;
+ var old = map.transform.Find(RootName);
+ if (old != null)
+ {
+ // Undo the old board now: its Destroy runs only at the frame's end, after a new board may be built.
+ old.GetComponentInChildren<HexBoardAssets>()?.Teardown();
+ old.SetParent(null, false);
+ if (Application.isPlaying) UnityEngine.Object.Destroy(old.gameObject); else UnityEngine.Object.DestroyImmediate(old.gameObject);
+ }
+ if (!enabled || map.Terrain == null) return;
+ var holder = new GameObject(RootName).transform;
+ holder.SetParent(map.transform, false);
+ var id = RequestedBoard(Application.absoluteURL, Environment.GetCommandLineArgs(), Application.platform == RuntimePlatform.WebGLPlayer) ?? Board;
+ if (Resources.Load<TextAsset>(HexBoard.BoardsFolder + "/" + id) == null) { Debug.LogWarning($"hex-tiles: no board '{id}', using {Board}"); id = Board; }
+ // The hex tiles replace the map's own dressing (its town kits and planted trees), which would otherwise draw
+ // over them; both come back when the board is removed. Off before the board is placed, so what the kits
+ // switch shows is already settled when the board hides the map's markers on its land.
+ SetDressing(false);
+ var (root, _) = HexRealMap.Place(map, HexBoard.Load(id), HexBoard.GroundFromResources, holder,
+ restoreDressing: () => SetDressing(true));
+ // Civ's warm, saturated diorama light while the board is up.
+ var rig = Camera.main != null ? Camera.main.GetComponent<CameraRig>() : null;
+ root.GetComponent<HexBoardAssets>().OnTeardown(HexLook.Apply(rig != null && rig.Volume != null ? rig.Volume.profile : null, MapLighting.FindSun()));
+ }
+
+ static void SetDressing(bool on)
+ {
+ foreach (var layer in DressingToggles)
+ if (System.Linq.Enumerable.Contains(VisualToggles.Names, layer)) // gone once the map's KitLayer has unloaded
+ VisualToggles.Set(layer, on);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/HexTilesLook.cs.meta b/unity/Assets/Scripts/Map/HexTiles/HexTilesLook.cs.meta
new file mode 100644
index 000000000..4703f1502
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/HexTilesLook.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 69c37a89dd9f140d0987da76b1624874
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes.meta
new file mode 100644
index 000000000..47a58538e
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: eb5cfea0a2c6d45a1beb399d8f3533de
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/ArabVillage.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/ArabVillage.cs
new file mode 100644
index 000000000..0054a62b8
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/ArabVillage.cs
@@ -0,0 +1,135 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>An Arab stone village on a hill (the Judean and Samarian foothills, 1948). Flat-roofed limestone houses
+ /// crowd the hilltop in two tight rings round a small paved square, which stays clear for a unit. The village mosque
+ /// (the larger stone courtyard building) faces the square from 0.35 S out, in place of an inner-ring house, and a slim
+ /// minaret stands at the square's corner. Below the houses, two rings of dry-stone terrace walls hold a band of tilled
+ /// terra-rossa soil planted with olives and a few carobs. Three footpaths run down through gaps in the walls, with
+ /// limestone boulders beside them, and prickly-pear hedges and carobs fill the far corners. The soil band and the paths
+ /// are painted into the ground (ctx.PaintGround / PaintStroke); the square and the walls stay flats.
+ ///
+ /// Triangle estimate, at the maximum counts (FlatSurface refuses nothing), with measured per-model counts:
+ /// 14 houses (kit_jerusalem, _2, _3, kit_stone_village_2) x 700 = 9,800. stone-village-v1 x 8,642. Mosque
+ /// kit_stone_village (b17) x 1,400. At most 14 olives x 1602 = 22,428. At most 7 carobs x 648 = 4,536. At most 4
+ /// limestone x 700 = 2,800. Minaret and 6 prickly pears as stand-ins, about 320. About 45 flats x 12 = 540. Total about
+ /// 50,400 of 60,000 (two house slots now go to the mosque, so a little less).
+ ///
+ /// The minaret and the prickly pear have no models (tiles:arab_village/...), so they draw stand-ins: Pine, a slim spire,
+ /// for the minaret and a low Tree for the prickly pear.</summary>
+ [HexPrototype("arab_village")]
+ public sealed class ArabVillage : IHexPrototype
+ {
+ public string Title => "Arab stone village on a hill (1948)";
+ public HexTerrain Terrain => HexTerrain.Hills;
+ public string Ground => "hills";
+ public int TriangleBudget => 60000;
+
+ // Explicit house ids, not wildcards: kit_jerusalem* and kit_stone_village* both include b17, kept for the mosque.
+ static readonly string[] Houses = { "sandbox:kit_jerusalem", "sandbox:kit_jerusalem_2", "sandbox:kit_jerusalem_3", "sandbox:kit_stone_village_2" };
+ const string Mosque = "sandbox:kit_stone_village", Cluster = "proto:stone-village-v1", Minaret = "tiles:arab_village/minaret",
+ PricklyPear = "tiles:arab_village/prickly_pear", Olive = "sandbox:olive_lite", Carob = "sandbox:carob_lite", Rock = "sandbox:limestone*";
+
+ static readonly Color Limestone = new Color(0.82f, 0.76f, 0.64f), Paving = new Color(0.74f, 0.68f, 0.56f),
+ Wall = new Color(0.80f, 0.75f, 0.65f),
+ OliveLeaf = new Color(0.42f, 0.50f, 0.34f), CarobLeaf = new Color(0.20f, 0.34f, 0.16f), Cactus = new Color(0.48f, 0.58f, 0.40f),
+ RockGrey = new Color(0.72f, 0.69f, 0.62f);
+
+ const float HouseSlope = 38f, WallRise = 140f;
+ // The inner-ring slot the mosque takes, and the outer-ring slot beside it that it would overlap.
+ const int MosqueInner = 1, MosqueOuter = 2;
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S, vy = ctx.Range(0f, 360f);
+ float[] paths = { vy + 15f, vy + 135f, vy + 255f };
+ bool NearPath(float bearing, float clearDeg) { foreach (var p in paths) if (Mathf.Abs(Mathf.DeltaAngle(bearing, p)) < clearDeg) return true; return false; }
+
+ // 1. The square on the hilltop (kept clear for a unit), the mosque facing it from 0.35 S out, on the bearing of
+ // inner-ring slot MosqueInner, and the minaret at the square's corner.
+ float mosqueBearing = vy + 30f + 60f * MosqueInner;
+ ctx.PlaceFlat(ctx.Centre, vy, 0.30f * s, 0.30f * s, Paving, 150f);
+ ctx.PlaceByWidth(Mosque, ctx.At(mosqueBearing, 0.35f), mosqueBearing + 180f, 0.2f * s, StandIn.Box, Limestone, maxSlopeDeg: HouseSlope);
+ ctx.PlaceByHeight(Minaret, ctx.At(vy + 45f, 0.165f), vy, 0.2f * s, StandIn.Pine, Limestone, 0.2f, maxSlopeDeg: HouseSlope);
+
+ // 2. Houses in two tight rings, each turned to face the square, with a little jitter so the cluster is organic.
+ // One outer slot is the first-batch stone-village cluster, set a little further out; the mosque takes one
+ // inner slot and the outer slot beside it (their draws are still made, so the sequence holds).
+ int h = 0;
+ for (int k = 0; k < 6; k++)
+ {
+ float b = vy + 30f + 60f * k + ctx.Range(-8f, 8f);
+ var at = ctx.At(b, 0.27f + ctx.Range(-0.015f, 0.015f));
+ float yaw = b + 180f + ctx.Range(-12f, 12f), width = ctx.Range(0.12f, 0.13f) * s;
+ if (k == MosqueInner) continue;
+ ctx.PlaceByWidth(Houses[h++ % Houses.Length], at, yaw, width, StandIn.Box, Limestone, maxSlopeDeg: HouseSlope);
+ }
+ for (int k = 0; k < 9; k++)
+ {
+ float b = vy + 40f * k + ctx.Range(-5f, 5f);
+ if (k == 4)
+ {
+ ctx.PlaceByWidth(Cluster, ctx.At(b, 0.48f), b + 180f, 0.18f * s, StandIn.Box, Limestone, maxSlopeDeg: HouseSlope);
+ continue;
+ }
+ var at = ctx.At(b, 0.44f + ctx.Range(-0.015f, 0.015f));
+ float yaw = b + 180f + ctx.Range(-12f, 12f), width = ctx.Range(0.12f, 0.13f) * s;
+ if (k == MosqueOuter) continue;
+ ctx.PlaceByWidth(Houses[h++ % Houses.Length], at, yaw, width, StandIn.Box, Limestone, maxSlopeDeg: HouseSlope);
+ }
+ float clusterBearing = vy + 160f;
+
+ // 3. Terraces: two rings of thin dry-stone walls along the contour, a band of tilled red soil painted between
+ // them, broken by the three footpaths (and kept clear of the cluster).
+ for (int k = 0; k < 22; k++)
+ {
+ float bb = vy + k * (360f / 22f);
+ if (NearPath(bb, 10f) || Mathf.Abs(Mathf.DeltaAngle(bb, clusterBearing)) < 22f) continue;
+ ctx.PaintGround("ploughed", ctx.At(bb, 0.60f), bb + 90f, 0.16f * s, 0.03f * s, 0.4f, 0.9f); // terrace wall line, painted
+ ctx.PaintGround("ploughed", ctx.At(bb, 0.67f), bb + 90f, 0.17f * s, 0.11f * s, 0.15f, 0.7f);
+ }
+ for (int k = 0; k < 28; k++)
+ {
+ float bb = vy + k * (360f / 28f);
+ if (NearPath(bb, 9f)) continue;
+ ctx.PaintGround("ploughed", ctx.At(bb, 0.74f), bb + 90f, 0.16f * s, 0.03f * s, 0.4f, 0.9f);
+ }
+
+ // 4. The footpaths down the slope, painted as dirt, and limestone boulders where they cut through the upper wall.
+ int rocks = 0;
+ foreach (var p in paths)
+ {
+ ctx.PaintStroke("dirt", ctx.At(p, 0.52f), ctx.At(p, 0.86f), 0.045f * s, 0.85f);
+ if (rocks < 4 && ctx.PlaceByWidth(Rock, ctx.At(p + 11f, 0.60f), ctx.Range(0f, 360f), ctx.Range(0.05f, 0.07f) * s, StandIn.Rock, RockGrey, maxSlopeDeg: 45f)) rocks++;
+ }
+ if (rocks < 4) ctx.PlaceByWidth(Rock, ctx.At(paths[1] - 11f, 0.74f), ctx.Range(0f, 360f), 0.06f * s, StandIn.Rock, RockGrey, maxSlopeDeg: 45f);
+
+ // 5. Olives on the soil band, every fifth tree a carob; capped by what is actually placed.
+ int olives = 0, carobs = 0, slot = 0;
+ for (int k = 0; k < 20; k++)
+ {
+ float bb = vy + 9f + 18f * k;
+ if (NearPath(bb, 10f) || Mathf.Abs(Mathf.DeltaAngle(bb, clusterBearing)) < 22f) continue;
+ var at = ctx.At(bb, 0.67f + ctx.Range(-0.01f, 0.01f));
+ if (slot++ % 5 == 4)
+ {
+ if (carobs < 4 && ctx.PlaceByHeight(Carob, at, ctx.Range(0f, 360f), ctx.Range(0.13f, 0.15f) * s, StandIn.Tree, CarobLeaf, 0.5f, 40f)) carobs++;
+ }
+ else if (olives < 14 && ctx.PlaceByHeight(Olive, at, ctx.Range(0f, 360f), ctx.Range(0.12f, 0.13f) * s, StandIn.Tree, OliveLeaf, 0.5f, 40f)) olives++;
+ }
+
+ // 6. The far corners, past the terraces: carobs in three, prickly-pear hedges (two plants) in the other three.
+ for (int c = 0; c < 6; c++)
+ {
+ float b = 60f * c;
+ if (c % 2 == 0)
+ ctx.PlaceByHeight(Carob, ctx.At(b, 0.83f), ctx.Range(0f, 360f), 0.12f * s, StandIn.Tree, CarobLeaf, 0.5f, 40f);
+ else
+ foreach (float side in new[] { -4f, 4f })
+ ctx.PlaceByHeight(PricklyPear, ctx.At(b + side, 0.83f), ctx.Range(0f, 360f), 0.06f * s, StandIn.Tree, Cactus, 0.9f, 40f);
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/ArabVillage.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/ArabVillage.cs.meta
new file mode 100644
index 000000000..d1db2d578
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/ArabVillage.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 88b94d6eeea6d4e31b2a5c7afbcbd9d5
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/CitrusOrchard.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CitrusOrchard.cs
new file mode 100644
index 000000000..c5f0ab64b
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CitrusOrchard.cs
@@ -0,0 +1,81 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>Jaffa orange groves south-east of Tel Aviv, 1948: an improvement hex like Civ's plantation. Three
+ /// rectangular grove blocks of citrus in straight rows on one grid turned 15 degrees, on dark tilled soil; cypress
+ /// windbreaks along the west and north edges (the sea wind); dirt tracks between the blocks; a packing house on its
+ /// yard by the main track, a citrus truck beside it and a square irrigation pool. Few, large pieces (HexScale).
+ ///
+ /// Soil, tracks and the yard are painted into the ground (ctx.PaintGround / PaintStroke); only the pool is a flat.
+ /// Tall pieces keep out of the unit spot (ctx.InUnitSpot), so the trees there are left out and the packing house
+ /// stands south of it.
+ ///
+ /// Triangle estimate (per-instance counts of the local models): at most 21 citrus x 1600 + 6 cypress x 1600 + truck
+ /// 7000 + packing house up to 1400 = 51,600, plus one flat, against 60,000. Stand-ins draw fewer.</summary>
+ [HexPrototype("citrus_orchard")]
+ public sealed class CitrusOrchard : IHexPrototype
+ {
+ public string Title => "Jaffa orange groves (1948)";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "grass";
+ public int TriangleBudget => HexScale.BudgetForest;
+
+ // Models: the EZ-Tree trees and the Tripo kit and truck are local-only; without them the stand-ins draw.
+ const string Citrus = "sandbox:citrus_lite", Cypress = "sandbox:cypress_lite", House = "sandbox:kit_moshava*",
+ Truck = "proto:vehicle-citrus-truck-v1";
+ static readonly Color Leaf = new Color(0.16f, 0.34f, 0.14f), CypressLeaf = new Color(0.12f, 0.26f, 0.13f),
+ Plaster = new Color(0.88f, 0.80f, 0.68f), Lorry = new Color(0.42f, 0.48f, 0.52f), Water = new Color(0.30f, 0.52f, 0.66f);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S, gridYaw = 15f, row = 0.13f;
+ var turn = Quaternion.Euler(0f, gridYaw, 0f);
+ // A point on the orchard grid, in shares of S.
+ Vector3 Grid(float x, float z) => ctx.Centre + turn * new Vector3(x * s, 0f, z * s);
+
+ // 1. Dirt tracks painted into the ground: the main track (grid north-south) and the cross track, clipped to the hex.
+ ctx.PaintStroke("dirt", Grid(0f, -0.95f), Grid(0f, 0.95f), 0.045f * s, 0.9f);
+ ctx.PaintStroke("dirt", Grid(-0.95f, 0f), Grid(0.95f, 0f), 0.04f * s, 0.9f);
+
+ // 2. Grove blocks: tilled soil painted under each, then the trees in straight rows (no position jitter, so rows
+ // read). (x0, z0) is the first tree, cols x rows trees at the row spacing; trees in the unit spot are left out.
+ Grove(ctx, Grid, gridYaw, row, -0.44f, 0.18f, 3, 3); // north-west, 9
+ Grove(ctx, Grid, gridYaw, row, 0.18f, 0.18f, 3, 2); // north-east, 6
+ Grove(ctx, Grid, gridYaw, row, -0.44f, -0.33f, 3, 2); // south-west, 6
+
+ // 3. Cypress windbreaks: tight rows along the north edge of the north-west block and the west edge of the
+ // south-west block.
+ for (int k = 0; k < 3; k++)
+ {
+ ctx.PlaceByHeight(Cypress, Grid(-0.41f + 0.1f * k, 0.56f), ctx.Range(0f, 360f), ctx.Range(0.17f, 0.19f) * s, StandIn.Pine, CypressLeaf, 0.3f);
+ ctx.PlaceByHeight(Cypress, Grid(-0.57f, -0.365f + 0.1f * k), ctx.Range(0f, 360f), ctx.Range(0.17f, 0.19f) * s, StandIn.Pine, CypressLeaf, 0.3f);
+ }
+
+ // 4. The packing house on its painted yard, beside the main track in the south-east quarter and south of the
+ // unit spot, and the truck beside it.
+ ctx.PaintGround("dirt", Grid(0.12f, -0.44f), gridYaw, 0.17f * s, 0.36f * s, 0.2f, 0.8f);
+ ctx.PlaceByWidth(House, Grid(0.11f, -0.36f), gridYaw + 180f * ctx.Rng.Next(2), 0.14f * s, StandIn.Box, Plaster);
+ ctx.PlaceByWidth(Truck, Grid(0.115f, -0.54f), gridYaw, 0.14f * s, StandIn.Box, Lorry);
+
+ // 5. The square irrigation pool, on the grass east of the yard.
+ ctx.PlaceFlat(Grid(0.38f, -0.40f), gridYaw, 0.12f * s, 0.12f * s, Water);
+ }
+
+ static void Grove(HexTileContext ctx, System.Func<float, float, Vector3> grid, float gridYaw, float row,
+ float x0, float z0, int cols, int rows)
+ {
+ float w = (cols - 1) * row + 0.10f, d = (rows - 1) * row + 0.10f;
+ ctx.PaintGround("ploughed", grid(x0 + (cols - 1) * row * 0.5f, z0 + (rows - 1) * row * 0.5f), gridYaw, w * ctx.S, d * ctx.S, 0.2f, 0.7f);
+ for (int i = 0; i < cols; i++)
+ for (int j = 0; j < rows; j++)
+ {
+ var at = grid(x0 + i * row, z0 + j * row);
+ float yaw = ctx.Range(0f, 360f), height = ctx.Range(0.12f, 0.15f) * ctx.S; // drawn even when skipped, so the sequence holds
+ if (ctx.InUnitSpot(at, 0.04f * ctx.S)) continue;
+ ctx.PlaceByHeight(Citrus, at, yaw, height, StandIn.Tree, Leaf, 0.6f);
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/CitrusOrchard.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CitrusOrchard.cs.meta
new file mode 100644
index 000000000..27195907d
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CitrusOrchard.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: f6ca1b8ffacc94b6f9ce839b54750a48
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/CoastalDunes.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CoastalDunes.cs
new file mode 100644
index 000000000..f68b58f4c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CoastalDunes.cs
@@ -0,0 +1,97 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>The coastal sand dunes north of Tel Aviv, 1948. Large drifting dunes are drawn as pale and warm sand flats
+ /// of varied size and heading that never overlap. Low retama-like white-broom scrub is scattered over them, with one
+ /// small clump of date palms. If the hex touches the sea, a fishing boat is pulled up on the dry sand just short of the
+ /// water. The tile is light, so a whole coast can wear it.
+ ///
+ /// Triangle estimate, at the maximum counts, with measured per-model counts: fishing boat x 13,437 (only on a hex that
+ /// touches water, so the FlatSurface test never places it). 4 date palms x 284 = 1,136. 16 scrub stand-ins x about 46 =
+ /// 740. 12 flats x 12 = 144. Total about 15,500 of 20,000 with the boat.
+ ///
+ /// The scrub has no model (tiles:coastal_dunes/scrub), so it draws the Tree stand-in tinted pale sage.</summary>
+ [HexPrototype("coastal_dunes")]
+ public sealed class CoastalDunes : IHexPrototype
+ {
+ public string Title => "Coastal dunes (1948)";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "beach";
+ public int TriangleBudget => HexScale.BudgetFields;
+
+ const string Boat = "proto:vehicle-fishing-boat-1948-v2", Scrub = "tiles:coastal_dunes/scrub", Palm = "sandbox:date_palm";
+ // One clearly lighter and one warmer, darker sand, so the dunes read against the beach ground from far away.
+ static readonly Color[] Sand = { new Color(0.98f, 0.95f, 0.86f), new Color(0.82f, 0.70f, 0.50f), new Color(0.95f, 0.90f, 0.78f) };
+ static readonly Color Sage = new Color(0.66f, 0.70f, 0.56f), Hull = new Color(0.45f, 0.33f, 0.22f);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ // Pieces already down, as circles (centre, radius in metres), so the dunes never overlap each other or the boat.
+ var taken = new List<(Vector3 at, float r)>();
+ bool Free(Vector3 at, float r) { foreach (var t in taken) if (Vector2.Distance(new Vector2(at.x, at.z), new Vector2(t.at.x, t.at.z)) < r + t.r) return false; return true; }
+
+ // 1. The boat, first: step out along each bearing until the sea shows about 0.1 S ahead, then try that spot and
+ // up to two steps back. The first success ends the search; no water near, no boat.
+ float start = ctx.Range(0f, 360f);
+ bool boat = false;
+ var boatAt = Vector3.zero;
+ bool OffBoat(Vector3 at, float r) => !boat || Vector2.Distance(new Vector2(at.x, at.z), new Vector2(boatAt.x, boatAt.z)) >= r + 0.11f * s;
+ for (int i = 0; i < 24 && !boat; i++)
+ {
+ float b = start + 15f * i;
+ for (float r = 0.30f; r <= 0.80f; r += 0.03f)
+ {
+ if (!ctx.IsWater(ctx.At(b, r + 0.10f))) continue;
+ for (int back = 0; back < 3 && !boat; back++)
+ {
+ var at = ctx.At(b, r - 0.03f * back);
+ if (ctx.PlaceByWidth(Boat, at, b + ctx.Range(-15f, 15f), 0.14f * s, StandIn.Box, Hull))
+ {
+ taken.Add((at, 0.11f * s));
+ boatAt = at;
+ boat = true;
+ }
+ }
+ break;
+ }
+ }
+
+ // 2. Dunes: large sand flats, longer than wide, at random headings, placed only where they overlap nothing.
+ int dunes = 0;
+ for (int k = 0; k < 70 && dunes < 12; k++)
+ {
+ float w = ctx.Range(0.16f, 0.30f) * s, d = w * ctx.Range(0.45f, 0.7f), yaw = ctx.Range(0f, 180f);
+ var at = ctx.RandomPoint(0.04f * s);
+ // Dunes are ground, not objects: soft blobs of pale sand painted into the beach, a few greener hollows.
+ string layer = ctx.Rng.Next(Sand.Length) == 1 ? "plains" : "desert";
+ float r = 0.5f * Mathf.Sqrt(w * w + d * d);
+ if (!Free(at, r)) continue;
+ ctx.PaintGround(layer, at, yaw, w, d, 0.45f, layer == "plains" ? 0.55f : 0.85f);
+ taken.Add((at, r)); dunes++;
+ }
+
+ // 3. A small clump of date palms, kept off the boat.
+ var grove = ctx.At(ctx.Range(0f, 360f), ctx.Range(0.2f, 0.45f));
+ int palms = 0;
+ for (int k = 0; k < 12 && palms < 4; k++)
+ {
+ var at = grove + new Vector3(ctx.Range(-0.08f, 0.08f) * s, 0f, ctx.Range(-0.08f, 0.08f) * s);
+ if (!OffBoat(at, 0.03f * s)) continue;
+ if (ctx.PlaceByHeight(Palm, at, ctx.Range(0f, 360f), ctx.Range(0.12f, 0.15f) * s, StandIn.Palm, null, 0.3f)) palms++;
+ }
+
+ // 4. Scrub: low, wide white-broom bushes scattered over the sand and the dunes, kept off the boat.
+ int scrub = 0;
+ for (int k = 0; k < 60 && scrub < 16; k++)
+ {
+ var at = ctx.RandomPoint(0.03f * s);
+ if (!OffBoat(at, 0.04f * s)) continue;
+ if (ctx.PlaceByHeight(Scrub, at, ctx.Range(0f, 360f), ctx.Range(0.06f, 0.09f) * s, StandIn.Tree, Sage, 1.0f)) scrub++;
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/CoastalDunes.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CoastalDunes.cs.meta
new file mode 100644
index 000000000..22ed755dd
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/CoastalDunes.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 813bdeda77e9f4ed8ae793575b19cd20
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/DesertEdge.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/DesertEdge.cs
new file mode 100644
index 000000000..b36a9da99
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/DesertEdge.cs
@@ -0,0 +1,143 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>The desert edge, 1948: the Judean desert east of Jerusalem, or the northern Negev loess. Bare tan slopes
+ /// (the desert layer, painted to the rim so neighbouring ground does not soften it) are streaked with paler wind-blown
+ /// sand. A dry wadi meanders across the dome's flank, painted as dirt with a pale gravel bed, with a few acacias along
+ /// its banks. Desert rocks are scattered, two of them large. A Bedouin camp of three long, low, dark goat-hair tents
+ /// sits on the far flank. There are no people or animals, few pieces, and the unit spot stays open.
+ ///
+ /// Each tent is two or three dark Box stand-ins in a row along its heading (tiles:desert_edge/tent has no model), because
+ /// the Box stand-in is fixed at 0.65 of its width tall. A row reads long and low; boxes sit just apart, so their tops
+ /// never overlap.
+ ///
+ /// Triangle budget by arithmetic (caps below, with measured per-model counts): 6 acacias x ~1,160 = 6,960. 9 rocks x
+ /// ~700 = 6,300. 9 tent boxes x under 50 = under 450. Total under 13,800 of 25,000.</summary>
+ [HexPrototype("desert_edge")]
+ public sealed class DesertEdge : IHexPrototype
+ {
+ public string Title => "Desert edge: wadi, acacias, Bedouin tents (1948)";
+ public HexTerrain Terrain => HexTerrain.Hills;
+ public string Ground => "desert";
+ public int TriangleBudget => 25000;
+
+ // Models: EZ-Tree trees and Poly Haven rocks are local-only for now; the stand-ins draw without them.
+ const string Acacia = "sandbox:acacia_lite", Rock = "sandbox:desert_rock*", Tent = "tiles:desert_edge/tent";
+ // Caps that keep the tile inside its budget whatever the models' exact counts.
+ const int MaxAcacias = 6, MaxBigRocks = 2, MaxRocks = 9, MaxTents = 3;
+
+ static readonly Color AcaciaGreen = new Color(0.48f, 0.50f, 0.30f), RockTan = new Color(0.70f, 0.58f, 0.44f),
+ TentBlack = new Color(0.17f, 0.14f, 0.12f);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+
+ // 1. Bare tan slopes: the desert layer over the whole hex, soft at the rim; then paler sand streaks, long and thin,
+ // all lying roughly along one wind.
+ ctx.PaintGround("desert", ctx.Centre, 0f, 1.75f * s, 2.0f * s, 0.2f, 0.7f);
+ float wind = ctx.Range(0f, 180f);
+ for (int k = 0; k < 5; k++)
+ {
+ var at = ctx.RandomPoint(0.08f * s);
+ ctx.PaintGround("beach", at, wind + ctx.Range(-10f, 10f), ctx.Range(0.30f, 0.50f) * s, ctx.Range(0.05f, 0.08f) * s, 0.5f, 0.65f);
+ }
+
+ // 2. The wadi: a meandering line across the flank, about 0.4 S off the centre (so it keeps clear of the unit
+ // spot), painted as dirt banks with a narrower pale gravel bed.
+ float side = ctx.Range(0f, 360f), offset = ctx.Range(0.38f, 0.45f) * s;
+ float amp = ctx.Range(0.04f, 0.06f) * s, phase = ctx.Range(0f, 6.283f);
+ var normal = Flat(ctx.At(side, 1f) - ctx.Centre).normalized;
+ var along = new Vector3(normal.z, 0f, -normal.x);
+ var wadi = new List<Vector3>();
+ for (int k = 0; k <= 20; k++)
+ {
+ float t = -1f + k * 0.1f;
+ wadi.Add(ctx.Centre + normal * (offset + amp * Mathf.Sin(3.4f * t + phase)) + along * (t * s));
+ }
+ for (int k = 0; k < wadi.Count - 1; k++)
+ {
+ ctx.PaintStroke("dirt", wadi[k], wadi[k + 1], 0.06f * s, 0.85f);
+ ctx.PaintStroke("beach", wadi[k], wadi[k + 1], 0.022f * s, 0.7f);
+ }
+ bool NearWadi(Vector3 p, float within)
+ {
+ for (int k = 0; k < wadi.Count - 1; k++) if (DistToSegment(p, wadi[k], wadi[k + 1]) < within) return true;
+ return false;
+ }
+
+ // Pieces already down, as circles (centre, radius in metres), so later pieces keep off them.
+ var taken = new List<(Vector3 at, float r)>();
+ bool Free(Vector3 at, float r)
+ {
+ foreach (var t in taken) if (Flat(at - t.at).magnitude < r + t.r) return false;
+ return true;
+ }
+
+ // 3. The Bedouin camp on the far flank: up to three tents along the contour, staggered up and down the slope,
+ // each a row of two or three dark boxes along its heading.
+ float campBearing = side + 180f + ctx.Range(-35f, 35f);
+ var camp = ctx.At(campBearing, ctx.Range(0.52f, 0.58f));
+ var radial = Flat(camp - ctx.Centre).normalized;
+ var contour = new Vector3(radial.z, 0f, -radial.x);
+ float[] stagger = { 0f, 0.07f, -0.02f };
+ for (int j = 0; j < MaxTents; j++)
+ {
+ int boxes = 2 + ctx.Rng.Next(2);
+ float w = ctx.Range(0.045f, 0.055f) * s, turn = ctx.Range(-10f, 10f);
+ var centre = camp + contour * ((j - 1) * 0.21f * s) + radial * (stagger[j] * s);
+ var dir = Quaternion.Euler(0f, turn, 0f) * contour;
+ float yaw = Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg;
+ for (int b = 0; b < boxes; b++)
+ {
+ var at = centre + dir * ((b - 0.5f * (boxes - 1)) * 1.04f * w);
+ if (ctx.InUnitSpot(at, 0.75f * w) || NearWadi(at, 0.75f * w + 0.03f * s)) continue;
+ if (ctx.PlaceByWidth(Tent, at, yaw, w, StandIn.Box, TentBlack, maxSlopeDeg: 40f)) taken.Add((at, 0.75f * w));
+ }
+ }
+
+ // 4. Acacias along the wadi banks, alternating sides, a few only.
+ int acacias = 0;
+ for (int k = 2; k < wadi.Count - 1 && acacias < MaxAcacias; k += 3)
+ {
+ var dirK = Flat(wadi[k + 1] - wadi[k]).normalized;
+ var bank = new Vector3(dirK.z, 0f, -dirK.x) * ((k / 3) % 2 == 0 ? 1f : -1f);
+ var at = wadi[k] + bank * (ctx.Range(0.045f, 0.06f) * s);
+ float height = ctx.Range(0.10f, 0.12f) * s, yaw = ctx.Range(0f, 360f);
+ if (!ctx.Inside(at, 0.05f * s) || ctx.InUnitSpot(at, 0.05f * s) || !Free(at, 0.05f * s)) continue;
+ if (ctx.PlaceByHeight(Acacia, at, yaw, height, StandIn.Tree, AcaciaGreen, footprintShare: 0.8f, maxSlopeDeg: 40f))
+ {
+ taken.Add((at, 0.05f * s)); acacias++;
+ }
+ }
+
+ // 5. Desert rocks: two large ones out on the flanks, then small ones scattered, off the wadi, camp and unit spot.
+ int rocks = 0, big = 0;
+ for (int i = 0; i < 40 && rocks < MaxRocks; i++)
+ {
+ bool large = big < MaxBigRocks;
+ float w = (large ? ctx.Range(0.11f, 0.15f) : ctx.Range(0.04f, 0.07f)) * s, yaw = ctx.Range(0f, 360f);
+ var at = large ? ctx.At(ctx.Range(0f, 360f), ctx.Range(0.48f, 0.66f)) : ctx.RandomPoint(0.04f * s);
+ float r = 0.75f * w;
+ if (ctx.InUnitSpot(at, r) || NearWadi(at, r + 0.03f * s) || !Free(at, r + 0.03f * s)) continue;
+ if (ctx.PlaceByWidth(Rock, at, yaw, w, StandIn.Rock, RockTan, maxSlopeDeg: 45f))
+ {
+ taken.Add((at, r)); rocks++;
+ if (large) big++;
+ }
+ }
+ }
+
+ static Vector3 Flat(Vector3 v) => new Vector3(v.x, 0f, v.z);
+
+ static float DistToSegment(Vector3 p, Vector3 a, Vector3 b)
+ {
+ Vector3 ab = Flat(b - a), ap = Flat(p - a);
+ float t = Mathf.Clamp01(Vector3.Dot(ap, ab) / Mathf.Max(ab.sqrMagnitude, 1e-4f));
+ return (ap - ab * t).magnitude;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/DesertEdge.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/DesertEdge.cs.meta
new file mode 100644
index 000000000..2cc51dd62
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/DesertEdge.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: baeda1362e81f435187f55dd3160c005
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/JaffaOldCity.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JaffaOldCity.cs
new file mode 100644
index 000000000..b2f63c5ff
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JaffaOldCity.cs
@@ -0,0 +1,197 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>Old Jaffa, the hilltop port town (1948), drawn Civ-style as a city-centre hex.
+ /// - The tile first finds the sea side: the bearing on which water comes nearest. With no water it falls back to west.
+ /// - Ochre and limestone houses cluster tightly in three rings round a summit between the centre and the sea. St
+ /// Peter's church and its belfry crown the summit.
+ /// - The terrain is Flat, so the mound is drawn by size. Houses are widest, and so tallest, in the inner ring and
+ /// smaller in each ring below, so the town steps up toward the church.
+ /// - The first-batch stone-village cluster stands once on one flank of the hill.
+ /// - At the centre is the market (the clock-tower square). It is painted dirt and kept open for a unit, with the
+ /// Ottoman clock tower at its northern edge.
+ /// - Dirt lanes run up the hill, down to the harbour, inland and up the coast road, with date palms along the inland
+ /// road and painted gardens beyond.
+ /// - Where the sea is near, the small harbour has up to two fishing boats on the shore, a stone quay and the Sea
+ /// Mosque's minaret.
+ ///
+ /// Triangle estimate, at the maximum counts:
+ /// - At most 20 houses (sandbox:kit_jaffa*, up to 1,400 each; kit_jaffa shares kit_jerusalem_4's mesh) = 28,000.
+ /// - stone-village-v1 once = 8,642.
+ /// - At most 2 fishing boats x 13,437 = 26,874. They appear only on a hex that touches water, so the FlatSurface test
+ /// never places them.
+ /// - At most 8 date palms x 284 = 2,272.
+ /// - Church Box, and belfry, clock tower and minaret Pine stand-ins: about 160. Quay flat: 12.
+ /// - Total about 66,000 of 70,000 with the harbour, about 39,100 without it.
+ ///
+ /// The clock tower, church, belfry and minaret have no models (tiles:jaffa_old_city/...), so they always draw stand-ins.</summary>
+ [HexPrototype("jaffa_old_city")]
+ public sealed class JaffaOldCity : IHexPrototype
+ {
+ public string Title => "Jaffa, the old port town (1948)";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "plains";
+ public int TriangleBudget => 70000;
+
+ const string House = "sandbox:kit_jaffa*", Cluster = "proto:stone-village-v1", Boat = "proto:vehicle-fishing-boat-1948-v2",
+ Palm = "sandbox:date_palm", ClockTower = "tiles:jaffa_old_city/clock_tower", Church = "tiles:jaffa_old_city/st_peter",
+ Belfry = "tiles:jaffa_old_city/belfry", Minaret = "tiles:jaffa_old_city/sea_minaret";
+
+ static readonly Color Ochre = new Color(0.84f, 0.68f, 0.46f), Stone = new Color(0.86f, 0.80f, 0.68f),
+ TowerStone = new Color(0.80f, 0.73f, 0.58f), Quay = new Color(0.70f, 0.65f, 0.55f), Hull = new Color(0.45f, 0.33f, 0.22f);
+
+ const int MaxHouses = 20, MaxBoats = 2, MaxPalms = 8;
+ const float LaneHalf = 0.025f;
+ /// <summary>The coast road leaves the summit this many degrees off the bearing to the sea.</summary>
+ const float CoastTurnDeg = 100;
+
+ /// <summary>The house rings about the summit: radius, slots, and footprint width range (shares of S). Each ring is
+ /// smaller than the one inside it, so the town reads as a mound.</summary>
+ static readonly (float r, int n, float wMin, float wMax)[] Rings =
+ {
+ (0.15f, 5, 0.13f, 0.14f), (0.28f, 10, 0.12f, 0.13f), (0.40f, 14, 0.105f, 0.115f),
+ };
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ var taken = new List<(Vector3 at, float r)>();
+ var lanes = new List<(Vector3 a, Vector3 b)>();
+ bool Free(Vector3 at, float r)
+ {
+ foreach (var t in taken) if (Planar(at - t.at) < r + t.r) return false;
+ return true;
+ }
+ bool OffLanes(Vector3 at, float r)
+ {
+ foreach (var l in lanes) if (SegmentDistance(at, l.a, l.b) < r + LaneHalf * s) return false;
+ return true;
+ }
+ void Lane(Vector3 a, Vector3 b) { lanes.Add((a, b)); ctx.PaintStroke("dirt", a, b, 2f * LaneHalf * s, 0.9f); }
+ bool NearerNorth(float a, float b) => Mathf.Abs(Mathf.DeltaAngle(a, 0f)) <= Mathf.Abs(Mathf.DeltaAngle(b, 0f));
+
+ // 1. The sea side: the bearing on which water comes nearest the centre. With no water, west.
+ float seaB = 270f, shoreR = 1f;
+ bool sea = false;
+ for (int i = 0; i < 24; i++)
+ {
+ float b = 15f * i;
+ for (float r = 0.30f; r < shoreR && r <= 0.90f; r += 0.03f)
+ if (ctx.IsWater(ctx.At(b, r))) { seaB = b; shoreR = r; sea = true; break; }
+ }
+
+ // 2. The market at the centre: the clock-tower square, painted dirt and kept open for a unit. The clock tower
+ // stands at the square's inland corner nearer north, so it does not hide a unit from the camera.
+ taken.Add((ctx.Centre, 0.15f * s));
+ ctx.PaintGround("dirt", ctx.Centre, seaB, 0.30f * s, 0.30f * s, 0.2f, 0.95f);
+ float clockB = NearerNorth(seaB + 130f, seaB - 130f) ? seaB + 130f : seaB - 130f;
+ var clock = ctx.At(clockB, 0.19f);
+ ctx.PlaceByHeight(ClockTower, clock, clockB + 180f, 0.20f * s, StandIn.Pine, TowerStone, footprintShare: 0.2f);
+ taken.Add((clock, 0.05f * s));
+
+ // 3. The harbour. On a few bearings either side of the sea direction, step out until water shows just ahead,
+ // then try that spot and up to two steps back for a fishing boat on the shore. Boats are kept apart. Behind
+ // the first boat go a stone quay, the lane down from the market, and the Sea Mosque's minaret.
+ int boats = 0;
+ if (sea)
+ foreach (float d in new[] { 30f, -30f, 50f, -50f, 15f, -15f, 0f })
+ {
+ if (boats >= MaxBoats) break;
+ float b = seaB + d;
+ for (float r = 0.30f; r <= 0.85f; r += 0.03f)
+ {
+ if (!ctx.IsWater(ctx.At(b, r + 0.09f))) continue;
+ for (int back = 0; back < 3; back++)
+ {
+ float rr = r - 0.03f * back;
+ var at = ctx.At(b, rr);
+ if (!Free(at, 0.07f * s)) break;
+ if (!ctx.PlaceByWidth(Boat, at, b + ctx.Range(-15f, 15f), 0.13f * s, StandIn.Box, Hull)) continue;
+ if (boats == 0)
+ {
+ var quay = ctx.At(b, rr - 0.10f);
+ if (ctx.PlaceFlat(quay, b, 0.20f * s, 0.05f * s, Quay)) taken.Add((quay, 0.10f * s));
+ Lane(ctx.Centre, quay);
+ var minaret = ctx.At(b - 25f, rr - 0.13f);
+ if (Free(minaret, 0.03f * s) && ctx.PlaceByHeight(Minaret, minaret, 0f, 0.13f * s, StandIn.Pine, TowerStone, footprintShare: 0.2f))
+ taken.Add((minaret, 0.04f * s));
+ }
+ taken.Add((at, 0.08f * s));
+ boats++;
+ break;
+ }
+ break;
+ }
+ }
+
+ // 4. The summit, between the market and the sea, carrying St Peter's church and its belfry. Lanes run up to it,
+ // inland, and along the coast road (on the side nearer north).
+ float topR = sea ? Mathf.Clamp(shoreR - 0.26f, 0.30f, 0.40f) : 0.36f;
+ var top = ctx.At(seaB, topR);
+ ctx.PlaceByWidth(Church, top, seaB + 180f, 0.15f * s, StandIn.Box, Stone);
+ ctx.PlaceByHeight(Belfry, top + Dir(seaB + 90f) * (0.06f * s), 0f, 0.17f * s, StandIn.Pine, TowerStone, footprintShare: 0.2f);
+ taken.Add((top, 0.065f * s));
+ float coastB = NearerNorth(seaB + CoastTurnDeg, seaB - CoastTurnDeg) ? seaB + CoastTurnDeg : seaB - CoastTurnDeg;
+ Lane(ctx.Centre, top);
+ Lane(ctx.Centre, ctx.At(seaB + 180f, 0.90f));
+ Lane(ctx.Centre, ctx.At(coastB, 0.90f));
+
+ // 5. The stone-village cluster, once, on the flank of the hill away from the coast road.
+ float clusterB = coastB == seaB + CoastTurnDeg ? seaB - 90f : seaB + 90f;
+ var clusterAt = top + Dir(clusterB) * (0.30f * s);
+ if (OffLanes(clusterAt, 0.08f * s) && ctx.PlaceByWidth(Cluster, clusterAt, clusterB + 180f, 0.16f * s, StandIn.Box, Stone))
+ taken.Add((clusterAt, 0.08f * s));
+
+ // 6. Houses in three rings about the summit, each turned to face it. Each ring is filled from the inland side
+ // outward in both directions (slot order 0, -1, 1, -2, 2 ...), so the cap trims the seaward end evenly.
+ // Slots on a lane, in the market or on any piece already placed are skipped.
+ int houses = 0;
+ foreach (var ring in Rings)
+ for (int k = 0; k < ring.n; k++)
+ {
+ int m = (k + 1) / 2 * (k % 2 == 0 ? 1 : -1);
+ float b = seaB + 180f + m * (360f / ring.n) + ctx.Range(-5f, 5f);
+ var at = top + Dir(b) * ((ring.r + ctx.Range(-0.01f, 0.01f)) * s);
+ float w = ctx.Range(ring.wMin, ring.wMax) * s, yaw = b + 180f + ctx.Range(-10f, 10f);
+ var tint = ctx.Rng.Next(3) == 0 ? Stone : Ochre;
+ if (houses >= MaxHouses || !Free(at, 0.5f * w) || !OffLanes(at, 0.5f * w)) continue;
+ if (ctx.PlaceByWidth(House, at, yaw, w, StandIn.Box, tint)) houses++;
+ }
+
+ // 7. Date palms: two at the market's inland corners, then pairs along the inland road.
+ int palms = 0;
+ var palmSpots = new List<Vector3> { ctx.At(seaB + 155f, 0.22f), ctx.At(seaB + 205f, 0.22f) };
+ foreach (float r in new[] { 0.42f, 0.58f, 0.74f })
+ foreach (float side in new[] { -90f, 90f })
+ palmSpots.Add(ctx.At(seaB + 180f, r) + Dir(seaB + 180f + side) * (0.055f * s));
+ foreach (var at in palmSpots)
+ {
+ if (palms >= MaxPalms || !Free(at, 0.02f * s)) continue;
+ if (ctx.PlaceByHeight(Palm, at, ctx.Range(0f, 360f), ctx.Range(0.11f, 0.13f) * s, StandIn.Palm, null, 0.3f)) palms++;
+ }
+
+ // 8. The gardens and orchards inland of the town, painted into the plains on either side of the inland road.
+ foreach (float side in new[] { -55f, 55f })
+ ctx.PaintGround("green_crop", ctx.At(seaB + 180f + side, 0.60f), seaB + 180f + side, 0.22f * s, 0.15f * s, 0.3f, 0.6f);
+ }
+
+ static Vector3 Dir(float bearingDeg)
+ {
+ float a = bearingDeg * Mathf.Deg2Rad;
+ return new Vector3(Mathf.Sin(a), 0f, Mathf.Cos(a));
+ }
+
+ static float Planar(Vector3 v) => new Vector2(v.x, v.z).magnitude;
+
+ /// <summary>Distance from p to the segment a-b, in the ground plane.</summary>
+ static float SegmentDistance(Vector3 p, Vector3 a, Vector3 b)
+ {
+ Vector2 q = new Vector2(p.x, p.z), u = new Vector2(a.x, a.z), ab = new Vector2(b.x - a.x, b.z - a.z);
+ float t = Mathf.Clamp01(Vector2.Dot(q - u, ab) / Mathf.Max(ab.sqrMagnitude, 1e-4f));
+ return (q - (u + ab * t)).magnitude;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/JaffaOldCity.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JaffaOldCity.cs.meta
new file mode 100644
index 000000000..bb7d6d0f3
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JaffaOldCity.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: a830138da40aa4ca5a8ae35549a88f75
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/JerusalemOldCity.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JerusalemOldCity.cs
new file mode 100644
index 000000000..087cb8c59
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JerusalemOldCity.cs
@@ -0,0 +1,159 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>Jerusalem's walled Old City on its hill (1948), drawn Civ-style as a city-centre hex.
+ /// - The wall is a square-ish crenellated ring, half-side 0.5 S, turned a few degrees. It is built from many short
+ /// stand-in blocks of two alternating sizes, with larger towers at the corners and beside four gates.
+ /// - The gates sit on the axes: Damascus (north), Lions' (east), Dung (south) and Jaffa (west). Four streets painted
+ /// as dirt cross the town from them to a small paved plaza at the centre, 0.25 S across and kept open for a unit.
+ /// - North of the plaza, 0.3 S out, stands the first-batch Jerusalem stone-city cluster. Its covered mass stands for
+ /// the souk on the Damascus Gate street.
+ /// - To the south-east is the Haram al-Sharif: a raised paved esplanade carrying the Dome of the Rock and the
+ /// al-Aqsa block. The Dome is two crossed blocks in blue faience (an octagonal drum) under a gold dome.
+ /// - Stone houses fill every other lot inside the walls, on a tight grid. About one lot in seven is a garden
+ /// courtyard with a cypress or an olive.
+ /// - The ground inside the walls is painted dirt at half strength. Outside, the bare hill carries olives on the
+ /// Mount of Olives (east) and in the valleys (south), and cypresses to the north and west.
+ ///
+ /// Triangle estimate, at the maximum counts (FlatSurface refuses nothing):
+ /// - At most 30 houses (sandbox:kit_jerusalem*, up to 1,400 each) = 42,000.
+ /// - At most 6 courtyard trees, 2 on the esplanade and 11 outside, so 19 x 1,602 = 30,438.
+ /// - The jerusalem-stone-city-v1 cluster: about 6,000 (the 6,000-triangle Tripo export; unmeasured here).
+ /// - Wall blocks, gate towers and corner towers: 84 Box stand-ins x 12 = 1,008.
+ /// - Dome drum, al-Aqsa block and gold dome: about 90. Plaza and esplanade flats: 24.
+ /// - Total about 79,600 of 90,000 (about 83,600 even if the cluster were the 10,000-triangle export).
+ ///
+ /// The wall, towers, drum, dome and al-Aqsa have no models (tiles:jerusalem_old_city/...), so they always draw stand-ins.
+ /// The gold dome is a Tree stand-in whose crown rises out of the drum.</summary>
+ [HexPrototype("jerusalem_old_city")]
+ public sealed class JerusalemOldCity : IHexPrototype
+ {
+ public string Title => "Jerusalem, the walled Old City (1948)";
+ public HexTerrain Terrain => HexTerrain.Hills;
+ public string Ground => "hills";
+ public int TriangleBudget => 90000;
+
+ const string Cluster = "proto:jerusalem-stone-city-v1", House = "sandbox:kit_jerusalem*", Cypress = "sandbox:cypress_lite",
+ Olive = "sandbox:olive_lite", Wall = "tiles:jerusalem_old_city/wall", Tower = "tiles:jerusalem_old_city/tower",
+ Drum = "tiles:jerusalem_old_city/dome_drum", Dome = "tiles:jerusalem_old_city/golden_dome", Aqsa = "tiles:jerusalem_old_city/aqsa";
+
+ static readonly Color Limestone = new Color(0.86f, 0.80f, 0.68f), WallStone = new Color(0.83f, 0.76f, 0.62f),
+ TowerStone = new Color(0.77f, 0.70f, 0.56f), Paving = new Color(0.80f, 0.75f, 0.63f), Esplanade = new Color(0.87f, 0.83f, 0.72f),
+ Faience = new Color(0.30f, 0.47f, 0.62f), Gold = new Color(0.90f, 0.71f, 0.22f),
+ OliveLeaf = new Color(0.42f, 0.50f, 0.34f), CypressLeaf = new Color(0.18f, 0.30f, 0.16f);
+
+ /// <summary>The wall's half-side, as a share of S. At 0.5 the corner towers pass the inset-hexagon test at any of the
+ /// small turns the wall takes, so no segment is refused and no accidental gap opens.</summary>
+ const float Half = 0.5f, Slope = 40f;
+ const int MaxHouses = 30, MaxYards = 6;
+
+ /// <summary>House lot centres on each axis, as shares of S. The wider gap about 0 leaves the cross streets open.</summary>
+ static readonly float[] Lots = { -0.415f, -0.305f, -0.195f, -0.085f, 0.085f, 0.195f, 0.305f, 0.415f };
+
+ /// <summary>Where houses may not go, in the wall's frame (centre and half-sizes, shares of S): the plaza, the cluster
+ /// and the esplanade.</summary>
+ static readonly (float x, float z, float hx, float hz)[] KeepOut =
+ {
+ (0f, 0f, 0.125f, 0.125f), (0f, 0.30f, 0.15f, 0.15f), (0.30f, -0.20f, 0.13f, 0.15f),
+ };
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S, yaw = ctx.Range(-8f, 8f);
+ var rot = Quaternion.Euler(0f, yaw, 0f);
+ // A point in the wall's frame: x along the north and south walls (east), z along the east and west walls (north),
+ // both shares of S.
+ Vector3 P(float x, float z) => ctx.Centre + rot * new Vector3(x * s, 0f, z * s);
+ bool Free(float x, float z, float half)
+ {
+ foreach (var k in KeepOut) if (Mathf.Abs(x - k.x) < half + k.hx && Mathf.Abs(z - k.z) < half + k.hz) return false;
+ return true;
+ }
+
+ // 1. Ground. Inside the walls it is beaten earth: dirt at half strength over the hill rock, kept just inside the
+ // wall. Ploughed olive terraces lie on the Mount of Olives to the east. The four streets cross the town and
+ // run on out through the gates.
+ ctx.PaintGround("dirt", ctx.Centre, yaw, 0.92f * s, 0.92f * s, 0.04f, 0.5f);
+ ctx.PaintGround("ploughed", P(0.66f, 0f), yaw, 0.16f * s, 0.80f * s, 0.3f, 0.45f);
+ ctx.PaintStroke("dirt", P(0f, 0.125f), P(0f, 0.85f), 0.06f * s, 0.9f);
+ ctx.PaintStroke("dirt", P(0.125f, 0f), P(0.85f, 0f), 0.06f * s, 0.9f);
+ ctx.PaintStroke("dirt", P(0f, -0.125f), P(0f, -0.85f), 0.06f * s, 0.9f);
+ ctx.PaintStroke("dirt", P(-0.125f, 0f), P(-0.85f, 0f), 0.06f * s, 0.9f);
+
+ // 2. The wall: on each side, short blocks 0.04 S apart, alternately 0.045 and 0.034 S. The sizes alternate so
+ // neighbouring blocks never share a face plane, and the skyline reads as crenellation. A gap is left at each
+ // gate, flanked by two gate towers, and a larger tower stands at each corner.
+ var sides = new (bool alongX, float at, float gate)[] { (true, Half, 0f), (false, Half, 0f), (true, -Half, 0f), (false, -Half, 0f) };
+ foreach (var side in sides)
+ {
+ Vector3 OnSide(float t) => side.alongX ? P(t, side.at) : P(side.at, t);
+ for (int i = 0; i <= 21; i++)
+ {
+ float t = -0.42f + 0.04f * i;
+ if (Mathf.Abs(t - side.gate) < 0.09f) continue;
+ ctx.PlaceByWidth(Wall, OnSide(t), yaw, (i % 2 == 0 ? 0.045f : 0.034f) * s, StandIn.Box, WallStone, Slope);
+ }
+ foreach (float d in new[] { -0.065f, 0.065f })
+ ctx.PlaceByWidth(Tower, OnSide(side.gate + d), yaw, 0.055f * s, StandIn.Box, TowerStone, Slope);
+ }
+ foreach (float cx in new[] { -Half, Half })
+ foreach (float cz in new[] { -Half, Half })
+ ctx.PlaceByWidth(Tower, P(cx, cz), yaw, 0.075f * s, StandIn.Box, TowerStone, Slope);
+
+ // 3. The open plaza at the centre, for a unit. North of it, 0.3 S out, the stone-city cluster faces south, toward
+ // the plaza and the camera.
+ ctx.PlaceFlat(ctx.Centre, yaw, 0.25f * s, 0.25f * s, Paving, 150f);
+ ctx.PlaceByWidth(Cluster, P(0f, 0.30f), yaw + 180f, 0.30f * s, StandIn.Box, Limestone, Slope);
+
+ // 4. The Haram al-Sharif, to the south-east. Its raised esplanade is a genuine paved platform, so a flat. On it:
+ // - the Dome of the Rock: two blocks at yaw 0 and 45 (0.09 and 0.08 S, so their tops never share a plane) form a stepped octagonal faience drum, and a gold Tree stand-in at
+ // the same spot rises out of it as the dome;
+ // - al-Aqsa at the south end;
+ // - two cypresses.
+ ctx.PlaceFlat(P(0.30f, -0.20f), yaw, 0.26f * s, 0.30f * s, Esplanade, 400f);
+ var dome = P(0.28f, -0.15f);
+ ctx.PlaceByWidth(Drum, dome, yaw, 0.09f * s, StandIn.Box, Faience, Slope);
+ ctx.PlaceByWidth(Drum, dome, yaw + 45f, 0.08f * s, StandIn.Box, Faience, Slope);
+ ctx.PlaceByHeight(Dome, dome, yaw, 0.13f * s, StandIn.Tree, Gold, footprintShare: 0.7f, maxSlopeDeg: Slope);
+ ctx.PlaceByWidth(Aqsa, P(0.30f, -0.30f), yaw + 180f, 0.07f * s, StandIn.Box, TowerStone, Slope);
+ ctx.PlaceByHeight(Cypress, P(0.40f, -0.08f), ctx.Range(0f, 360f), 0.12f * s, StandIn.Pine, CypressLeaf, footprintShare: 0.3f, maxSlopeDeg: Slope);
+ ctx.PlaceByHeight(Cypress, P(0.20f, -0.32f), ctx.Range(0f, 360f), 0.13f * s, StandIn.Pine, CypressLeaf, footprintShare: 0.3f, maxSlopeDeg: Slope);
+
+ // 5. Houses on a tight, lightly jittered grid of lots, 0.11 S apart. Lots in the plaza, under the cluster or on
+ // the esplanade are skipped. About one lot in seven becomes a garden courtyard with a cypress or an olive.
+ int houses = 0, yards = 0;
+ foreach (float lx in Lots)
+ foreach (float lz in Lots)
+ {
+ float x = lx + ctx.Range(-0.006f, 0.006f), z = lz + ctx.Range(-0.006f, 0.006f), w = ctx.Range(0.10f, 0.108f);
+ int roll = ctx.Rng.Next(100), turn = ctx.Rng.Next(4);
+ if (!Free(x, z, 0.5f * w)) continue;
+ var at = P(x, z);
+ if (roll < 15 && yards < MaxYards)
+ {
+ ctx.PaintGround("grass", at, yaw, 0.09f * s, 0.09f * s, 0.3f, 0.55f);
+ bool placed = roll % 2 == 0
+ ? ctx.PlaceByHeight(Cypress, at, ctx.Range(0f, 360f), ctx.Range(0.13f, 0.15f) * s, StandIn.Pine, CypressLeaf, footprintShare: 0.3f, maxSlopeDeg: Slope)
+ : ctx.PlaceByHeight(Olive, at, ctx.Range(0f, 360f), ctx.Range(0.11f, 0.12f) * s, StandIn.Tree, OliveLeaf, footprintShare: 0.5f, maxSlopeDeg: Slope);
+ if (placed) yards++;
+ continue;
+ }
+ if (houses < MaxHouses && ctx.PlaceByWidth(House, at, yaw + 90f * turn + ctx.Range(-3f, 3f), w * s, StandIn.Box, Limestone, Slope)) houses++;
+ }
+
+ // 6. Outside the walls, kept off the four roads:
+ // - olives on the Mount of Olives (east) and in the valleys (south);
+ // - cypresses to the north and west.
+ foreach (float z in new[] { -0.36f, -0.18f, 0.18f, 0.36f })
+ ctx.PlaceByHeight(Olive, P(0.66f, z), ctx.Range(0f, 360f), ctx.Range(0.12f, 0.13f) * s, StandIn.Tree, OliveLeaf, footprintShare: 0.5f, maxSlopeDeg: Slope);
+ foreach (float x in new[] { -0.30f, -0.14f, 0.24f })
+ ctx.PlaceByHeight(Olive, P(x, -0.64f), ctx.Range(0f, 360f), ctx.Range(0.12f, 0.13f) * s, StandIn.Tree, OliveLeaf, footprintShare: 0.5f, maxSlopeDeg: Slope);
+ foreach (float x in new[] { -0.24f, 0.24f })
+ ctx.PlaceByHeight(Cypress, P(x, 0.64f), ctx.Range(0f, 360f), ctx.Range(0.14f, 0.16f) * s, StandIn.Pine, CypressLeaf, footprintShare: 0.3f, maxSlopeDeg: Slope);
+ foreach (float z in new[] { -0.24f, 0.24f })
+ ctx.PlaceByHeight(Cypress, P(-0.66f, z), ctx.Range(0f, 360f), ctx.Range(0.14f, 0.16f) * s, StandIn.Pine, CypressLeaf, footprintShare: 0.3f, maxSlopeDeg: Slope);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/JerusalemOldCity.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JerusalemOldCity.cs.meta
new file mode 100644
index 000000000..84b36a8d0
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JerusalemOldCity.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 23070f7ba24264ed0b6b57de1b0b50e8
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/JudeanHighlands.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JudeanHighlands.cs
new file mode 100644
index 000000000..ccb24f6b7
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JudeanHighlands.cs
@@ -0,0 +1,226 @@
+#nullable enable
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>The Judean and Samarian highlands, 1948: a smooth highland dome (no cliffs, so units cross it easily) that
+ /// reads as rugged mountain from far away. Three great pale limestone crags stand out at the hex corners, never at the
+ /// centre. Rocky scree aprons are painted round their feet and along the rim. Sparse olives grow on painted terraces on
+ /// the gentler (lowest) side. Garrigue scrub clumps, a few carobs and Aleppo pines are scattered between them. A goat
+ /// track winds across from one pass between crags to the next, through the clear unit spot.
+ ///
+ /// Layout, by corner (bearings 0, 60 ... 300; corner g is the lowest one, the gentle side): olives at g, crags at g+1,
+ /// g+3 and g+5 (sometimes g+5 is left out), and the track from corner g+2 to corner g+4. Crags sit with a flat face
+ /// towards the centre (yaw = bearing + k x 90), so by arithmetic the footprint clears the unit spot (inner face at
+ /// 0.31 S or more) and stays in the inset hexagon (0.866 d + 0.683 W at most 0.796 at a corner). That caps a crag at
+ /// about 0.48 S wide; a refused crag is retried 10% smaller, twice.
+ ///
+ /// Triangle budget by arithmetic (caps below, with measured per-model counts): 3 crags + 4 boulders x ~700 = 4,900.
+ /// 10 olives x ~1,600 = 16,000. 5 carobs x ~650 = 3,250. 3 pines x ~1,600 = 4,800. 24 garrigue stand-ins x under 100 =
+ /// under 2,400. Total under 31,400 of 40,000 (still under 36,000 if the limestone variants run twice as heavy).
+ ///
+ /// The garrigue has no model (tiles:judean_highlands/garrigue), so it draws the Tree stand-in tinted dusty green.</summary>
+ [HexPrototype("judean_highlands")]
+ public sealed class JudeanHighlands : IHexPrototype
+ {
+ public string Title => "Judean highlands: limestone crags, terraced olives (1948)";
+ public HexTerrain Terrain => HexTerrain.Mountain;
+ public string Ground => "mountain";
+ public int TriangleBudget => 40000;
+
+ // Models: EZ-Tree trees and Poly Haven rocks are local-only for now; the stand-ins draw without them.
+ const string Rock = "sandbox:limestone*", Olive = "sandbox:olive_lite", Carob = "sandbox:carob_lite",
+ Pine = "sandbox:aleppo_pine_lite", Garrigue = "tiles:judean_highlands/garrigue";
+ // Caps that keep the tile inside its budget whatever the models' exact counts.
+ const int MaxBoulders = 4, MaxOlives = 10, MaxCarobs = 5, MaxPines = 3, MaxGarrigue = 24;
+
+ static readonly Color Limestone = new Color(0.88f, 0.85f, 0.77f), OliveGreen = new Color(0.50f, 0.55f, 0.38f),
+ CarobGreen = new Color(0.27f, 0.39f, 0.20f), PineGreen = new Color(0.20f, 0.33f, 0.18f),
+ DustyGreen = new Color(0.52f, 0.56f, 0.40f);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ float Corner(int k) => 60f * (((k % 6) + 6) % 6);
+
+ // 1. The gentle side: the lowest corner at 0.7 S, scanned from a seeded start with a strict "<" so ties (a flat
+ // surface) resolve the same way every time.
+ int start = ctx.Rng.Next(6), g = start;
+ float lowest = float.MaxValue;
+ for (int i = 0; i < 6; i++)
+ {
+ int k = (start + i) % 6;
+ float y = ctx.GroundY(ctx.At(Corner(k), 0.7f));
+ if (y < lowest) { lowest = y; g = k; }
+ }
+ float gentle = Corner(g);
+
+ // 2. The crags: at corners g+3 (opposite the gentle side), g+1 and, two times in three, g+5. Width W, centre at
+ // 0.30 + W/2 + a little, a flat face to the centre. maxSlopeDeg 70 so the dome's flanks never refuse them.
+ var crags = new List<(Vector3 at, float yaw, float w)>();
+ var cragCorners = ctx.Rng.Next(3) == 0 ? new[] { g + 3, g + 1 } : new[] { g + 3, g + 1, g + 5 };
+ foreach (int k in cragCorners)
+ {
+ float bearing = Corner(k), w = ctx.Range(0.38f, 0.46f) * s, yaw = bearing + 90f * ctx.Rng.Next(4);
+ float slack = ctx.Range(0.01f, 0.03f) * s;
+ for (int attempt = 0; attempt < 3; attempt++, w *= 0.9f)
+ {
+ var at = ctx.At(bearing, (0.30f * s + 0.5f * w + slack) / s);
+ if (ctx.InUnitSpot(at, 0.5f * w)) continue;
+ if (ctx.PlaceByWidth(Rock, at, yaw, w, StandIn.Rock, Limestone, maxSlopeDeg: 70f)) { crags.Add((at, yaw, w)); break; }
+ }
+ }
+ bool InCrag(Vector3 p, float marginM)
+ {
+ foreach (var c in crags)
+ {
+ var local = Quaternion.Euler(0f, -c.yaw, 0f) * Flat(p - c.at);
+ float half = 0.5f * c.w + marginM;
+ if (Mathf.Abs(local.x) < half && Mathf.Abs(local.z) < half) return true;
+ }
+ return false;
+ }
+
+ // 3. The goat track: a curve from corner g+2 to corner g+4, bowed towards the gentle side so it crosses near the
+ // centre, with a small wiggle that dies out at both ends; painted as dirt strokes.
+ Vector3 p0 = ctx.At(Corner(g + 2), 0.90f), p2 = ctx.At(Corner(g + 4), 0.90f), pc = ctx.At(gentle, ctx.Range(0.25f, 0.35f));
+ float wiggle = ctx.Range(0.03f, 0.05f) * s, phase = ctx.Range(0f, 6.283f);
+ var track = new List<Vector3>();
+ for (int k = 0; k <= 16; k++)
+ {
+ float t = k / 16f, u = 1f - t;
+ var at = u * u * p0 + 2f * u * t * pc + t * t * p2;
+ var tangent = Flat(2f * u * (pc - p0) + 2f * t * (p2 - pc)).normalized;
+ var side = new Vector3(tangent.z, 0f, -tangent.x);
+ track.Add(at + side * (wiggle * Mathf.Sin(Mathf.PI * t) * Mathf.Sin(3f * Mathf.PI * t + phase)));
+ }
+ for (int k = 0; k < track.Count - 1; k++) ctx.PaintStroke("dirt", track[k], track[k + 1], 0.03f * s, 0.8f);
+ bool NearTrack(Vector3 p, float within)
+ {
+ for (int k = 0; k < track.Count - 1; k++) if (DistToSegment(p, track[k], track[k + 1]) < within) return true;
+ return false;
+ }
+
+ // 4. Scree: pale rock aprons round each crag's foot and fanning to the rim (the mountain layer, which holds the
+ // rocky read where neighbouring ground blends in), a rocky rim band away from the gentle side, and earthier
+ // patches (the hills layer) on the open slopes beside the crags.
+ foreach (var c in crags)
+ {
+ float bearing = Bearing(ctx, c.at);
+ ctx.PaintGround("mountain", c.at, c.yaw, 1.6f * c.w, 1.4f * c.w, 0.45f, 1f);
+ ctx.PaintGround("mountain", ctx.At(bearing, 0.80f), bearing, 1.1f * c.w, 0.22f * s, 0.5f, 0.9f);
+ }
+ for (int k = 1; k <= 4; k++) // the four edges not touching corner g
+ ctx.PaintStroke("mountain", ctx.At(Corner(g + k), 0.86f), ctx.At(Corner(g + k + 1), 0.86f), 0.12f * s, 0.7f);
+ for (int k = 1; k < 6; k += 2) // edge midpoints g+1.5, g+3.5 and g+5.5, each beside a crag corner
+ {
+ float bearing = Corner(g + k) + 30f;
+ ctx.PaintGround("hills", ctx.At(bearing + ctx.Range(-8f, 8f), ctx.Range(0.50f, 0.60f)), bearing + ctx.Range(-20f, 20f),
+ ctx.Range(0.18f, 0.24f) * s, ctx.Range(0.10f, 0.14f) * s, 0.5f, 0.6f);
+ }
+
+ // 5. Boulders at the crags' feet: beside each crag (in its frame, off a side face), never in the unit spot.
+ int boulders = 0;
+ foreach (var c in crags)
+ {
+ if (boulders >= MaxBoulders) break;
+ float w = ctx.Range(0.07f, 0.10f) * s, sideSign = ctx.Rng.Next(2) == 0 ? -1f : 1f;
+ var at = c.at + Quaternion.Euler(0f, c.yaw, 0f) * new Vector3(sideSign * (0.5f * c.w + 0.6f * w + 0.02f * s), 0f, ctx.Range(-0.2f, 0.2f) * c.w);
+ float yaw = ctx.Range(0f, 360f);
+ if (ctx.InUnitSpot(at, 0.75f * w) || NearTrack(at, 0.75f * w + 0.02f * s)) continue;
+ if (ctx.PlaceByWidth(Rock, at, yaw, w, StandIn.Rock, Limestone, maxSlopeDeg: 70f)) boulders++;
+ }
+
+ // Trees already down, so later pieces keep off them.
+ var trees = new List<(Vector3 at, float r)>();
+ bool Clear(Vector3 at, float r)
+ {
+ foreach (var t in trees) if (Flat(at - t.at).magnitude < r + t.r) return false;
+ return true;
+ }
+
+ // 6. Terraced olives on the gentle side: three contour arcs about corner g (contours on the dome are circles),
+ // each painted as an earthy terrace band, olives spaced along them.
+ int olives = 0;
+ for (int row = 0; row < 3; row++)
+ {
+ float r = 0.42f + 0.13f * row, half = 20f + 8f * row;
+ var arc = new List<Vector3>();
+ for (int k = 0; k <= 6; k++) arc.Add(ctx.At(gentle - half + 2f * half * k / 6f, r));
+ for (int k = 0; k < arc.Count - 1; k++) ctx.PaintStroke("hills", arc[k], arc[k + 1], 0.055f * s, 0.85f);
+
+ float stepDeg = Mathf.Rad2Deg * (0.13f / r), jitter = ctx.Range(-0.5f, 0.5f) * stepDeg;
+ for (float b = gentle - half + 0.5f * stepDeg + jitter; b <= gentle + half; b += stepDeg)
+ {
+ if (olives >= MaxOlives) break;
+ var at = ctx.At(b, r + ctx.Range(-0.012f, 0.012f));
+ float height = ctx.Range(0.12f, 0.14f) * s, yaw = ctx.Range(0f, 360f);
+ if (ctx.InUnitSpot(at, 0.04f * s) || InCrag(at, 0.04f * s) || NearTrack(at, 0.05f * s) || !Clear(at, 0.04f * s)) continue;
+ if (ctx.PlaceByHeight(Olive, at, yaw, height, StandIn.Tree, OliveGreen, footprintShare: 0.45f, maxSlopeDeg: 50f))
+ {
+ trees.Add((at, 0.04f * s)); olives++;
+ }
+ }
+ }
+ bool InTerraces(Vector3 p)
+ {
+ float d = Flat(p - ctx.Centre).magnitude / s, off = Mathf.Abs(Mathf.DeltaAngle(Bearing(ctx, p), gentle));
+ return d > 0.36f && off < 40f;
+ }
+
+ // 7. A few Aleppo pines on the rugged side: edge midpoints in a seeded order, off the crags, track and terraces.
+ int pines = 0, firstEdge = ctx.Rng.Next(6);
+ for (int i = 0; i < 12 && pines < MaxPines; i++)
+ {
+ float bearing = Corner(firstEdge + i) + 30f + ctx.Range(-6f, 6f), r = i < 6 ? 0.66f : 0.72f;
+ var at = ctx.At(bearing, r);
+ float height = ctx.Range(0.15f, 0.18f) * s, yaw = ctx.Range(0f, 360f);
+ if (InTerraces(at) || InCrag(at, 0.04f * s) || NearTrack(at, 0.06f * s) || !Clear(at, 0.05f * s)) continue;
+ if (ctx.PlaceByHeight(Pine, at, yaw, height, StandIn.Pine, PineGreen, footprintShare: 0.3f, maxSlopeDeg: 50f))
+ {
+ trees.Add((at, 0.04f * s)); pines++;
+ }
+ }
+
+ // 8. Carobs, scattered at the margins between the crags.
+ int carobs = 0;
+ for (int i = 0; i < 30 && carobs < MaxCarobs; i++)
+ {
+ var at = ctx.At(ctx.Range(0f, 360f), ctx.Range(0.40f, 0.74f));
+ float height = ctx.Range(0.12f, 0.14f) * s, yaw = ctx.Range(0f, 360f);
+ if (ctx.InUnitSpot(at, 0.04f * s) || InTerraces(at) || InCrag(at, 0.04f * s) || NearTrack(at, 0.05f * s) || !Clear(at, 0.05f * s)) continue;
+ if (ctx.PlaceByHeight(Carob, at, yaw, height, StandIn.Tree, CarobGreen, footprintShare: 0.45f, maxSlopeDeg: 50f))
+ {
+ trees.Add((at, 0.04f * s)); carobs++;
+ }
+ }
+
+ // 9. Garrigue: clumps of two to four small, dusty-green bushes on the open slopes, off the unit spot and track.
+ int garrigue = 0;
+ for (int clump = 0; clump < 14 && garrigue < MaxGarrigue; clump++)
+ {
+ var centre = ctx.RandomPoint(0.05f * s);
+ int n = 2 + ctx.Rng.Next(3);
+ for (int k = 0; k < n && garrigue < MaxGarrigue; k++)
+ {
+ var at = centre + new Vector3(ctx.Range(-0.05f, 0.05f) * s, 0f, ctx.Range(-0.05f, 0.05f) * s);
+ float height = ctx.Range(0.04f, 0.06f) * s, yaw = ctx.Range(0f, 360f);
+ if (ctx.InUnitSpot(at, 0.02f * s) || InCrag(at, 0.01f * s) || NearTrack(at, 0.03f * s) || !Clear(at, 0.02f * s)) continue;
+ if (ctx.PlaceByHeight(Garrigue, at, yaw, height, StandIn.Tree, DustyGreen, footprintShare: 1.0f, maxSlopeDeg: 60f)) garrigue++;
+ }
+ }
+ }
+
+ static float Bearing(HexTileContext ctx, Vector3 p) => Mathf.Atan2(p.x - ctx.Centre.x, p.z - ctx.Centre.z) * Mathf.Rad2Deg;
+
+ static Vector3 Flat(Vector3 v) => new Vector3(v.x, 0f, v.z);
+
+ static float DistToSegment(Vector3 p, Vector3 a, Vector3 b)
+ {
+ Vector3 ab = Flat(b - a), ap = Flat(p - a);
+ float t = Mathf.Clamp01(Vector3.Dot(ap, ab) / Mathf.Max(ab.sqrMagnitude, 1e-4f));
+ return (ap - ab * t).magnitude;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/JudeanHighlands.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JudeanHighlands.cs.meta
new file mode 100644
index 000000000..f462a812f
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/JudeanHighlands.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: bcd1998ed97744f799b75b862e9b3c8e
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/Kibbutz.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/Kibbutz.cs
new file mode 100644
index 000000000..470cce60c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/Kibbutz.cs
@@ -0,0 +1,130 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>A kibbutz of the 1940s as a Civ-style settlement tile (Degania, Ein Harod). A compact fenced compound
+ /// stands in the north of the hex, toward one flat side (bearing 30 or 330). The first-batch compound cluster is its core.
+ /// The dining hall (the landmark) faces the hex centre on the lawn in front of it. Two rows of low living quarters stand
+ /// to the west. The farmyard to the east holds two cowsheds, a hay barn and the water tower. A painted ring path runs
+ /// inside the perimeter fence. Large painted fields (wheat, green fodder, fresh ploughing) on one grid fill the rest of
+ /// the hex. The access road runs from the gate through the hex centre, where a unit stands, lined with shade trees.
+ /// Three rectangular fishponds lie on dykes to one side. An L of cypress windbreaks shelters the other side.
+ ///
+ /// The compound starts 0.28 S out and its buildings 0.30 S out (centre 0.56 S), so no tall piece enters the unit spot.
+ /// A core 0.35 S out would cross into it: a 0.31 S footprint reaches 0.16 S toward the centre.
+ ///
+ /// Triangle estimate at the maximum counts (FlatSurface refuses nothing), with measured per-model counts. The compound
+ /// cluster has 12,432 polygon indices in its FBX: about 4,144 triangles, or about 6,200 if it holds quads. Dining hall kit_kibbutz_2 (b07) 1,400. Six
+ /// quarters kit_kibbutz (b09a) x 700 = 4,200. Three barns kit_kibbutz_3 (b24) x 1,400 = 4,200. Water tower
+ /// kit_kibbutz_4 (b28) 1,400. Buildings 15,344. 13 cypress x 1,596 = 20,748. 4 tabor oaks x 648 = 2,592. 3 pond flats
+ /// x 12 = 36. Total about 38,700 (40,800 with quads) of 60,000.</summary>
+ [HexPrototype("kibbutz")]
+ public sealed class Kibbutz : IHexPrototype
+ {
+ public string Title => "Kibbutz compound and its fields (1940s)";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "plains";
+ public int TriangleBudget => 60000;
+
+ // Explicit kit ids, not "kit_kibbutz*": the wildcard would mix the dining hall, barn and water tower into the rows.
+ const string Core = "proto:kibbutz-compound-v2", Quarters = "sandbox:kit_kibbutz", DiningHall = "sandbox:kit_kibbutz_2",
+ Barn = "sandbox:kit_kibbutz_3", WaterTower = "sandbox:kit_kibbutz_4", Cypress = "sandbox:cypress_lite",
+ ShadeTree = "sandbox:tabor_oak_lite";
+
+ static readonly Color RedRoof = new Color(0.72f, 0.36f, 0.26f), Plaster = new Color(0.86f, 0.82f, 0.72f),
+ Timber = new Color(0.52f, 0.38f, 0.26f), Concrete = new Color(0.82f, 0.80f, 0.74f),
+ PondWater = new Color(0.27f, 0.45f, 0.53f), Leaf = new Color(0.20f, 0.36f, 0.16f), CypressLeaf = new Color(0.12f, 0.26f, 0.13f);
+
+ // The perimeter in the compound frame (u across, v outward from the hex centre, shares of S), chamfered at the
+ // corners so the ring stays inside the inset hexagon.
+ static readonly Vector2[] Perimeter =
+ {
+ new Vector2(-0.42f, 0.205f), new Vector2(0.42f, 0.205f), new Vector2(0.49f, 0.14f), new Vector2(0.49f, -0.20f),
+ new Vector2(0.36f, -0.285f), new Vector2(-0.36f, -0.285f), new Vector2(-0.49f, -0.20f), new Vector2(-0.49f, 0.14f),
+ };
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ // The compound faces a flat side in the north half, so it stands behind the unit as the camera sees it.
+ float bearing = (ctx.Rng.Next(2) == 0 ? -30f : 30f) + ctx.Range(-3f, 3f);
+ float pondSide = ctx.Rng.Next(2) == 0 ? -1f : 1f;
+ var turn = Quaternion.Euler(0f, bearing, 0f);
+ // The field frame (x across, z toward the compound, shares of S, about the hex centre) and the compound frame.
+ Vector3 F(float x, float z) => ctx.Centre + turn * new Vector3(x * s, 0f, z * s);
+ const float Out = 0.56f;
+ Vector3 L(float u, float v) => F(u, Out + v);
+
+ // 1. Fields: a 7 x 7 grid of large parcels painted as crops, clipped to the hex, none under the compound.
+ string[] crops = { "wheat", "wheat", "green_crop", "ploughed", "wheat", "green_crop" };
+ const float cell = 0.34f;
+ for (int i = -3; i <= 3; i++)
+ for (int j = -3; j <= 3; j++)
+ {
+ float x = i * cell, z = j * cell;
+ var at = F(x, z);
+ if (!ctx.Inside(at, -0.2f * s)) continue; // wholly outside the hex
+ if (Mathf.Abs(x) < 0.54f && z > 0.2f) continue; // the compound
+ string crop = crops[ctx.Rng.Next(crops.Length)];
+ bool across = ctx.Rng.Next(2) == 0;
+ if (ctx.Rng.Next(8) == 0) continue; // pasture
+ ctx.PaintGround(crop, at, bearing + (across ? 90f : 0f), (cell - 0.03f) * s, (cell - 0.03f) * s, 0.08f, 0.95f);
+ }
+
+ // 2. The compound ground: a lawn over the fenced area, the farmyard in dirt, then the ring path inside the fence.
+ ctx.PaintGround("grass", L(0f, -0.04f), bearing, 0.98f * s, 0.49f * s, 0.15f, 0.8f);
+ ctx.PaintGround("dirt", L(0.31f, -0.07f), bearing, 0.30f * s, 0.36f * s, 0.25f, 0.8f);
+ for (int k = 0; k < Perimeter.Length; k++)
+ {
+ Vector2 a = Perimeter[k], b = Perimeter[(k + 1) % Perimeter.Length];
+ ctx.PaintStroke("dirt", L(a.x, a.y), L(b.x, b.y), 0.022f * s, 0.9f);
+ }
+ // The access road from the gate through the hex centre (the unit stands on it) to the far edge.
+ ctx.PaintStroke("dirt", L(0f, -0.285f), ctx.At(bearing + 180f, 0.95f), 0.035f * s, 0.95f);
+
+ // 3. Fishponds: three rectangles in a row on painted dykes, on one side of the road. Water-blue flats, since a
+ // pond is a man-made surface, not ground.
+ float px = pondSide * 0.40f;
+ ctx.PaintGround("dirt", F(px, -0.475f), bearing, 0.19f * s, 0.42f * s, 0.15f, 0.9f);
+ foreach (float z in new[] { -0.34f, -0.475f, -0.61f })
+ if (!ctx.InUnitSpot(F(px, z), 0.09f * s))
+ ctx.PlaceFlat(F(px, z), bearing, 0.13f * s, 0.11f * s, PondWater, 80f);
+
+ // 4. The compound. The core cluster faces the hex centre, with the dining hall in front of it on the lawn.
+ Place(ctx, L(0f, 0.03f), 0.22f * s, p => ctx.PlaceByWidth(Core, p, bearing + 180f, 0.31f * s, StandIn.Box, RedRoof));
+ Place(ctx, L(0f, -0.205f), 0.05f * s, p => ctx.PlaceByWidth(DiningHall, p, bearing + 180f, 0.17f * s, StandIn.Box, Plaster));
+ // The living quarters: two rows of three to the west, facing the core across a lane.
+ foreach (float u in new[] { -0.245f, -0.385f })
+ foreach (float v in new[] { 0.105f, -0.015f, -0.135f })
+ Place(ctx, L(u, v), 0.09f * s, p => ctx.PlaceByWidth(Quarters, p, bearing + 90f, 0.12f * s, StandIn.Box, RedRoof));
+ // The farmyard to the east: two cowsheds side by side, a hay barn in front, the water tower behind.
+ foreach (float u in new[] { 0.235f, 0.37f })
+ Place(ctx, L(u, -0.03f), 0.1f * s, p => ctx.PlaceByWidth(Barn, p, bearing + 180f, 0.16f * s, StandIn.Box, Timber));
+ Place(ctx, L(0.30f, -0.205f), 0.09f * s, p => ctx.PlaceByWidth(Barn, p, bearing + 90f, 0.13f * s, StandIn.Box, Timber));
+ Place(ctx, L(0.25f, 0.13f), 0.07f * s, p => ctx.PlaceByHeight(WaterTower, p, bearing + 180f, 0.18f * s, StandIn.Palm, Concrete, 0.55f));
+ Place(ctx, L(0.405f, 0.135f), 0.07f * s, p => ctx.PlaceByHeight(ShadeTree, p, ctx.Range(0f, 360f), 0.12f * s, StandIn.Tree, Leaf, 0.5f));
+
+ // 5. Shade trees along the road beyond the unit spot (tabor oaks stand in for eucalyptus).
+ Place(ctx, F(0.075f, -0.42f), 0.08f * s, p => ctx.PlaceByHeight(ShadeTree, p, ctx.Range(0f, 360f), 0.13f * s, StandIn.Tree, Leaf, 0.5f));
+ Place(ctx, F(-0.075f, -0.58f), 0.08f * s, p => ctx.PlaceByHeight(ShadeTree, p, ctx.Range(0f, 360f), 0.13f * s, StandIn.Tree, Leaf, 0.5f));
+ Place(ctx, F(0.075f, -0.74f), 0.08f * s, p => ctx.PlaceByHeight(ShadeTree, p, ctx.Range(0f, 360f), 0.13f * s, StandIn.Tree, Leaf, 0.5f));
+
+ // 6. Windbreaks: an L of cypresses along two field edges on the side away from the ponds (8 + 5).
+ float wx = -pondSide;
+ for (int k = 0; k < 8; k++)
+ Place(ctx, F(wx * 0.51f, -0.42f + 0.085f * k), 0.05f * s,
+ p => ctx.PlaceByHeight(Cypress, p, ctx.Range(0f, 360f), ctx.Range(0.15f, 0.17f) * s, StandIn.Pine, CypressLeaf, 0.3f));
+ foreach (float x in new[] { 0.18f, 0.265f, 0.35f, 0.435f, 0.51f })
+ Place(ctx, F(wx * x, -0.51f), 0.05f * s,
+ p => ctx.PlaceByHeight(Cypress, p, ctx.Range(0f, 360f), ctx.Range(0.15f, 0.17f) * s, StandIn.Pine, CypressLeaf, 0.3f));
+ }
+
+ /// <summary>Places a tall piece only when it stays clear of the unit spot by <paramref name="clearM"/> (about half its
+ /// footprint); a refused placement is normal.</summary>
+ static void Place(HexTileContext ctx, Vector3 at, float clearM, System.Func<Vector3, bool> place)
+ {
+ if (!ctx.InUnitSpot(at, clearM)) place(at);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/Kibbutz.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/Kibbutz.cs.meta
new file mode 100644
index 000000000..bd31aa992
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/Kibbutz.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3687c263430b745549896c526af1d12d
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/MoshavaVillage.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MoshavaVillage.cs
new file mode 100644
index 000000000..f2546dc80
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MoshavaVillage.cs
@@ -0,0 +1,123 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>A moshava, a Jewish farming colony of the coastal plain (Rishon LeZion, Rehovot, 1948). One main street
+ /// runs through the hex on a grid turned up to 20 degrees, with a cypress gateway at each end. Two rows of red-roofed
+ /// houses face the street, each with its garden behind (citrus or a date palm). The water tower stands on a small
+ /// plaza mid-street, with the first-batch moshava cluster across from it. A barn, a farmhouse and the stone wine
+ /// cellar stand in the back row. Citrus groves on dark soil fill the two flanks. The street, gardens, yards and grove
+ /// soil are painted into the ground (ctx.PaintGround / PaintStroke); only the paved plaza is a flat.
+ ///
+ /// Triangle estimate, at the maximum counts (FlatSurface refuses nothing), with measured per-model counts:
+ /// 4 kit_moshava x 700 + 4 kit_moshava_2 x 1399 (houses) + moshava-town-v1 x 3555 + barn kit_moshava_3 x 1400 +
+ /// farmhouse kit_moshava x 700 + winery kit_moshava_2 x 1399 = 15,450. 14 citrus x 1602 = 22,428. 4 cypress x 1596 =
+ /// 6,384. 6 date palms x 284 = 1,704. Water tower (kit_kibbutz_4) as in the kibbutz tile. 1 flat x 12. Total about 46,000 of 60,000.
+ ///
+ /// The water tower is the kibbutz tile's b28 tower (sandbox:kit_kibbutz_4); where it is missing, the Palm stand-in
+ /// draws instead, its silhouette (a thin shaft under a wide crown) the nearest to a tank on a column.</summary>
+ [HexPrototype("moshava_village")]
+ public sealed class MoshavaVillage : IHexPrototype
+ {
+ public string Title => "Moshava farming colony (1948)";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "plains";
+ public int TriangleBudget => 60000;
+
+ // Explicit kit ids, not "kit_moshava*": the wildcard would also pick kit_moshava_3, which is the barn.
+ const string Farmhouse = "sandbox:kit_moshava", TwoStorey = "sandbox:kit_moshava_2", Barn = "sandbox:kit_moshava_3",
+ Cluster = "proto:moshava-town-v1", WaterTower = "sandbox:kit_kibbutz_4",
+ Citrus = "sandbox:citrus_lite", Cypress = "sandbox:cypress_lite", Palm = "sandbox:date_palm";
+
+ static readonly Color RedRoof = new Color(0.72f, 0.36f, 0.26f), Stone = new Color(0.78f, 0.72f, 0.60f),
+ Timber = new Color(0.52f, 0.38f, 0.26f), Concrete = new Color(0.82f, 0.80f, 0.74f),
+ Plaza = new Color(0.84f, 0.78f, 0.64f), Leaf = new Color(0.16f, 0.34f, 0.14f), CypressLeaf = new Color(0.12f, 0.26f, 0.13f);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S, yaw = ctx.Range(-20f, 20f);
+ var turn = Quaternion.Euler(0f, yaw, 0f);
+ // A point in the street's frame, in shares of S: x across the street, z along it.
+ Vector3 L(float x, float z) => ctx.Centre + turn * new Vector3(x * s, 0f, z * s);
+
+ // 1. The main street, a dirt stroke right through the hex (clipped to it).
+ ctx.PaintStroke("dirt", L(0f, -0.95f), L(0f, 0.95f), 0.055f * s, 0.95f);
+
+ // 2. Two rows of houses facing the street, five slots a side. The middle west slot is the water-tower plaza,
+ // the middle east slot the first-batch cluster. Every house has its garden behind it.
+ float[] slots = { -0.48f, -0.24f, 0f, 0.24f, 0.48f };
+ int house = 0;
+ foreach (float side in new[] { -1f, 1f })
+ for (int i = 0; i < slots.Length; i++)
+ {
+ float z = slots[i];
+ if (i == 2 && side < 0f)
+ {
+ ctx.PlaceFlat(L(-0.17f, 0f), yaw, 0.16f * s, 0.17f * s, Plaza);
+ ctx.PlaceByHeight(WaterTower, L(-0.19f, 0f), yaw, 0.17f * s, StandIn.Palm, Concrete, 0.35f);
+ ctx.PlaceByHeight(Palm, L(-0.11f, -0.065f), ctx.Range(0f, 360f), 0.12f * s, StandIn.Palm, null, 0.3f);
+ ctx.PlaceByHeight(Palm, L(-0.11f, 0.065f), ctx.Range(0f, 360f), 0.12f * s, StandIn.Palm, null, 0.3f);
+ continue;
+ }
+ if (i == 2)
+ {
+ ctx.PlaceByWidth(Cluster, L(0.18f, 0f), yaw - 90f, 0.2f * s, StandIn.Box, RedRoof);
+ continue;
+ }
+ string model = house++ % 2 == 0 ? Farmhouse : TwoStorey;
+ ctx.PlaceByWidth(model, L(side * 0.155f, z), yaw + side * 90f, ctx.Range(0.13f, 0.15f) * s, StandIn.Box, RedRoof);
+ if (!Fits(ctx, L(side * 0.30f, z), yaw, 0.11f * s, 0.17f * s)) continue;
+ ctx.PaintGround("grass", L(side * 0.30f, z), yaw, 0.11f * s, 0.17f * s, 0.25f, 0.75f);
+ if ((i + (side > 0f ? 1 : 0)) % 2 == 0)
+ ctx.PlaceByHeight(Citrus, L(side * 0.30f, z), ctx.Range(0f, 360f), ctx.Range(0.12f, 0.14f) * s, StandIn.Tree, Leaf, 0.6f);
+ else
+ ctx.PlaceByHeight(Palm, L(side * 0.30f, z), ctx.Range(0f, 360f), 0.12f * s, StandIn.Palm, null, 0.3f);
+ }
+
+ // 3. The back row: the barn on its yard and a farmhouse to the west, the stone wine cellar on its yard to the east.
+ if (Fits(ctx, L(-0.45f, 0.30f), yaw, 0.18f * s, 0.24f * s))
+ {
+ ctx.PaintGround("dirt", L(-0.45f, 0.30f), yaw, 0.18f * s, 0.24f * s, 0.25f, 0.8f);
+ ctx.PlaceByWidth(Barn, L(-0.45f, 0.30f), yaw + 90f, 0.16f * s, StandIn.Box, Timber);
+ }
+ ctx.PlaceByWidth(Farmhouse, L(-0.45f, -0.30f), yaw + 90f, 0.14f * s, StandIn.Box, RedRoof);
+ if (Fits(ctx, L(0.47f, -0.30f), yaw, 0.20f * s, 0.24f * s))
+ {
+ ctx.PaintGround("dirt", L(0.47f, -0.30f), yaw, 0.20f * s, 0.24f * s, 0.25f, 0.8f);
+ ctx.PlaceByWidth(TwoStorey, L(0.47f, -0.30f), yaw - 90f, 0.19f * s, StandIn.Box, Stone);
+ }
+
+ // 4. Citrus groves on the flanks, in straight rows on painted tilled soil: 3 x 2 to the east, 2 x 2 to the west.
+ ctx.PaintGround("ploughed", L(0.62f, 0.11f), yaw, 0.20f * s, 0.34f * s, 0.2f, 0.7f);
+ foreach (float x in new[] { 0.56f, 0.68f })
+ foreach (float z in new[] { -0.02f, 0.11f, 0.24f })
+ ctx.PlaceByHeight(Citrus, L(x, z), ctx.Range(0f, 360f), ctx.Range(0.12f, 0.14f) * s, StandIn.Tree, Leaf, 0.6f);
+ ctx.PaintGround("ploughed", L(-0.64f, 0.025f), yaw, 0.20f * s, 0.21f * s, 0.2f, 0.7f);
+ foreach (float x in new[] { -0.58f, -0.70f })
+ foreach (float z in new[] { -0.04f, 0.09f })
+ ctx.PlaceByHeight(Citrus, L(x, z), ctx.Range(0f, 360f), ctx.Range(0.12f, 0.14f) * s, StandIn.Tree, Leaf, 0.6f);
+
+ // 5. A cypress gateway at each end of the street.
+ foreach (float z in new[] { -0.70f, 0.70f })
+ foreach (float x in new[] { -0.075f, 0.075f })
+ ctx.PlaceByHeight(Cypress, L(x, z), ctx.Range(0f, 360f), ctx.Range(0.17f, 0.19f) * s, StandIn.Pine, CypressLeaf, 0.3f);
+ }
+
+ /// <summary>The test the flats these paints replaced made (every corner inside the hex, on dry ground, within the
+ /// default rise), so the pieces gated on them place exactly as before.</summary>
+ static bool Fits(HexTileContext ctx, Vector3 at, float yawDeg, float widthM, float depthM, float maxRiseM = 60f)
+ {
+ var rot = Quaternion.Euler(0f, yawDeg, 0f);
+ float lo = float.MaxValue, hi = float.MinValue;
+ foreach (var c in new[] { Vector3.zero, new Vector3(widthM, 0f, depthM) * 0.5f, new Vector3(-widthM, 0f, depthM) * 0.5f,
+ new Vector3(widthM, 0f, -depthM) * 0.5f, new Vector3(-widthM, 0f, -depthM) * 0.5f })
+ {
+ var q = at + rot * c;
+ if (!ctx.Inside(q) || ctx.IsWater(q)) return false;
+ float y = ctx.GroundY(q); lo = Mathf.Min(lo, y); hi = Mathf.Max(hi, y);
+ }
+ return hi - lo <= maxRiseM;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/MoshavaVillage.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MoshavaVillage.cs.meta
new file mode 100644
index 000000000..4b1924944
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MoshavaVillage.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: b2383cb71440646548aa3914c197001f
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/MountainPeaks.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MountainPeaks.cs
new file mode 100644
index 000000000..c5d11fd6c
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MountainPeaks.cs
@@ -0,0 +1,25 @@
+#nullable enable
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>Built-in context tile for a mountain hex: two to four great rock masses (Poly Haven scans, stand-in rocks).</summary>
+ [HexPrototype("mountain_peaks")]
+ public sealed class MountainPeaks : IHexPrototype
+ {
+ public string Title => "Mountain peaks";
+ public HexTerrain Terrain => HexTerrain.Mountain;
+ public string Ground => "mountain";
+ public int TriangleBudget => 6000;
+
+ public void Build(HexTileContext ctx)
+ {
+ int n = 2 + ctx.Rng.Next(3);
+ for (int k = 0; k < n; k++)
+ {
+ float width = ctx.Range(0.45f, 0.75f) * ctx.S;
+ var at = ctx.At(ctx.Range(0f, 360f), ctx.Range(0f, 0.25f));
+ ctx.PlaceByWidth("sandbox:limestone*", at, ctx.Range(0f, 360f), width, StandIn.Rock, null, 90f);
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/MountainPeaks.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MountainPeaks.cs.meta
new file mode 100644
index 000000000..886c0137f
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/MountainPeaks.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 1605b22445cd44c63813f6784fdc6902
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/OliveTerraces.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/OliveTerraces.cs
new file mode 100644
index 000000000..943460b31
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/OliveTerraces.cs
@@ -0,0 +1,117 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>Terraced hill farming in the Samarian and Judean foothills (1948). Contour terraces ring the hill dome
+ /// about the hex centre. Each terrace is a band of ploughed soil (at 0.42, 0.60 and 0.78 S) with a dry-stone riser on
+ /// its downhill side. The risers are painted as thin rocky lines, with short runs of limestone boulders where they show.
+ /// All the rings share one slightly irregular contour shape, so they read as contours, not circles. Olive trees stand
+ /// in rows along the bands, with a few carobs among them. A stone field hut stands on the middle terrace, with its path
+ /// down to the hex edge. A track climbs from the south edge to the bare summit, where a unit stands.
+ ///
+ /// The bands are polylines of PaintStroke at strength 0.85. Paints lerp in turn, so at a lower strength the joints
+ /// between strokes would bead visibly.
+ ///
+ /// Triangle estimate at the maximum counts (capped by counters; FlatSurface refuses nothing), with measured per-model
+ /// counts: at most 22 olives x 1,602 = 35,244, at most 4 carobs x 648 = 2,592, at most 12 limestone x 700 = 8,400, and
+ /// the hut kit_stone_village_2 x 700. Total at most 46,936 of 50,000.</summary>
+ [HexPrototype("olive_terraces")]
+ public sealed class OliveTerraces : IHexPrototype
+ {
+ public string Title => "Olive terraces on a hillside (1948)";
+ public HexTerrain Terrain => HexTerrain.Hills;
+ public string Ground => "hills";
+ public int TriangleBudget => 50000;
+
+ // The hut is explicit, not "kit_stone_village*": the wildcard would also pick b17, the village mosque.
+ const string Olive = "sandbox:olive_lite", Carob = "sandbox:carob_lite", Stone = "sandbox:limestone*",
+ Hut = "sandbox:kit_stone_village_2";
+ const int MaxOlives = 22, MaxCarobs = 4, StoneRuns = 4, StonesPerRun = 3, Segments = 24;
+
+ static readonly Color OliveLeaf = new Color(0.38f, 0.44f, 0.28f), CarobLeaf = new Color(0.18f, 0.32f, 0.15f),
+ Limestone = new Color(0.80f, 0.76f, 0.66f), HutStone = new Color(0.76f, 0.70f, 0.58f);
+
+ static readonly float[] Bands = { 0.42f, 0.60f, 0.78f }; // terrace soil (tree rows on the inner two, corners on the outer)
+ static readonly float[] Risers = { 0.33f, 0.51f, 0.69f, 0.87f }; // dry-stone walls, downhill of each band
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ // One contour shape for every ring: two low harmonics, so the terraces swell and pinch together.
+ float phase1 = ctx.Range(0f, 360f), phase2 = ctx.Range(0f, 360f);
+ float Wobble(float b) => 1f + 0.05f * Mathf.Sin((b + phase1) * Mathf.Deg2Rad) + 0.03f * Mathf.Sin((2f * b + phase2) * Mathf.Deg2Rad);
+ Vector3 On(float r, float b) => ctx.At(b, r * Wobble(b));
+
+ float trackB = ctx.Range(160f, 200f); // the track up from the south
+ float hutB = trackB + (ctx.Rng.Next(2) == 0 ? -1f : 1f) * ctx.Range(70f, 110f); // the hut, off the track
+ var hut = On(Bands[1], hutB);
+
+ // 1. Ground: the terrace bands, then the risers, then the track, the hut's path and its yard.
+ foreach (float r in Bands) Ring("ploughed", r, 0.12f, 0.85f);
+ foreach (float r in Risers) Ring("mountain", r, 0.022f, 0.8f);
+ ctx.PaintStroke("dirt", ctx.At(trackB, 0.97f), ctx.Centre, 0.03f * s, 0.9f);
+ ctx.PaintStroke("dirt", hut, ctx.At(hutB, 0.97f), 0.02f * s, 0.85f);
+ ctx.PaintGround("dirt", hut, hutB, 0.15f * s, 0.15f * s, 0.3f, 0.8f);
+
+ // 2. The field hut, its front down the slope.
+ if (!ctx.InUnitSpot(hut, 0.07f * s)) ctx.PlaceByWidth(Hut, hut, hutB, 0.10f * s, StandIn.Box, HutStone);
+
+ // 3. Trees in rows along the bands: the middle terrace first (the most seen), then the upper, then one at each
+ // corner of the outer terrace, where the hexagon has room. Gaps where the track and the hut's path cross.
+ int olives = 0, carobs = 0;
+ float o1 = ctx.Range(0f, 360f / 13f), o0 = ctx.Range(0f, 40f);
+ for (int k = 0; k < 13; k++)
+ {
+ float b = o1 + k * 360f / 13f;
+ if (Mathf.Abs(Mathf.DeltaAngle(b, hutB)) < 16f) continue;
+ Tree(Bands[1], b);
+ }
+ for (int k = 0; k < 9; k++) Tree(Bands[0], o0 + k * 40f);
+ for (int k = 0; k < 6; k++)
+ {
+ float b = k * 60f + ctx.Range(-5f, 5f);
+ if (Mathf.Abs(Mathf.DeltaAngle(b, hutB)) < 10f) continue;
+ Tree(Bands[2], b);
+ }
+
+ // 4. Short runs of limestone where the risers show between the rows.
+ for (int run = 0; run < StoneRuns; run++)
+ {
+ float r = Risers[1 + ctx.Rng.Next(2)], b0 = ctx.Range(0f, 360f);
+ if (Mathf.Abs(Mathf.DeltaAngle(b0, trackB)) < 12f) continue;
+ for (int i = 0; i < StonesPerRun; i++)
+ {
+ var p = On(r, b0 + (i - 1) * 5f);
+ if (ctx.InUnitSpot(p, 0.03f * s)) continue;
+ ctx.PlaceByWidth(Stone, p, ctx.Range(0f, 360f), ctx.Range(0.035f, 0.05f) * s, StandIn.Rock, Limestone);
+ }
+ }
+
+ // A closed contour ring of one ground layer, as a polyline with a little irregularity at each vertex.
+ void Ring(string layer, float r, float widthShare, float strength)
+ {
+ var pts = new Vector3[Segments];
+ for (int k = 0; k < Segments; k++) pts[k] = On(r + ctx.Range(-0.008f, 0.008f), k * 360f / Segments);
+ for (int k = 0; k < Segments; k++) ctx.PaintStroke(layer, pts[k], pts[(k + 1) % Segments], widthShare * s, strength);
+ }
+
+ // One tree slot on a band: now and then a gap or a carob, otherwise an olive, up to the caps.
+ void Tree(float r, float b)
+ {
+ if (Mathf.Abs(Mathf.DeltaAngle(b, trackB)) < 10f) return;
+ var p = On(r, b);
+ if (ctx.InUnitSpot(p, 0.07f * s)) return;
+ int roll = ctx.Rng.Next(10);
+ if (roll == 0) return;
+ if (roll == 1 && carobs < MaxCarobs)
+ {
+ if (ctx.PlaceByHeight(Carob, p, ctx.Range(0f, 360f), ctx.Range(0.14f, 0.16f) * s, StandIn.Tree, CarobLeaf, 0.5f)) carobs++;
+ return;
+ }
+ if (olives >= MaxOlives) return;
+ if (ctx.PlaceByHeight(Olive, p, ctx.Range(0f, 360f), ctx.Range(0.12f, 0.13f) * s, StandIn.Tree, OliveLeaf, 0.5f)) olives++;
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/OliveTerraces.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/OliveTerraces.cs.meta
new file mode 100644
index 000000000..c1ca30365
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/OliveTerraces.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: a64e7bda19fce4d16b12ffdd4ba07731
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/PineForest.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/PineForest.cs
new file mode 100644
index 000000000..f3e867cf8
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/PineForest.cs
@@ -0,0 +1,149 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>JNF pine forest on the first foothills east of Tel Aviv, 1948 (the Ben Shemen plantings): Aleppo pines in
+ /// planted, slightly irregular contour rows over most of the hex, closed into one canopy with native fill; two grassy
+ /// clearings with limestone outcrops; native Tabor oaks and carobs at the margins; a dirt forest track winding west to
+ /// east (Tel Aviv side to the hills). The clearings and the track are painted into the ground (no flats), and tall
+ /// pieces keep out of the unit spot (ctx.InUnitSpot).
+ /// Triangle budget by arithmetic (caps below): 27 pines x ~1600 + 9 broadleaf x ~650 + 3 rocks x ~700 = 51,150, and
+ /// no flats; about 51k of 60k.</summary>
+ [HexPrototype("pine_forest")]
+ public sealed class PineForest : IHexPrototype
+ {
+ public string Title => "JNF pine forest, foothills east of Tel Aviv (1948)";
+ public HexTerrain Terrain => HexTerrain.Hills;
+ public string Ground => "hills";
+ public int TriangleBudget => HexScale.BudgetForest;
+
+ // Models: EZ-Tree trees and Poly Haven rocks are local-only for now; the stand-ins draw without them.
+ const string Pine = "sandbox:aleppo_pine_lite", Oak = "sandbox:tabor_oak_lite", Carob = "sandbox:carob_lite", Rock = "sandbox:limestone*";
+ // Caps that keep the tile inside its budget whatever the models' exact counts.
+ const int MaxPines = 22, MaxBroadleaf = 9, MaxFill = 26;
+
+ static readonly Color PineGreen = new Color(0.20f, 0.33f, 0.18f), OakGreen = new Color(0.36f, 0.44f, 0.23f),
+ CarobGreen = new Color(0.27f, 0.39f, 0.20f), Limestone = new Color(0.86f, 0.83f, 0.74f);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+
+ // 1. The track: a sine-wiggled line across the hex, roughly west (Tel Aviv) to east, painted as dirt strokes.
+ float trackBearing = 80f + ctx.Range(-15f, 15f), amp = ctx.Range(0.10f, 0.15f) * s, phase = ctx.Range(0f, 6.283f);
+ var along = new Vector3(Mathf.Sin(trackBearing * Mathf.Deg2Rad), 0f, Mathf.Cos(trackBearing * Mathf.Deg2Rad));
+ var side = new Vector3(along.z, 0f, -along.x);
+ Vector3 TrackAt(float t) => ctx.Centre + along * (t * s) + side * (amp * Mathf.Sin(2.6f * t + phase));
+ var track = new List<Vector3>();
+ for (int k = 0; k <= 16; k++) track.Add(TrackAt(-0.95f + k * (1.9f / 16f)));
+ for (int k = 0; k < track.Count - 1; k++) ctx.PaintStroke("dirt", track[k], track[k + 1], 0.035f * s, 0.85f);
+
+ // 2. Two clearings, one each side of the track, pulled inwards until they sit in the hex, painted as dry grass.
+ var clearings = new[]
+ {
+ (centre: TrackAt(ctx.Range(-0.40f, -0.15f)) + side * (0.22f * s), radius: 0.16f * s),
+ (centre: TrackAt(ctx.Range(0.20f, 0.42f)) - side * (0.20f * s), radius: 0.12f * s),
+ };
+ for (int c = 0; c < clearings.Length; c++)
+ {
+ var at = clearings[c].centre;
+ for (int i = 0; i < 6 && !ctx.Inside(at, clearings[c].radius * 0.6f); i++) at = Vector3.Lerp(at, ctx.Centre, 0.3f);
+ clearings[c].centre = at;
+ ctx.PaintGround("plains", at, ctx.Range(0f, 90f), 1.3f * clearings[c].radius, 1.3f * clearings[c].radius, 0.4f, 0.8f);
+ }
+
+ // 3. Limestone outcrops in the clearings: two in the larger, one in the smaller (none in the unit spot).
+ for (int c = 0; c < clearings.Length; c++)
+ for (int k = 0; k < 2 - c; k++)
+ {
+ var at = clearings[c].centre + Quaternion.Euler(0f, ctx.Range(0f, 360f), 0f) * new Vector3(0f, 0f, ctx.Range(0.2f, 0.5f) * clearings[c].radius);
+ float yaw = ctx.Range(0f, 360f), width = ctx.Range(0.06f, 0.09f) * s; // drawn even when skipped, so the sequence holds
+ if (ctx.InUnitSpot(at, 0.04f * s)) continue;
+ ctx.PlaceByWidth(Rock, at, yaw, width, StandIn.Rock, Limestone, 40f);
+ }
+
+ bool InClearing(Vector3 p, float extra)
+ {
+ foreach (var c in clearings) if (Flat(p - c.centre).magnitude < c.radius + extra) return true;
+ return false;
+ }
+ bool NearTrack(Vector3 p, float within)
+ {
+ for (int k = 0; k < track.Count - 1; k++) if (DistToSegment(p, track[k], track[k + 1]) < within) return true;
+ return false;
+ }
+
+ // 4a. Spots for the native broadleaf at the margins: around the clearings' rims and the forest edge. Chosen
+ // before the rows, so no pine is planted on them.
+ var margins = new List<Vector3>();
+ foreach (var c in clearings)
+ {
+ float start = ctx.Range(0f, 360f);
+ for (int k = 0; k < 3; k++)
+ margins.Add(c.centre + Quaternion.Euler(0f, start + 120f * k + ctx.Range(-25f, 25f), 0f) * new Vector3(0f, 0f, c.radius * 0.95f));
+ }
+ for (int k = 0; k < 6; k++) margins.Add(ctx.At(60f * k + ctx.Range(10f, 50f), ctx.Range(0.62f, 0.72f)));
+ bool NearMargin(Vector3 p)
+ {
+ foreach (var m in margins) if (Flat(p - m).magnitude < 0.08f * s) return true;
+ return false;
+ }
+
+ // 4b. The planted stands: staggered contour rows, each cell jittered; cells in the unit spot stay empty. Pines
+ // go in a seeded order until the cap.
+ float rowYaw = ctx.Range(15f, 40f), rowGap = 0.17f * s, treeGap = 0.16f * s;
+ var turn = Quaternion.Euler(0f, rowYaw, 0f);
+ var cells = new List<(Vector3 at, double key)>();
+ for (int j = -5; j <= 5; j++)
+ for (int i = -5; i <= 5; i++)
+ {
+ float x = (i + (j & 1) * 0.5f) * treeGap, z = j * rowGap;
+ var at = ctx.Centre + turn * new Vector3(x, 0f, z)
+ + new Vector3(ctx.Range(-0.03f, 0.03f) * s, 0f, ctx.Range(-0.03f, 0.03f) * s);
+ double key = ctx.Rng.NextDouble();
+ if (!ctx.Inside(at, 0.04f * s) || ctx.InUnitSpot(at, 0.04f * s) || InClearing(at, 0.06f * s) || NearTrack(at, 0.075f * s)) continue;
+ bool shaded = !NearMargin(at); // a broadleaf spot keeps its floor but takes no pine
+ cells.Add((at, shaded ? key : 2.0));
+ }
+
+ var order = new int[cells.Count];
+ for (int k = 0; k < order.Length; k++) order[k] = k;
+ Array.Sort(order, (a, b) => cells[a].key != cells[b].key ? cells[a].key.CompareTo(cells[b].key) : a.CompareTo(b));
+ int pines = 0, fill = 0;
+ foreach (int k in order)
+ {
+ if (cells[k].key > 1.0) break;
+ if (pines < MaxPines)
+ {
+ if (ctx.PlaceByHeight(Pine, cells[k].at, ctx.Range(0f, 360f), ctx.Range(0.16f, 0.20f) * s, StandIn.Pine, PineGreen, 0.3f)) pines++;
+ }
+ // The rest of the stand closes into canopy with round-crowned native trees (light: ~650 triangles each).
+ else if (fill < MaxFill && ctx.PlaceByHeight(ctx.Rng.Next(3) == 0 ? Carob : Oak, cells[k].at, ctx.Range(0f, 360f), ctx.Range(0.13f, 0.16f) * s, StandIn.Tree, OakGreen, 0.45f))
+ fill++;
+ }
+
+ // 5. Native broadleaf at the margins (spots chosen in step 4a): oak or carob.
+ int broadleaf = 0;
+ foreach (var at in margins)
+ {
+ if (broadleaf >= MaxBroadleaf) break;
+ if (NearTrack(at, 0.05f * s) || ctx.InUnitSpot(at, 0.04f * s)) continue;
+ bool oak = ctx.Rng.Next(3) != 0; // Tabor oak about two in three, carob the rest
+ if (ctx.PlaceByHeight(oak ? Oak : Carob, at, ctx.Range(0f, 360f), ctx.Range(0.14f, 0.17f) * s, StandIn.Tree, oak ? OakGreen : CarobGreen, 0.45f))
+ broadleaf++;
+ }
+ }
+
+ static Vector3 Flat(Vector3 v) => new Vector3(v.x, 0f, v.z);
+
+ static float DistToSegment(Vector3 p, Vector3 a, Vector3 b)
+ {
+ Vector3 ab = Flat(b - a), ap = Flat(p - a);
+ float t = Mathf.Clamp01(Vector3.Dot(ap, ab) / Mathf.Max(ab.sqrMagnitude, 1e-4f));
+ return (ap - ab * t).magnitude;
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/PineForest.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/PineForest.cs.meta
new file mode 100644
index 000000000..a850998b9
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/PineForest.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: b5787ae7b01ef45b98093d6f528bed5f
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs
new file mode 100644
index 000000000..0033dfaba
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs
@@ -0,0 +1,104 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>REFERENCE PROTOTYPE: copy this file to start a new hex (docs/hex-tiles/README.md).
+ /// Tel Aviv 1948, the White City core, built Civ-style around one square: the White City landmark on a round plaza
+ /// ringed by palms (Dizengoff Square), four palm-lined avenues out to the edge, an inner ring of Bauhaus buildings
+ /// facing the square and an outer ring on the city's grid (-20 degrees, turned to the coast), garden trees between,
+ /// townspeople on the square, a horse wagon on an avenue, and a palm promenade along the shore. Models are the
+ /// 13 October Tripo set (local, pending rights); every piece has a stand-in.
+ /// Budget: this showcase tile is drawn at full quality (about 110k triangles); LODs come before any map rollout.</summary>
+ [HexPrototype("tel_aviv_city")]
+ public class TelAvivCity : IHexPrototype
+ {
+ public virtual string Title => "Tel Aviv, White City (1948)";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "plains";
+ public int TriangleBudget => 120000;
+
+ const string Hero = "sandbox:hq_white_city_hero", Building = "sandbox:hq_white_city*", Palm = "sandbox:date_palm",
+ GardenTree = "sandbox:carob_lite", Wagon = "proto:figure-vehicle-horse-wagon-1948-v2";
+ static readonly string[] People =
+ {
+ "proto:figure-townsman-c02-1948-v2", "proto:figure-woman-blue-dress-c10-1948-v2", "proto:figure-nurse-c13-1948-v2",
+ "proto:figure-arriving-man-c01-1948-v2", "proto:figure-sabra-pioneer-c04-1948-v2",
+ };
+ static readonly Color Plaster = new Color(0.95f, 0.93f, 0.88f);
+
+ const float GridYaw = -20f;
+
+ /// <summary>The outer ring's k-th building and its footprint width; a variant may swap in other models here.</summary>
+ protected virtual (string model, float width) OuterBuilding(int k, HexTileContext ctx) => (Building, ctx.Range(0.15f, 0.17f) * ctx.S);
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ // Bearings are clockwise from north; the avenues follow the city grid.
+ float[] avenues = { GridYaw, GridYaw + 90f, GridYaw + 180f, GridYaw + 270f };
+ bool OnAvenue(float bearing, float clearDeg) { foreach (var a in avenues) if (Mathf.Abs(Mathf.DeltaAngle(bearing, a)) < clearDeg) return true; return false; }
+
+ // 1. The square: an octagonal plaza (two crossed squares), the landmark on it, a ring of palms round its edge.
+ float plaza = 0.42f * s;
+ // Painted ground, not flat boxes (Tal, 19 Oct): pale sand paving for the square, the yards and the promenade.
+ ctx.PaintGround("beach", ctx.Centre, GridYaw, 0.95f * s, 0.95f * s, 0.45f, 0.4f); // the town's lighter ground
+ ctx.PaintGround("beach", ctx.Centre, GridYaw, plaza, plaza, 0.25f);
+ ctx.PaintGround("beach", ctx.Centre, GridYaw + 45f, plaza, plaza, 0.25f);
+ ctx.PlaceByWidth(Hero, ctx.Centre, GridYaw + 180f, 0.24f * s, StandIn.Box, Plaster);
+ for (int k = 0; k < 10; k++)
+ {
+ float b = GridYaw + 18f + 36f * k;
+ if (!OnAvenue(b, 8f)) ctx.PlaceByHeight(Palm, ctx.At(b, 0.19f), b, 0.12f * s, StandIn.Palm, null, 0.3f);
+ }
+
+ // 2. Avenues out to the edge, palms on both sides.
+ foreach (var a in avenues) ctx.PaintStroke("dirt", ctx.At(a, 0.23f), ctx.At(a, 0.88f), 0.05f * s);
+ foreach (var a in avenues)
+ for (float r = 0.26f; r <= 0.86f; r += 0.06f)
+ {
+ if (r > 0.3f && Mathf.Repeat(r, 0.12f) < 0.06f)
+ foreach (float side in new[] { -90f, 90f })
+ ctx.PlaceByHeight(Palm, ctx.At(a, r) + Quaternion.Euler(0f, a + side, 0f) * Vector3.forward * (0.045f * s), 0f, 0.11f * s, StandIn.Palm, null, 0.3f);
+ }
+
+ // 3. Inner ring: eight buildings facing the square, between the avenues. Outer ring: twelve on the grid.
+ for (int k = 0; k < 8; k++)
+ {
+ float b = GridYaw + 22.5f + 45f * k;
+ var at = ctx.At(b, 0.41f);
+ ctx.PaintGround("beach", at, b, 0.2f * s, 0.2f * s, 0.3f, 0.8f);
+ ctx.PlaceByWidth(Building, at, b + 180f, ctx.Range(0.16f, 0.18f) * s, StandIn.Box, Plaster);
+ }
+ for (int k = 0; k < 12; k++)
+ {
+ float b = GridYaw + 15f + 30f * k;
+ if (OnAvenue(b, 10f)) b += 10f;
+ var at = ctx.At(b, 0.67f + ctx.Range(-0.03f, 0.03f));
+ var (model, width) = OuterBuilding(k, ctx);
+ if (!ctx.PlaceByWidth(model, at, GridYaw + 90f * ctx.Rng.Next(4), width, StandIn.Box, Plaster)) continue;
+ ctx.PaintGround("beach", at, GridYaw, width * 1.15f, width * 1.15f, 0.3f, 0.8f);
+ // A garden tree in the gap after each outer building.
+ ctx.PlaceByHeight(GardenTree, ctx.At(b + 15f, 0.67f), ctx.Range(0f, 360f), 0.13f * s, StandIn.Tree, null, 0.5f);
+ }
+
+ // 4. Life: townspeople on the square in two small groups, a horse wagon coming in along the north avenue.
+ for (int k = 0; k < People.Length; k++)
+ {
+ float b = GridYaw + 200f + 22f * k + (k > 2 ? 60f : 0f);
+ ctx.PlaceByHeight(People[k], ctx.At(b, 0.15f), b + 160f + ctx.Range(-30f, 30f), 0.075f * s, StandIn.Figure, null, 0.4f);
+ }
+ ctx.PlaceByWidth(Wagon, ctx.At(avenues[0], 0.5f), avenues[0] + 180f, 0.1f * s, StandIn.Box, new Color(0.45f, 0.33f, 0.22f));
+
+ // 5. The shore: where a bearing reaches the sea, a promenade strip and a palm just short of the water.
+ for (float b = 180f; b <= 360f; b += 14f)
+ for (float r = 0.3f; r <= 0.9f; r += 0.04f)
+ {
+ if (!ctx.IsWater(ctx.At(b, r + 0.06f))) continue;
+ ctx.PaintGround("beach", ctx.At(b, r), b, 0.07f * s, 0.06f * s, 0.3f);
+ ctx.PlaceByHeight(Palm, ctx.At(b, r - 0.04f), 0f, 0.11f * s, StandIn.Palm, null, 0.3f);
+ break;
+ }
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs.meta
new file mode 100644
index 000000000..39e69e8d2
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCity.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3861fc1a68db14a8a895b38687f67d75
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCityMixed.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCityMixed.cs
new file mode 100644
index 000000000..1198e1944
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCityMixed.cs
@@ -0,0 +1,18 @@
+#nullable enable
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>A/B variant of tel_aviv_city for review: the same layout, but every other outer-ring building is a block
+ /// from the first (10 October, faceted low-poly) Tripo batch, drawn as a cluster of houses at a building's footprint, so detail
+ /// stays realistic at the square and the edge reads denser. Render it on the city's hex with
+ /// -prototype tel_aviv_city_mixed -on tel_aviv_city.</summary>
+ [HexPrototype("tel_aviv_city_mixed")]
+ public sealed class TelAvivCityMixed : TelAvivCity
+ {
+ public override string Title => "Tel Aviv, White City (1948), mixed with the first batch";
+ static readonly string[] FirstBatch = { "proto:tel-aviv-white-city-v1", "proto:moshava-town-v1" };
+
+ protected override (string model, float width) OuterBuilding(int k, HexTileContext ctx) =>
+ k % 2 == 1 ? (FirstBatch[(k / 2) % FirstBatch.Length], ctx.Range(0.165f, 0.18f) * ctx.S) : base.OuterBuilding(k, ctx);
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCityMixed.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCityMixed.cs.meta
new file mode 100644
index 000000000..125f76038
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/TelAvivCityMixed.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: eccc64fd516d143658b369f9db7fa19d
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/WheatFields.cs b/unity/Assets/Scripts/Map/HexTiles/Prototypes/WheatFields.cs
new file mode 100644
index 000000000..5b371bcf2
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/WheatFields.cs
@@ -0,0 +1,83 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Prototypes
+{
+ /// <summary>Context tile: a farmed plain, Civ's farm improvement. A patchwork of large fields on one grid (wheat,
+ /// green fodder, fresh ploughing) with tracks between, olive hedgerows along a few edges, and one farmhouse with its
+ /// barn (13 October Tripo modules) by the main track. Light, so many hexes can wear it.</summary>
+ [HexPrototype("wheat_fields")]
+ public sealed class WheatFields : IHexPrototype
+ {
+ public string Title => "Wheat fields and a farmstead";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "plains";
+ public int TriangleBudget => HexScale.BudgetFields + 10000;
+
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S, yaw = ctx.Range(-25f, 25f), cell = 0.36f * s, gap = 0.035f * s;
+ var turn = Quaternion.Euler(0f, yaw, 0f);
+ // Fields: a 5 x 5 grid of parcels painted into the ground as crop rows (wheat, green crops, fresh ploughing),
+ // a few left as pasture, with soft edges so they read as fields, not boards, from far away.
+ string[] crops = { "wheat", "wheat", "green_crop", "ploughed", "wheat", "green_crop" };
+ for (int i = -2; i <= 2; i++)
+ for (int j = -2; j <= 2; j++)
+ {
+ var at = ctx.Centre + turn * new Vector3(i * cell, 0f, j * cell);
+ string crop = crops[ctx.Rng.Next(crops.Length)];
+ bool across = ctx.Rng.Next(2) == 0;
+ if (ctx.Rng.Next(7) == 0) continue; // pasture
+ ctx.PaintGround(crop, at, yaw + (across ? 90f : 0f), cell - gap, cell - gap, 0.08f, 0.95f);
+ }
+ // The farm track: one straight dirt track along the grid through the hex, the farmstead on it.
+ ctx.PaintStroke("dirt", ctx.Centre + turn * new Vector3(0.5f * cell, 0f, -2.6f * cell), ctx.Centre + turn * new Vector3(0.5f * cell, 0f, 2.6f * cell), 0.035f * s);
+ // Hedgerows: olives down two parcel edges.
+ for (int k = -4; k <= 4; k++)
+ foreach (float x in new[] { -0.5f, 0.5f })
+ if (ctx.Rng.Next(3) != 0 && !ctx.InUnitSpot(ctx.Centre + turn * new Vector3(x * cell, 0f, k * cell * 0.5f), 0.05f * s))
+ ctx.PlaceByHeight("sandbox:olive_lite", ctx.Centre + turn * new Vector3(x * cell, 0f, k * cell * 0.5f), ctx.Range(0f, 360f), 0.12f * s, StandIn.Tree, null, 0.5f);
+ // The farmstead on a yard by the centre track: a two-storey farmhouse and a barn.
+ var yard = ctx.Centre + turn * new Vector3(0.48f * s, 0f, -0.18f * s); // out of the unit spot
+ ctx.PaintGround("dirt", yard, yaw, 0.3f * s, 0.24f * s, 0.3f, 0.9f);
+ ctx.PlaceByWidth("sandbox:kit_moshava", yard + turn * new Vector3(-0.06f * s, 0f, 0f), yaw + 180f, 0.13f * s, StandIn.Box);
+ ctx.PlaceByWidth("sandbox:kit_moshava_3", yard + turn * new Vector3(0.08f * s, 0f, 0.02f * s), yaw + 90f, 0.12f * s, StandIn.Box);
+ }
+ }
+
+ /// <summary>Context tile: open grazing land in the coastal plain and foothills. Scattered olive and carob trees, a few
+ /// rock outcrops, and a flock of sheep with a donkey and their shepherd's track (13 October Tripo animals).</summary>
+ [HexPrototype("grazing_land")]
+ public sealed class GrazingLand : IHexPrototype
+ {
+ public string Title => "Grazing land with a flock";
+ public HexTerrain Terrain => HexTerrain.Flat;
+ public string Ground => "grass";
+ public int TriangleBudget => 60000;
+
+ public void Build(HexTileContext ctx)
+ {
+ float s = ctx.S;
+ int trees = 0;
+ for (int k = 0; k < 60 && trees < 12; k++)
+ {
+ bool carob = ctx.Rng.Next(3) == 0;
+ var spot = ctx.RandomPoint(0.04f * s);
+ if (ctx.InUnitSpot(spot, 0.05f * s)) continue;
+ if (ctx.PlaceByHeight(carob ? "sandbox:carob_lite" : "sandbox:olive_lite", spot, ctx.Range(0f, 360f), ctx.Range(0.12f, 0.15f) * s, StandIn.Tree, null, 0.5f)) trees++;
+ }
+ for (int k = 0; k < 3; k++)
+ ctx.PlaceByWidth("sandbox:limestone*", ctx.At(ctx.Range(0f, 360f), ctx.Range(0.4f, 0.6f)), ctx.Range(0f, 360f), ctx.Range(0.07f, 0.1f) * s, StandIn.Rock);
+ // The flock: one compact group, all grazing the same way, the donkey at its edge.
+ var flock = ctx.At(ctx.Range(0f, 360f), ctx.Range(0.45f, 0.55f)); // grazing beside the unit spot, not in it
+ float heading = ctx.Range(0f, 360f);
+ for (int k = 0; k < 6; k++)
+ {
+ var p = flock + new Vector3(ctx.Range(-0.1f, 0.1f) * s, 0f, ctx.Range(-0.1f, 0.1f) * s);
+ ctx.PlaceByHeight("proto:figure-sheep-lite-1948", p, heading + ctx.Range(-30f, 30f), 0.06f * s, StandIn.Figure, null, 1.2f);
+ }
+ ctx.PlaceByHeight("proto:figure-donkey-lite-1948", flock + new Vector3(0.13f * s, 0f, 0f), heading, 0.08f * s, StandIn.Figure, null, 1.0f);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Prototypes/WheatFields.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Prototypes/WheatFields.cs.meta
new file mode 100644
index 000000000..0a12bea12
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Prototypes/WheatFields.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 6f7df40779dec40f5ac93e3c30571eb7
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Units.meta b/unity/Assets/Scripts/Map/HexTiles/Units.meta
new file mode 100644
index 000000000..127f1bfbd
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Units.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3c7890d7452a1402aaf7003d78d013c2
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/Map/HexTiles/Units/PalmachSquad.cs b/unity/Assets/Scripts/Map/HexTiles/Units/PalmachSquad.cs
new file mode 100644
index 000000000..c59c17b55
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Units/PalmachSquad.cs
@@ -0,0 +1,14 @@
+#nullable enable
+
+namespace Statecraft.HexTiles.Units
+{
+ /// <summary>A Palmach squad, 1948: eight fighters in a wedge (HexUnitTypes.Squad), the 13 October Tripo soldiers with
+ /// walk and idle clips. Only the characters: the land under them stays the tile's (Tal's unit rules).</summary>
+ [HexUnitType("palmach_squad")]
+ public sealed class PalmachSquad : IHexUnitType
+ {
+ public string Title => "Palmach squad (1948)";
+ public HexUnit Create() => HexUnitTypes.Squad(Title,
+ "proto:figure-palmach-scout-c12f-1948-v2", "proto:figure-veteran-fighter-c07-1948-v2", "proto:figure-young-recruit-c06-1948-v2");
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Units/PalmachSquad.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Units/PalmachSquad.cs.meta
new file mode 100644
index 000000000..a838bd543
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Units/PalmachSquad.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ea352fdba9e5546c89d13708b63322df
\ No newline at end of file
diff --git a/unity/Assets/Scripts/Map/HexTiles/Units/Vehicles.cs b/unity/Assets/Scripts/Map/HexTiles/Units/Vehicles.cs
new file mode 100644
index 000000000..918d74b4f
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Units/Vehicles.cs
@@ -0,0 +1,27 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.HexTiles.Units
+{
+ /// <summary>One-vehicle units (Tal's rule: a vehicle unit is one vehicle, and no road under it). Drawn at
+ /// HexUnitScale.VehicleLength; the 13 October Tripo vehicles face +X, hence the -90 degree turn.</summary>
+ [HexUnitType("sandwich_truck")]
+ public sealed class SandwichTruck : IHexUnitType
+ {
+ public string Title => "Sandwich armoured truck (1948)";
+ public HexUnit Create() => One(Title, "proto:figure-vehicle-sandwich-convoy-1948-v2");
+
+ public static HexUnit One(string title, string model, float lengthShare = HexUnitScale.VehicleLength) => new HexUnit
+ {
+ Title = title,
+ Members = { new HexUnitMember { Model = model, StandIn = StandIn.Box, Offset = Vector2.zero, HeightShare = lengthShare, CycleShare = 0.12f, ByWidth = true, YawOffset = -90f } },
+ };
+ }
+
+ [HexUnitType("willys_jeep")]
+ public sealed class WillysJeep : IHexUnitType
+ {
+ public string Title => "Willys jeep (1948)";
+ public HexUnit Create() => SandwichTruck.One(Title, "proto:figure-vehicle-willys-jeep-1948-v2", 0.36f);
+ }
+}
diff --git a/unity/Assets/Scripts/Map/HexTiles/Units/Vehicles.cs.meta b/unity/Assets/Scripts/Map/HexTiles/Units/Vehicles.cs.meta
new file mode 100644
index 000000000..ac8ac730b
--- /dev/null
+++ b/unity/Assets/Scripts/Map/HexTiles/Units/Vehicles.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 2d10bbd49980d4752a4a7fb70749f781
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 729ca5d31..41ec247b7 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -202,6 +202,11 @@ namespace Statecraft.Game.UI
DiagLog.BootPhase($"session started (turn {session.State.Turn}, replayed)");
var bridge = Bridge = new SimBridge(session, text);
if (keep != null) foreach (var order in keep.Queued) bridge.Queue(order); // in their order: each was within the attention left
+ if (Statecraft.HexTiles.HexTilesLook.Requested()) // opt-in hex-tile map (docs/hex-tiles/README.md); presentation only
+ {
+ Statecraft.HexTiles.HexTilesLook.Apply(map, true);
+ owned.Add(new Undo(() => Statecraft.HexTiles.HexTilesLook.Apply(map, false)));
+ }
var root = document.rootVisualElement;
bool hebrew = text["ui.lang"] == UiLanguage.Hebrew;
// Hebrew: the Hebrew face, the advanced text generator and the mirrored rows (.lang-he); each text's paragraph
diff --git a/unity/Assets/Tests/EditMode/HexTilesLookTests.cs b/unity/Assets/Tests/EditMode/HexTilesLookTests.cs
new file mode 100644
index 000000000..3ecf217e5
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/HexTilesLookTests.cs
@@ -0,0 +1,264 @@
+#nullable enable
+using System;
+using System.Collections;
+using System.Linq;
+using Statecraft.Game.Map;
+using UnityEditor.SceneManagement;
+using UnityEngine;
+using UnityEngine.TerrainUtils;
+using UnityEngine.TestTools;
+using Object = UnityEngine.Object;
+using NUnit.Framework;
+using Statecraft.HexTiles;
+
+/// <summary>The hex-tile switch is opt-in and strict, as MapLook's is (the default game must not change).</summary>
+public class HexTilesLookTests
+{
+ [TestCase("http://localhost/?hex-tiles", true)]
+ [TestCase("http://localhost/?hex-tiles=1", true)]
+ [TestCase("http://localhost/?map-look&hex-tiles", true)]
+ [TestCase("http://localhost/?hex-tile", false)]
+ [TestCase("http://localhost/?hex-tiles=0", false)]
+ [TestCase("http://localhost/#hex-tiles", false)]
+ [TestCase("http://localhost/?next=/p?hex-tiles", false)]
+ [TestCase(null, false)]
+ public void TheWebFlagIsStrict(string? url, bool expected) =>
+ Assert.AreEqual(expected, HexTilesLook.Requested(url, Array.Empty<string>(), webgl: true));
+
+ [Test]
+ public void TheDesktopFlagIsTheExactArgument()
+ {
+ Assert.IsTrue(HexTilesLook.Requested(null, new[] { "Statecraft", "-hex-tiles" }, webgl: false));
+ Assert.IsFalse(HexTilesLook.Requested(null, new[] { "-hex-tiles-x" }, webgl: false));
+ Assert.IsFalse(HexTilesLook.Requested(null, Array.Empty<string>(), webgl: false));
+ }
+
+ [Test]
+ public void TheBoardShipsInResources() => Assert.That(HexBoard.Load(HexTilesLook.Board).Hexes.Count, Is.GreaterThan(0));
+
+ [TestCase("sandwich_truck", true)]
+ [TestCase("willys_jeep", true)]
+ [TestCase("palmach_squad", false)]
+ public void MissingModelsKeepTheDeclaredUnitSize(string typeId, bool byWidth)
+ {
+ const float size = 1000f;
+ var unit = HexUnitTypes.Create(typeId).Create();
+ // Exercise fallback even on an artist's machine with the local pending-rights models.
+ foreach (var m in unit.Members)
+ {
+ Assert.AreEqual(byWidth, m.ByWidth);
+ m.Model = "tiles:__missing_unit_test_" + typeId;
+ Assert.IsNull(HexModels.Prefab(m.Model));
+ }
+ var root = new GameObject("HexUnitFallbackTest");
+ try
+ {
+ var motion = new HexUnitMotion(unit, new[] { (0, 0) }, new FlatSurface(), root.transform, size);
+ motion.Pose(0f, false);
+ Assert.AreEqual(unit.Members.Count, motion.Objects.Count);
+ for (int i = 0; i < unit.Members.Count; i++)
+ {
+ var bounds = motion.Objects[i].GetComponentInChildren<Renderer>().bounds.size;
+ float dimension = byWidth ? Mathf.Max(bounds.x, bounds.z) : bounds.y;
+ Assert.That(dimension, Is.EqualTo(unit.Members[i].HeightShare * size).Within(0.01f), typeId);
+ var mesh = motion.Objects[i].GetComponentInChildren<MeshFilter>().sharedMesh;
+ StringAssert.Contains(byWidth ? "Cube" : "Capsule", mesh.name, "the declared Box/Figure stand-in");
+ }
+ }
+ finally { Object.DestroyImmediate(root); }
+ }
+
+ [TestCase("palmach_squad", false)]
+ [TestCase("palmach_squad", true)]
+ [TestCase("sandwich_truck", false)]
+ [TestCase("sandwich_truck", true)]
+ public void MissingModelsUseAnOwnedShippedMaterial(string typeId, bool existingBoardOwner)
+ {
+ var template = Resources.Load<Material>(HexMaterials.Folder + "/" + HexMaterials.Lit);
+ Assert.IsNotNull(template, "the portable material must ship with the player");
+ var unit = HexUnitTypes.Create(typeId).Create();
+ foreach (var member in unit.Members)
+ {
+ member.Model = "tiles:__missing_unit_material_test_" + typeId;
+ Assert.IsNull(HexModels.Prefab(member.Model));
+ }
+ var root = new GameObject("HexUnitMaterialLifetimeTest");
+ try
+ {
+ var boardOwner = existingBoardOwner ? root.AddComponent<HexBoardAssets>() : null;
+ var parent = existingBoardOwner ? new GameObject("Units").transform : root.transform;
+ if (existingBoardOwner) parent.SetParent(root.transform, false);
+ var motion = new HexUnitMotion(unit, new[] { (0, 0) }, new FlatSurface(), parent);
+ motion.Pose(0f, false);
+ Assert.AreEqual(unit.Members.Count, motion.Objects.Count);
+ var material = motion.Objects[0].GetComponent<MeshRenderer>().sharedMaterial;
+ Assert.IsNotNull(material);
+ Assert.AreNotSame(template, material, "the shipped template is borrowed, not owned");
+ Assert.AreSame(template.shader, material.shader);
+ Assert.AreEqual(template.GetColor("_BaseColor"), material.GetColor("_BaseColor"));
+ Assert.AreEqual(template.GetFloat("_Smoothness"), material.GetFloat("_Smoothness"));
+ foreach (var go in motion.Objects)
+ Assert.AreSame(material, go.GetComponent<MeshRenderer>().sharedMaterial, "one owned copy per motion");
+ Assert.AreEqual(1, root.GetComponentsInChildren<HexBoardAssets>(true).Length, "reuse the existing ancestor owner");
+ if (existingBoardOwner)
+ {
+ Assert.IsNull(parent.GetComponent<HexBoardAssets>(), "the child must not duplicate the board owner");
+ boardOwner!.Teardown();
+ }
+ else Object.DestroyImmediate(root);
+ Assert.IsTrue(material == null, "the parent/board lifetime releases the owned material");
+ Assert.IsTrue(template != null, "teardown must never destroy the shipped template");
+ }
+ finally { if (root != null) Object.DestroyImmediate(root); }
+ }
+
+ [Test]
+ public void TheBoardCanBeAppliedAfterReopeningTheEditorScene()
+ {
+ try
+ {
+ for (int pass = 0; pass < 2; pass++)
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>();
+ Assert.IsNotNull(map);
+ map.Build();
+ // No cache reset or manual mesh destruction: reopening the real scene releases procedural assets.
+ Assert.DoesNotThrow(() => HexTilesLook.Apply(map, true), "supported board, scene pass " + pass);
+ Assert.IsNotNull(map.transform.Find(HexTilesLook.RootName));
+ foreach (StandIn kind in Enum.GetValues(typeof(StandIn)))
+ {
+ var parts = HexModels.StandInParts(kind);
+ Assert.IsTrue(parts.All(part => part.mesh != null), kind + ": cached meshes are alive");
+ Assert.AreSame(parts, HexModels.StandInParts(kind), kind + ": live cached parts are reused");
+ Assert.Greater(HexModels.StandInTriangles(kind), 0, kind.ToString());
+ }
+ HexTilesLook.Apply(map, false);
+ Assert.IsNull(map.transform.Find(HexTilesLook.RootName));
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ }
+ }
+ finally
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ ShadowFit.Restore(); VisualToggles.Clear(); Statecraft.Game.Map.Kits.KitScale.Reset();
+ }
+ }
+
+ [Test]
+ public void RemovingAReplacementBoardRestoresTheDefaultMarkerStates()
+ {
+ try
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>();
+ Assert.IsNotNull(map);
+ map.Build();
+ var markers = map.transform.Find("Settlements").GetComponentsInChildren<MeshRenderer>(true);
+ Assert.Greater(markers.Length, 0);
+ var before = markers.Select(r => r.enabled).ToArray();
+ Assert.IsTrue(before.All(on => !on), "the default kits hide their placeholder boxes");
+ HexTilesLook.Apply(map, false);
+ CollectionAssert.AreEqual(before, markers.Select(r => r.enabled).ToArray(), "no board is a no-op");
+ HexTilesLook.Apply(map, true);
+ HexTilesLook.Apply(map, true); // replacing the board must also unwind its previous state first
+ Assert.IsNotNull(map.transform.Find(HexTilesLook.RootName));
+ HexTilesLook.Apply(map, false);
+ Assert.IsNull(map.transform.Find(HexTilesLook.RootName));
+ CollectionAssert.AreEqual(before, markers.Select(r => r.enabled).ToArray(),
+ "removing the replacement board must not enable placeholder boxes over the restored kits");
+ }
+ finally
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ ShadowFit.Restore(); VisualToggles.Clear(); Statecraft.Game.Map.Kits.KitScale.Reset();
+ }
+ }
+
+ // The replacement ground overlaps the real map; it is not a same-size neighboring Terrain tile.
+ static Terrain[] Neighbors(Terrain t) => new[] { t.leftNeighbor, t.topNeighbor, t.rightNeighbor, t.bottomNeighbor };
+ static string Facts(Terrain t) => $"{t.name} pos={t.transform.position:R} size={t.terrainData.size:R} res={t.terrainData.heightmapResolution} auto={t.allowAutoConnect} group={t.groupingID} neighbors=[{string.Join(",", Neighbors(t).Select(n => n == null ? "null" : n.name))}]";
+
+ [Test]
+ public void MatchingAdjacentTerrainsActuallyAutoConnect()
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ TerrainData? da = null, db = null; GameObject? ga = null, gb = null;
+ try
+ {
+ Assert.AreEqual(0, Terrain.activeTerrains.Length, "isolated positive-control fixture");
+ da = new TerrainData { heightmapResolution = 33, size = new Vector3(100, 20, 100) };
+ db = new TerrainData { heightmapResolution = 33, size = new Vector3(100, 20, 100) };
+ ga = Terrain.CreateTerrainGameObject(da); ga.name = "PositiveSouth";
+ gb = Terrain.CreateTerrainGameObject(db); gb.name = "PositiveNorth"; gb.transform.position = new Vector3(0, 0, 100);
+ var a = ga.GetComponent<Terrain>(); var b = gb.GetComponent<Terrain>();
+ a.allowAutoConnect = b.allowAutoConnect = true;
+ a.groupingID = b.groupingID = 30113;
+ TerrainUtility.AutoConnect();
+ Debug.Log("NEIGHBOR_POSITIVE " + Facts(a) + " | " + Facts(b));
+ Assert.AreSame(b, a.topNeighbor, "positive control: real adjacent north edge connects");
+ Assert.AreSame(a, b.bottomNeighbor, "positive control: reciprocal south edge connects");
+ }
+ finally
+ {
+ if (ga != null) Object.DestroyImmediate(ga);
+ if (gb != null) Object.DestroyImmediate(gb);
+ if (da != null) Object.DestroyImmediate(da);
+ if (db != null) Object.DestroyImmediate(db);
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ }
+ }
+
+ [UnityTest]
+ public IEnumerator SupportedOverlayIsNotAnAdjacentNeighborAndUndoRestoresBase()
+ {
+ try
+ {
+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);
+ var map = Object.FindFirstObjectByType<MapScene>(); Assert.IsNotNull(map);
+ map.Build();
+ var real = map.Terrain; Assert.IsNotNull(real);
+ Assert.AreEqual(1, Terrain.activeTerrains.Length, "actual map starts with one real terrain");
+ var data = real.terrainData; int n = data.heightmapResolution;
+ var before = data.GetHeights(0, 0, n, n);
+ var beforeSize = data.size; var beforePosition = real.transform.position;
+ bool beforeAuto = real.allowAutoConnect; int beforeGroup = real.groupingID;
+ TerrainUtility.AutoConnect();
+ Assert.IsTrue(Neighbors(real).All(t => t == null), "single base terrain has no neighbors");
+ Debug.Log("NEIGHBOR_BASE_BEFORE " + Facts(real));
+ HexTilesLook.Apply(map, true);
+ var holder = map.transform.Find(HexTilesLook.RootName); Assert.IsNotNull(holder);
+ var terrainList = holder.GetComponentsInChildren<Terrain>(true);
+ Assert.AreEqual(1, terrainList.Length, "one actual supported board Terrain");
+ var board = terrainList[0];
+ Assert.AreNotSame(real, board);
+ Assert.AreNotEqual(data.heightmapResolution, board.terrainData.heightmapResolution, "actual different-resolution overlay");
+ Assert.IsFalse(before.Cast<float>().SequenceEqual(data.GetHeights(0, 0, n, n).Cast<float>()),
+ "precondition: supported board changes real heights, so undo is not a no-op");
+ TerrainUtility.AutoConnect();
+ yield return null;
+ Debug.Log("NEIGHBOR_ACTUAL " + Facts(real) + " | " + Facts(board));
+ Assert.IsFalse(Neighbors(real).Contains(board), "overlapping board must not become adjacent base neighbor");
+ Assert.IsFalse(Neighbors(board).Contains(real), "base must not become adjacent overlay neighbor");
+ Assert.AreEqual(beforeAuto, real.allowAutoConnect, "placing board preserves base policy");
+ Assert.AreEqual(beforeGroup, real.groupingID, "placing board preserves base group");
+ HexTilesLook.Apply(map, false);
+ TerrainUtility.AutoConnect();
+ yield return null;
+ Assert.IsNull(map.transform.Find(HexTilesLook.RootName), "board removed");
+ Assert.AreEqual(1, Terrain.activeTerrains.Length, "only actual base remains");
+ Assert.AreSame(data, real.terrainData);
+ Assert.AreEqual(n, data.heightmapResolution); Assert.AreEqual(beforeSize, data.size);
+ Assert.AreEqual(beforePosition, real.transform.position);
+ Assert.AreEqual(beforeAuto, real.allowAutoConnect); Assert.AreEqual(beforeGroup, real.groupingID);
+ CollectionAssert.AreEqual(before, data.GetHeights(0, 0, n, n), "teardown restores all original base height samples exactly");
+ Assert.IsTrue(Neighbors(real).All(t => t == null), "no stale removed-board neighbor");
+ Debug.Log("NEIGHBOR_UNDO " + Facts(real));
+ }
+ finally
+ {
+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
+ ShadowFit.Restore(); VisualToggles.Clear(); Statecraft.Game.Map.Kits.KitScale.Reset();
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/HexTilesLookTests.cs.meta b/unity/Assets/Tests/EditMode/HexTilesLookTests.cs.meta
new file mode 100644
index 000000000..370b1cbc8
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/HexTilesLookTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 4235e5171ad0c4239a51abb0d3860fac
\ No newline at end of file
diff --git a/unity/Assets/link.xml b/unity/Assets/link.xml
index 01da2ca19..3282c1673 100644
--- a/unity/Assets/link.xml
+++ b/unity/Assets/link.xml
@@ -1,5 +1,8 @@
<linker>
<assembly fullname="YamlDotNet" preserve="all" />
<assembly fullname="Statecraft.Sim" preserve="all" />
- <assembly fullname="Statecraft.Game"><type fullname="Statecraft.Game.Map.*" preserve="all"/><type fullname="Statecraft.Game.UI.*" preserve="all"/><type fullname="Statecraft.Game.Boot.*" preserve="all"/></assembly>
+ <assembly fullname="Statecraft.Game"><type fullname="Statecraft.Game.Map.*" preserve="all"/><type fullname="Statecraft.Game.UI.*" preserve="all"/><type fullname="Statecraft.Game.Boot.*" preserve="all"/><type fullname="Statecraft.HexTiles.*" preserve="all"/></assembly>
+ <assembly fullname="UnityEngine.PhysicsModule">
+ <type fullname="UnityEngine.CapsuleCollider" preserve="all" />
+ </assembly>
</linker>