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>
This commit is contained in:
Forrest 2026-10-06 13:10:08 -04:00
parent 26b735d3e6
commit fc7c74fa32
10 changed files with 593 additions and 475 deletions

View file

@ -57,7 +57,14 @@ const BADGE_FILL := {
Category.ANIMAL: [Color(1.0, 0.62, 0.78), Color(1.0, 0.92, 0.95)],
Category.SUPPLY: [Color(0.78, 0.62, 0.4), Color(0.35, 0.8, 1.0)],
}
const TOKEN_SCENE := "res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_007.tscn"
## The token a carried or dropped crop shows, by CropUnit.crop (#20): the plant that grows in its
## field (a sunflower, a cabbage head, a corn stalk), scaled to about a meter at its largest. Any
## other crop shows a sunflower.
const CROP_TOKENS := {
"sunflower": ["res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_007.tscn", 0.6],
"lettuce": ["res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_004.tscn", 1.2],
"corn": ["res://assets/farm/ithappy/farm/prefabs/assets/plant/plant_001.tscn", 0.4],
}
const SACK_SCENE := "res://assets/farm/ithappy/farm/prefabs/assets/prop/bag_002.tscn"
const THREAT_COLORS := {
Threat.TARGETED: Color(1.0, 0.6, 0.1),
@ -140,7 +147,10 @@ func setup(p_campaign: CampaignController, units: Array[CropUnit], p_enemies: En
_outline[c] = outline_material(CATEGORY_COLORS[c])
var ring_shader := load("res://game/resources/steal_ring.gdshader") as Shader
var icon_shader := load("res://game/resources/loot_icon.gdshader") as Shader
var token_scene := load(TOKEN_SCENE) as PackedScene
var crop_of := {} # unit id -> a CROP_TOKENS key
for u in units:
crop_of[u.unit_id] = u.crop if CROP_TOKENS.has(u.crop) else "sunflower"
var token_scenes := {} # loaded once per crop: an instance doesn't keep its PackedScene alive
var sack_scene := load(SACK_SCENE) as PackedScene
for id in range(1, n):
category[id] = _category_of(id)
@ -157,8 +167,11 @@ func setup(p_campaign: CampaignController, units: Array[CropUnit], p_enemies: En
var token: Node3D = null
match category[id]:
Category.CROP:
token = token_scene.instantiate() as Node3D
token.scale = Vector3.ONE * 0.6
var crop: String = crop_of.get(id, "sunflower")
if not token_scenes.has(crop):
token_scenes[crop] = load(CROP_TOKENS[crop][0])
token = (token_scenes[crop] as PackedScene).instantiate() as Node3D
token.scale = Vector3.ONE * float(CROP_TOKENS[crop][1])
Category.SUPPLY:
token = sack_scene.instantiate() as Node3D
token.scale = Vector3.ONE * 0.85