harvest/game/LAYOUT.md
Forrest c6daf3d217 #33: opening intro cutscene
OpeningIntro (game/scripts/opening_intro.gd) plays on every New vacation
(not Continue, not when hosting co-op): the farmers leave in their loaded
station wagon, "Later that night....", a bickering UFO crew drops a part
whose blue flash brings the scarecrow (hung on a post in its T-pose) to life,
the UFO zooms off, then the loading screen and the first morning's sign.
Hold Space / Enter / A (or E, or the mouse button) 1 s to skip from any
stage; Escape pauses it; Restart the night skips it; Save & quit clears it.
It ends with the farm exactly as new_campaign() leaves it.

Hooks: ReviewPanel keeps the sign down while the intro has the farm (and
only focuses Start when the sign is up); DialogueDirector holds its
conversations and the sign, then intro_over() plays night 1's morning
conversations before the sign; Tutorial hides; FarmAudio gets set_scene /
end_scene (ambience and music held by a cutscene) and stop_cue (the morning
stinger plays with the sign instead); Main wires new_vacation(intro),
blocked, resume's freeze, restart and to_menu.

Tests: test_intro (45 checks); test_flow skips the new intro. Tool:
game/tools/capture_intro.gd saves a frame per stage for the timing review.
Docs: README, RULES, LAYOUT (staging points), PLAYTEST.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-07 22:54:24 -04:00

320 lines
20 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Harvest Season — farm layout
The playable farm built in Step 2 of `first-game-plan.md`. All numbers here are measured by
`game/tests/test_farm_layout.gd`, which fails if the layout drifts from these rules.
## The map
- **Playable area: 60 × 80 m**, x −13…47 and z −45…35 (`FarmZones.playable`). It was 60 × 60 m
(to z 15) until #20 extended it 20 m south over the old plowed soil, where the lettuce/cabbage
and corn fields grow. The rest of the old farm is out-of-bounds scenery.
- **Perimeter:** what's left of the wooden fence (`fence_005`, 52 segments): the north side and
the east side down to z 15 (the original map's south-east corner), with **3 gaps**. The south
side and most of the west side were taken out, and the east side's southern 20 m (z 15…35) has
none, so the farm is open ground there. Just beyond that stretch, about 1 m outside the map,
the old farm's outer fence runs north to south (x ≈ 48.2, z 18…46).
- **The farm's edge** is where enemies come from and go: every enemy arrives at its own random
point along it, and carriers escape across it (see "The farm's edge" below).
- **Scarecrow bounds:** invisible walls on the old farm's outer fences (`Zones/Perimeter/PlayerBounds`,
physics layer 3 `player_bounds`). Only the scarecrow collides with them (its mask is 1 + 3). It
walks off the farm to the gathering areas outside (see "Outside the fence" below), but not off
the map. Enemy navigation ignores them.
- **Scarecrow start:** (3, −13), between the barn apron and the animal pen.
Top-down picture with zone outlines:
```sh
godot --path . --script res://game/tools/render_overview.gd -- --out=/tmp/farm.png --center=17,-5 --size=86 --zones
```
## Zones
Every zone is a `FarmZone` node under `Zones/` in `farm.tscn`: an axis-aligned rectangle with a
kind, a display name, and a tint. Its props are its children. In the editor each zone draws a
translucent box, so it can be moved and resized there.
| Zone | Rectangle (x, z) | What's there | Purpose |
|---|---|---|---|
| Crop Field | 14…46, −18.6…11.4 | The sunflower field: 6 plots, 30 crop units, two 2 m walkways between the plot bands | Exposed asset; crows' target |
| Lettuce Field | −6…4, 20…30 | Cabbage heads on the south-west plowed soil: 2 plots, 10 crop units. Sprouts after night 2 | A later crop field (see "The later fields" below) |
| Corn Field | 24…34, 20…30 | Corn stalks on the south-east plowed soil: 2 plots, 10 crop units. Sprouts after night 4 | A later crop field |
| Supply Shed | −6…8, −24…−14 | The red barn's south doors and the apron in front of them, with stock piles that grow and shrink with the stock (`ShedStock`): crates for scrap (west of the doors), logs for wood and hay bales for straw (east of the doors); also sacks and barrels | Stored materials; supply thieves' target |
| Work Area | 25.6…31.6, −29.8…−20.8 | Tool table, workbench, chair, bucket, between the barn and the house | Crafting, repairs, and upgrades |
| Animal Pen | −10…4, −11…−1 | Brown paddock fence, a gate in the opening on the east side (a gate structure, standing from the start), henhouse, 4 chickens, 2 pigs, 2 sheep | Livestock; animal thieves' target. Enemies can only reach the inside by breaking the gate |
| Woodlot | 37.5…46.5, −35…−21 | The fir tree line, dead trees and branches, log piles | Wood |
| Scrap Heap | 25.5…36.5, −44…−33 | Old pickup, wagon, wheelbarrow, lawn mower, barrels, crate, on the farmyard dirt | Scrap |
| Haystacks | 14…22, −44…−35 | The old hay stack (moved in from beyond the north fence) and 3 round bales | Straw |
### The shed's stock piles (Step 8)
`ShedStock` (`game/scripts/shed_stock.gd`) takes over some of the shed zone's props and adds more
next to them. One prop shows per few units stored:
| Pile | Props | Units per prop | Thieves' spot |
|---|---|---|---|
| Wood | 7 log stacks east of the doors (2 from the scene) | 4 | (2.6, −18.6), beside the doors |
| Scrap | 10 crates and barrels west of the doors and along the barn wall (4 from the scene) | 3 | (−3.0, −15.1), in front |
| Straw | 6 hay bales east of the doors (1 from the scene) | 4 | (6.75, −16.25), in front |
Every prop collides and is in place when the navigation is built, so enemies always route around
a pile's full footprint. A hidden prop stops colliding for the scarecrow and shots. Each spot has
its own flow field, so a supply thief goes to the pile it wants even when another is nearer.
### Gather points and the workbench (Step 5)
Each point is a `GatherNode` under its zone, holding the props it is made of.
| Zone | Point | Props | Charges | Gathering clip |
|---|---|---|---|---|
| Woodlot | DeadTree, Snag | dead trees | 2 each | Chopping |
| Woodlot | Deadfall | big dead tree | 3 | Chopping |
| Woodlot | LogPile | stump with logs | 2 | PickUp |
| Scrap Heap | Wreck | old pickup | 3 | Hammering |
| Scrap Heap | Wagon | wagon | 2 | Hammering |
| Scrap Heap | Mower | lawn mower | 2 | PickUp |
| Scrap Heap | OldBarrels | two barrels | 2 | PickUp |
| Haystacks | Haystack | the 12-bale stack | 4 | PickUp |
| Haystacks | BaleA, BaleB, BaleC | round bales | 2 each | PickUp |
- Every point yields 2 per charge and grows back fully overnight.
- `Workbench` (the work area's tool table) sells Straw Stuffing.
- `test_economy` checks that the scarecrow's body can stand within reach of every point and the
workbench.
The middle and south-west of the map (x −13…14, z −1…15) are deliberately open ground for
building defenses, and so is the south end around the later fields (z 15…35).
### Crop units
The field is 10 rows, 3 m apart. A column split (rows 1–5 and 6–10) and two walkways (z −8.5…−6.5
and 0.4…2.4) divide it into 6 plots. Each **unit is one row segment of a plot**, 9–13 plants:
`Zones/CropField/PlotN/UnitMM` (`CropUnit`, `unit_id` 1–30). `GameConfig.start_crops` is 30 to
match. The plan estimated about 40, but one row segment per unit keeps every theft clearly
visible.
| | West rows (x 17–29) | East rows (x 32–44) |
|---|---|---|
| North band (z −15.4…−8.5) | Plot 1: units 1–5 | Plot 2: units 6–10 |
| Middle band (z −6.5…0.4) | Plot 3: units 11–15 | Plot 4: units 16–20 |
| South band (z 2.4…9.4) | Plot 5: units 21–25 | Plot 6: units 26–30 |
### The later fields (#13, #20)
Two more crop fields sprout during the campaign. Until then their units are dormant: hidden, and
not stealable (`CropUnit.sprout_night`, `LootSystem`). #20 moved them onto the bare plowed soil
south of the original map: the ithappy `ground_008_004` tile (south-west, x −25.3…7.5,
z 14.6…45.3) and `ground_011_003` (south-east, x 13.4…46.1, z 14.2…44.8).
| Field | Zone (x, z) | Units | Plants per unit | Sprouts after |
|---|---|---|---|---|
| Lettuce Field | −6…4, 20…30 | Plot 7: 31–35, Plot 8: 36–40 | 8 cabbage heads (`plant_004` / `plant_005`, ≈0.45 m) | Night 2 |
| Corn Field | 24…34, 20…30 | Plot 9: 41–45, Plot 10: 46–50 | 10 corn stalks (`plant_001`, scaled to ≈2.1 m) | Night 4 |
- Each unit is one north–south row, about 6.6 m long (z ≈ 21.7…28.4). The rows are 0.95 m apart.
- **Height:** the soil's surface is 0.2–0.65 m above the grass. Each field's zone sits at the
soil's median height under its plants (y 0.44 and 0.31), and every plant follows the soil
beneath it.
- A cabbage rests on the lowest soil under its leaves.
- A corn stalk's base is 6 cm into the soil.
- `test_farm_layout` checks that no plant floats.
- **Tokens:** a carried or dropped crop shows its own field's plant (`LootSystem.CROP_TOKENS`).
- **Thieves:** a crop thief goes straight at its target once inside that target's field, given a
clear line (`ThiefBehavior.field_rects`, one rectangle per field).
## The farm's edge and the fence's gaps
**Arrivals.** Every enemy arrives at its own random point along the farm's edge
(`FarmZones.edge`, `WaveDirector`), not at fixed gates:
- On foot: 3 m outside the map (`GameConfig.spawn_margin`), at any free navigation cell along that
line that has a route onto the farm (`WaveDirector.ground_spawns`, nearly all of it). The same
line is where carriers escape with what they took (loose animals roam the farm but never leave
it on their own).
- Crows: 8 m outside the map (`flyer_spawn_margin`), anywhere along it. They leave straight out
the nearest side.
**The gaps** in what's left of the fence are each 3 m wide (the driveway is 4 m) and marked inside
by a signpost. A `FarmMarker` sits 3 m outside each one. Enemies arriving behind the fence walk in
through them (or around the fence's ends); nothing can be built in them, so the scarecrow can
always walk out to the gathering areas.
| Gap | Fence side, position | Leads to |
|---|---|---|
| GapNorth | north, x 10.5…13.5 | Haystacks, work area, barn apron |
| GapDriveway | east, z −41.5…−37.5 (the farm road) | Scrap heap and farmyard. The farmers' car comes in here in the ending (Step 11) |
| GapEast | east, z −20…−17 | Woodlot and the crop field's north-east corner |
The signposts of the three gaps that were in the removed south and west fence (SignSouthEast,
SignSouthWest, SignWest) still stand. Since #20, SignSouthEast and SignSouthWest stand inside the
map, near the old south edge (z ≈ 13.8).
## Travel times
Scarecrow at run speed (5 m/s). Path lengths come from the navigation grid with the scarecrow's
radius (0.4 m), from zone center to zone center. The Animal Pen's center is inside the pen, so
routes to it go through the gate.
| From \ to | Crop Field | Lettuce Field | Corn Field | Supply Shed | Work Area | Animal Pen | Woodlot | Scrap Heap | Haystacks |
|---|---|---|---|---|---|---|---|---|---|
| **Crop Field** | — | 8.5 s | 5.9 s | 7.2 s | 4.4 s | 6.8 s | 5.9 s | 7.1 s | 8.0 s |
| **Lettuce Field** | 8.5 s | — | 6.0 s | 9.0 s | 12.5 s | 6.4 s | 14.2 s | 15.4 s | 15.5 s |
| **Corn Field** | 5.9 s | 6.0 s | — | 11.0 s | 10.1 s | 8.9 s | 11.8 s | 13.0 s | 13.7 s |
| **Supply Shed** | 7.2 s | 9.0 s | 11.0 s | — | 6.9 s | 2.9 s | 9.7 s | 9.1 s | 8.3 s |
| **Work Area** | 4.4 s | 12.5 s | 10.1 s | 6.9 s | — | 8.0 s | 3.0 s | 3.2 s | 3.7 s |
| **Animal Pen** | 6.8 s | 6.4 s | 8.9 s | 2.9 s | 8.0 s | — | 10.8 s | 10.3 s | 9.4 s |
| **Woodlot** | 5.9 s | 14.2 s | 11.8 s | 9.7 s | 3.0 s | 10.8 s | — | 3.5 s | 5.3 s |
| **Scrap Heap** | 7.1 s | 15.4 s | 13.0 s | 9.1 s | 3.2 s | 10.3 s | 3.5 s | — | 2.3 s |
| **Haystacks** | 8.0 s | 15.5 s | 13.7 s | 8.3 s | 3.7 s | 9.4 s | 5.3 s | 2.3 s | — |
- **The rule:** no key area more than 12 s from another. Among the original zones the longest
trip is 10.8 s (Animal Pen ↔ Woodlot).
- **The later fields** at the map's south end are farther out: up to 15.5 s (Lettuce Field ↔
Haystacks). `test_farm_layout` bounds them at 16 s.
- **The defended fronts:** the sunflower field in the east, and the pen and shed in the west, sit
6–7 s apart. Holding one leaves the other exposed. From night 2 the lettuce field joins them at
the south-west end (6.4 s from the pen), and from night 4 the corn field at the south-east end
(5.9 s from the sunflower field, 6.0 s from the lettuce).
- **Gathering** is in the north, so a day of gathering pulls the scarecrow away from every front.
Ground-enemy path from the middle of each side of the farm's edge (3 m out) to the nearest edge of
each zone, in meters (enemy radius 0.35 m). Enemies arrive anywhere along the edge, so these are
samples, not routes everyone takes; arriving behind the north fence means walking round to a gap.
| Zone | North | East | South | West |
|---|---|---|---|---|
| Crop Field | 35 | 16 | 27 | 30 |
| Lettuce Field | 76 | 67 | 17 | 29 |
| Corn Field | 78 | 37 | 11 | 50 |
| Supply Shed | 31 | 54 | 56 | 14 |
| Work Area | 33 | 32 | 63 | 48 |
| Animal Pen (inside) | 46 | 61 | 45 | 6 |
| Woodlot | 44 | 19 | 68 | 60 |
| Scrap Heap | 30 | 36 | 76 | 54 |
| Haystacks | 11 | 47 | 75 | 47 |
Since #20 the side middles are further south: the east and west ones at z −5 (they were at
z −15), the south one at z 38. The east one is behind the east fence, so enemies arriving there
walk round to a gap or the fence's south end first. Further south on the east side (z 18…38),
arrivals stand behind the old farm's outer fence and walk round its north end (z ≈ 18).
## Navigation
`FarmNavigation` (`game/scripts/farm_navigation.gd`) rasterizes the farm's own collision into a
0.5 m occupancy grid:
- Every StaticBody3D shape on layer 1 counts, except walkable trimesh terrain and anything below
0.35 m.
- Obstacles are inflated by the mover's radius.
- Distance fields use octile Dijkstra with no corner cutting.
For enemies: the playable area plus a 5 m margin is 25,844 cells (20,164 before #20 extended the
map). 367 shapes are rasterized, and the grid builds in about 27 ms (headless, editor binary).
Because the grid comes from the same collision the player walks against, physics and navigation
can't drift apart. Step 3 adds flow fields toward the crop plots and the farm's edge on top of it.
A flow-field rebuild after placing a fence (escape, pen, 3 shed piles, fence breakers; 2,000 cells
per tick) takes about 200 ms of work over 85 ticks. Before #20 it was about 150 ms over 64 ticks.
Its largest slice stays about 3 ms.
## What changed from the old farm
- **Removed:**
- 1,122 plants in the three fields outside the map (their bare soil stays as scenery)
- 60 plants where the walkways run
- the north-west field's soil tile
- 29 segments of the old inner east fence that would have doubled the new perimeter
- **Moved:** the hay stack from beyond the north fence into the farmyard (Haystacks).
- **#20:** the map grew 20 m south to take in the bare plowed soil there. The lettuce/cabbage and
corn fields (from #13, first placed on the grass at z 2…12) moved onto that soil, with their own
plants instead of sunflowers. The South Fields' hay moved south of the new edge.
- **Collision:**
- `build_prop_collision.gd` generated collision for the newly placed prop types.
- Animals get none: they are moving entities (`AnimalSystem`).
- Step 8 removed the pen's propped-open gate panel (`fence_018`). The opening is shut by a
gate structure instead: `GameConfig.start_structures` puts it at (4, −6), turned to run north
to south. It can be broken, repaired, or rebuilt like any gate.
- **Rendering cost:**
| View | Draw calls before | Draw calls after |
|---|---|---|
| Game camera at the start | 1,270 | 304 |
| Whole farm, top-down | 3,621 | 1,504 |
| Over the crop field | — | 649 |
The plants are cheap enough as ordinary nodes, so the crop field stays as instanced prefabs
rather than a MultiMesh.
## Editing the layout
- Move or resize zones and props in the editor. After placing a **new prefab type**, re-run
`game/tools/build_prop_collision.gd` with the editor closed.
- Run `godot --headless --path . --script res://game/tests/run_tests.gd -- --suite=test_farm_layout`
to check the result: zones, fence integrity, reachability, and travel times. It prints the
tables above.
## The farmers' return (Step 11)
`FarmersReturn` (`game/scripts/farmers_return.gd`) uses fixed points on this map:
- **The car's route:** the station wagon (`car_002`) comes north up the road east of the fence
(x 52), turns in at GapDriveway (z ≈ −39.5), and runs west along the yard road. It turns south
past the wagon and parks at (32.8, −29.5), facing south.
- **The farmers:** they get out on both sides of the car and walk to the porch steps on the
house's north side (the house is x 15.8…25.2, z −29.6…−21.3; the steps are at about (19.6, −29.8)).
They stop at (18.9, −31.4) and (20.5, −31.5).
- **The scarecrow** waits at (24.6, −34.0), beside their way.
- **The yard shot** looks south at the porch from (28, 10, −45.5).
- **What to avoid:** the tractor parked east of the house (about (30, −25)) hides anything at the
house's east side from the south-east.
## The opening intro (#33)
`OpeningIntro` (`game/scripts/opening_intro.gd`) stages its shots on the same map:
- **The car** waits at the end of the ending's route, (32.8, −29.5), facing north (nose-out), and
drives the route backwards: north along the yard road, east out of GapDriveway (the horn), then
south down the road at x 52 to z 80, well past the map's south edge.
- **The farmers** come out of the front door, (19.6, −29.8). The farmer walks along z ≈ −31 to the
car's left door, (31.45, −29.95). The wife goes round the car's nose (z −33.7) to its right
door, (34.15, −29.95).
- **The departure shot** looks south over the yard from the north, (26.2, 13.5, −59), at
(26.2, 1, −30.5). The porch and the car stand side by side in the middle of the frame, clear of
the talking heads at its sides. The scrap heap's props between the camera and the yard are low
enough to look over.
- **The drive** follows behind the car until 6 m before the gap. Then the camera stops by
GapDriveway, at (46.8, 3, −43.6), and watches the car go south down the road.
- **The scarecrow's post** stands at the scarecrow's start, (3, −13). The scarecrow hangs 0.6 m up
on it, facing east over the crop field. It drops off 0.6 m in front of the post, which tips over
to its left. At the end it stands at its start again, facing north.
- **The UFO** comes from (125, 62, −150), bends over (70, 40, −40), and stops over the scarecrow at
(5, 19, −13). The part lands 0.8 m in front of the scarecrow. After the flash the UFO backs off to
(26, 15, −16), then leaves up and away to the east-north-east.
- **The night shots:** the flight and the wobble look up from the south-west, low, at
(−9, 1.5, 19), far enough off to see the saucer from the side. The drop and the flash look at
the scarecrow from the east (the barn behind it). The uh-oh and the escape look over the
scarecrow's right shoulder from behind it.
- **What to avoid:** the woodlot's trees block any view of the yard from the east, and the pen
(x −10…4, z −11…−1) is right under low cameras south-west of the scarecrow.
## Outside the fence
The scarecrow can leave through the fence's gaps or across the open south and west sides. The invisible walls (`Zones/Perimeter/PlayerBounds`)
now stand on the old farm's outer fences, not on the farm's own fence: x −27.6…54.8, z −59.6…47
(`FarmZones.roam`). Building, the enemies' navigation grid, and the night stay inside the fence
(`FarmZones.playable`).
Four outside zones (`FarmZone.outside`) hold more to gather. Every point there yields 3 per charge.
| Zone | Rectangle center, size | Points | Nearest gaps |
|---|---|---|---|
| North Grove (wood) | (12, −52), 16 × 12 | GroveDeadTree, GroveSnag, GroveDeadfall (dead trees, 3 charges), GroveLogs (log pile, 3) | GapNorth |
| Old Hangar (scrap) | (38, −53), 18 × 13 | HangarWreck (old SUV, 4), HangarBarrels (3), HangarCart (3) | GapNorth, GapDriveway |
| East Road (scrap) | (51.5, −15), 6 × 14 | RoadsideCar (the abandoned red car, moved in from `Level/`, 4), RoadsideBarrels (3) | GapEast |
| South Fields (straw) | (9.5, 41), 66 × 10 | FieldStackWest (−14, 41.5), FieldStackEast (36, 41.5) (4-bale stacks, 4), FieldBaleWest (−3, 42), FieldBaleEast (21, 41) (round bales, 3) | none: the south side is open |
`FarmZones.zone(kind)` only ever returns the farm's own zone, and `zones()` lists only the farm's.
`outside_zones()` lists these, and `zone_at()` finds both.
**The South Fields** (#20) are the strip of plowed soil between the map's south edge (z 35) and the
old farm's south fence (z ≈ 46.4). Their hay rests on the soil there, south of the later crop
fields and clear of the enemies' arrival line (z 38).
**Placing outside points:** the North Grove sits east of the tall barn on purpose. Behind the barn
(x < 9), the game camera can't see the scarecrow. The semi-trucks west of the farm are beyond the
old west fence (x ≈ −28.5), so they're out of reach.