151 lines
8.1 KiB
Markdown
151 lines
8.1 KiB
Markdown
# 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 × 60 m**, x −13…47 and z −45…15 (`FarmZones.playable`). The rest of the
|
||
old farm is out-of-bounds scenery.
|
||
- **Perimeter:** a wooden fence (`fence_005`, 101 segments) with **6 gaps**. Ground enemies enter
|
||
and escape through the gaps. Crows (Step 9) fly over the fence.
|
||
- **Scarecrow bounds:** invisible walls on the fence lines (`Zones/Perimeter/PlayerBounds`, physics
|
||
layer 3 `player_bounds`). Only the scarecrow collides with them (its mask is 1 + 3), so the
|
||
scarecrow can step into a gap but not leave the farm. 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,-15 --size=66 --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. The HUD banner (`ZoneBanner`) shows the
|
||
name when the scarecrow walks in.
|
||
|
||
| 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 |
|
||
| Supply Shed | −6…8, −24…−14 | The red barn's south doors and the apron in front of them, with stock piles: crates and sacks (west of the doors), logs, hay, and barrels (east of the doors) | Stored materials; ground thieves' target (Step 8) |
|
||
| Work Area | 8…14, −24…−15 | Tool table, workbench, chair, bucket, between the barn and the house | Crafting, repairs, and upgrades |
|
||
| Animal Pen | −10…4, −11…−1 | Brown paddock fence, gate opening on the east side (panel swung open), henhouse, 4 chickens, 2 pigs, 2 sheep | Livestock (Step 8). Enemies can only reach the inside through 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 middle and south-west of the map (x −13…14, z −1…15) are deliberately open ground for
|
||
building defenses.
|
||
|
||
### 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 |
|
||
|
||
## Perimeter gaps and approach directions
|
||
|
||
Each gap is 3 m wide (the driveway is 4 m) and marked inside by a signpost. A `FarmMarker` (kind
|
||
GAP) sits 3 m outside each gap, where ground enemies spawn and escape.
|
||
|
||
| 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' truck uses it in the ending (Step 11) |
|
||
| GapEast | east, z −20…−17 | Woodlot and the crop field's north-east corner |
|
||
| GapSouthEast | south, x 29.5…32.5 | Crop field, south side |
|
||
| GapSouthWest | south, x −5.5…−2.5 | Open south-west ground, pen (south side) |
|
||
| GapWest | west, z −7.5…−4.5 | Pen's west fence: enemies must go round it to the gate |
|
||
|
||
Crow approach markers (kind CROW, about 8 m outside the fence): CrowNorth (17, −53),
|
||
CrowEast (55, −5), CrowSouth (17, 23), CrowWest (−21, −15).
|
||
|
||
## 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 | Supply Shed | Work Area | Animal Pen | Woodlot | Scrap Heap | Haystacks |
|
||
|---|---|---|---|---|---|---|---|
|
||
| **Crop Field** | — | 7.2 s | 5.4 s | 6.8 s | 5.9 s | 7.3 s | 8.0 s |
|
||
| **Supply Shed** | 7.2 s | — | 2.8 s | 4.7 s | 9.7 s | 9.1 s | 8.3 s |
|
||
| **Work Area** | 5.4 s | 2.8 s | — | 4.8 s | 7.1 s | 6.6 s | 5.7 s |
|
||
| **Animal Pen** | 6.8 s | 4.7 s | 4.8 s | — | 10.8 s | 11.0 s | 10.4 s |
|
||
| **Woodlot** | 5.9 s | 9.7 s | 7.1 s | 10.8 s | — | 3.5 s | 5.3 s |
|
||
| **Scrap Heap** | 7.3 s | 9.1 s | 6.6 s | 11.0 s | 3.5 s | — | 2.3 s |
|
||
| **Haystacks** | 8.0 s | 8.3 s | 5.7 s | 10.4 s | 5.3 s | 2.3 s | — |
|
||
|
||
The longest trip is 11.0 s (Animal Pen ↔ Scrap Heap). The rule is no key area more than 12 s from
|
||
another. The two defended fronts sit 6–7 s apart: the crop field in the south-east, and the pen
|
||
and shed in the west. Holding one leaves the other exposed. The gathering spots are in the north,
|
||
so a day of gathering pulls the scarecrow away from both fronts.
|
||
|
||
Ground-enemy path from each gap to the nearest edge of each zone, in meters (enemy radius 0.35 m):
|
||
|
||
| Zone | North | Driveway | East | South-east | South-west | West |
|
||
|---|---|---|---|---|---|---|
|
||
| Crop Field | 30 | 23 | 4 | 7 | 24 | 34 |
|
||
| Supply Shed | 26 | 49 | 43 | 42 | 36 | 16 |
|
||
| Work Area | 24 | 46 | 37 | 40 | 38 | 30 |
|
||
| Animal Pen (inside) | 46 | 63 | 51 | 39 | 28 | 32 |
|
||
| Woodlot | 39 | 10 | 7 | 42 | 60 | 62 |
|
||
| Scrap Heap | 26 | 14 | 24 | 52 | 63 | 56 |
|
||
| Haystacks | 6 | 32 | 35 | 57 | 62 | 49 |
|
||
|
||
## 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 20,164 cells. 423 shapes are rasterized, and
|
||
the grid builds in about 25 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 gaps on top of it.
|
||
|
||
## 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).
|
||
- **Collision:**
|
||
- `build_prop_collision.gd` generated collision for the newly placed prop types.
|
||
- Animals get none (they become moving entities in Step 8).
|
||
- The open gate (`fence_018`) has a hand-made thin box along its panel, so the pen opening stays
|
||
clear.
|
||
- **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.
|