harvest/game/LAYOUT.md
2026-10-04 12:07:36 -04:00

13 KiB
Raw Blame History

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: what's left of the wooden fence (fence_005, 52 segments): the north side and the east side, with 3 gaps. The south side and most of the west side were taken out, so the farm is open ground there.
  • 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:

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 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 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, 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.

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 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 and loose animals are lost.
  • 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.

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.3 s 9.7 s 9.1 s 8.3 s
Work Area 5.4 s 2.8 s — 4.7 s 7.1 s 6.6 s 5.7 s
Animal Pen 6.8 s 4.3 s 4.7 s — 10.8 s 11.0 s 10.3 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.3 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 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 6 7 30
Supply Shed 31 45 36 10
Work Area 29 39 35 24
Animal Pen (inside) 51 53 30 28
Woodlot 44 9 48 56
Scrap Heap 30 26 55 50
Haystacks 11 37 55 43

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. 390 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 farm's edge 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 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.

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, 31), 66 × 30 FieldStackWest, FieldStackEast (4-bale stacks, 4), FieldBaleWest, FieldBaleEast (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 zone banner says "North Grove (outside the fence)").

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.