harvest/game/scripts/crop_unit.gd
Forrest fc7c74fa32 Task #20: lettuce and corn fields on the south soil, map grows to 60 x 80
- farm.tscn: LettuceField moves to (-1, 0.44, 25) on the SW soil tile
  (ground_008_004) and CornField to (29, 0.31, 25) on the SE tile
  (ground_011_003), both still 10 x 10 m. Their units keep ids 31-40 /
  41-50, plots 7-10 and sprout nights 2 / 4. The sunflower children are
  replaced: lettuce rows get 8 cabbage heads each (plant_004/005), corn
  rows 10 stalks each (plant_001, scaled ~0.8). Every plant's height
  follows the soil under it (raycast), so none floats.
- South Fields (outside zone) moves to (9.5, 41), 66 x 10, between the
  new south edge (z 35) and the old south fence; its four hay points
  move there too and rest on the soil.
- FarmZones.playable: Rect2(-13, -45, 60, 80), i.e. z -45..35.
- ThiefBehavior: one rect per crop field (field_rects) instead of their
  bounding box; area_for() takes the target's position.
- LootSystem: carried/dropped crop tokens show the crop's own plant
  (CROP_TOKENS), each scene loaded once.
- Tests: test_farm_layout checks the 60 x 80 map, outside zones off the
  map, the later fields on the soil tiles with their own plants standing
  on the soil, side names for both fields, the open east side south of
  the fence, and splits the travel bound (12 s core rule, 16 s for the
  south fields). test_theft: new south edge cell, crop tokens.
  run_tests EDGE/SKY south points follow the edge. test_targets: the
  dropped animal is watched from outside the gate (the carrier now dies
  ~4 m from the west edge).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 13:10:08 -04:00

18 lines
1.1 KiB
GDScript

class_name CropUnit
extends Node3D
## One stealable crop unit: a cluster of plants (this node's children) with one ID in FarmState.
## The original crop field holds 6 plots of 5 units; each unit is one row segment of its plot.
## #13: two more fields (lettuce/cabbage, corn), each 2 plots of 5 units, sprout later in the
## campaign: dormant (hidden, unclaimable) until FarmState.nights_survived reaches sprout_night,
## then home like any other crop (LootSystem.sync_from_state derives this every morning).
@export var unit_id: int = 0
@export var plot: int = 0
## "sunflower" (the original field), "lettuce", or "corn" (#13). Cosmetic only: it picks the
## token a carried or dropped unit shows (#20, LootSystem.CROP_TOKENS), while theft rules go by
## category, not by this. The plants under the unit are the scene's (sunflowers plant_007/008,
## cabbage heads plant_004/005, corn stalks plant_001).
@export var crop: String = "sunflower"
## The night that must be survived (FarmState.nights_survived) before this unit sprouts and
## becomes stealable. 0 = already grown, in play from the first morning.
@export var sprout_night: int = 0