Merge task #21: animals roam the whole farm, never lost on their own

Loose animals roam the playable map day and night; dropped, leash-broken
and open-pen animals become LOOSE instead of running for the edge. Only
an Alien carrying one off the map loses it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 13:15:24 -04:00
commit 9d26f29299
8 changed files with 379 additions and 226 deletions

View file

@ -6,7 +6,7 @@ extends Node
## repair, shed drop-off) -> weapons (recharge, switching) -> aim and attack (pitchfork, corn
## shooter, pumpkin bombs) -> enemies (behavior, steering, motion, collision, traps) -> enemy
## melee -> automated defenses -> shots -> pumpkin bombs -> recovery by touch -> animals
## (wander, stray, follow) -> night arrivals (WaveDirector) -> deferred enemy removals ->
## (wander, roam, follow) -> night arrivals (WaveDirector) -> deferred enemy removals ->
## flow-field rebuild slice -> render upload -> campaign phase timers and outcome.
## Whenever the structures change (built, broken, dismantled), the flow fields are rebuilt as
## FieldJobs in slices of flow_slice_cells per tick; thieves keep using the old fields until the
@ -16,8 +16,8 @@ extends Node
## escape: WaveDirector.ground_spawns are the edge cells with a route in), owns the combat and theft systems,
## and applies the phase rules: thieves arrive only at night (the night's NightPlan, run by
## WaveDirector), sunrise makes them retreat (carriers keep running), the end of the dawn grace
## sends the rest off the farm with whatever they carry, returns dropped loot (and loose animals)
## home, and regrows the gather points, and every new morning (also after a retry) resets the
## sends the rest off the farm with whatever they carry, returns dropped loot (and the animals
## still following the scarecrow) home, and regrows the gather points, and every new morning (also after a retry) resets the
## theft state from the farm state. DayNight lights the phases; PhaseHud, AssetHud, ReviewPanel,
## and the other HUD parts show them. Co-op (CoopSession): a second scarecrow (add_partner) is
## simulated alongside the first, and on the partner's machine the farm is a replica: nothing is
@ -185,7 +185,7 @@ func _ready() -> void:
loot.animals = animals
loot.shed_stock = shed_stock
loot.setup(campaign, zones.crop_units(), enemies, AnimalSystem.find_animals(pen_zone).size())
animals.setup(campaign, pen_zone, nav, loot, enemies, player)
animals.setup(campaign, pen_zone, nav, loot, enemies, player, zones.playable)
if animals.count != config.start_animals:
push_warning("The pen holds %d animals but GameConfig.start_animals is %d" % [animals.count, config.start_animals])
enemies.enemy_removed.connect(loot.on_enemy_removed)
@ -337,7 +337,7 @@ func _ready() -> void:
toasts.push("Breach! A %s was broken" % StructureSystem.NAMES[type].to_lower(), Color(1.0, 0.35, 0.3)))
animals.pen_changed.connect(func(open: bool) -> void:
if open and campaign.state.phase != CampaignController.Phase.MORNING:
toasts.push("The pen is open: animals will wander out at night", Color(1.0, 0.55, 0.35)))
toasts.push("The pen is open: at night the animals in it will get out and roam loose", Color(1.0, 0.55, 0.35)))
scarecrow.patch_denied.connect(func(missing: Dictionary) -> void:
toasts.push("Not enough straw to patch up: need %s more" % ResourceStore.describe(missing), Color(1.0, 0.8, 0.5)))
if alerts != null:
@ -802,8 +802,8 @@ func _on_phase_changed(phase: CampaignController.Phase, _previous: CampaignContr
## End of the dawn grace: whoever is still on the farm leaves (carrying their loot off), and
## loot still lying on the ground goes home (crops to their plots, sacks to the shed, loose
## animals to the pen). #13: grows crops_total for any field that just sprouted (state.night is
## loot still lying on the ground goes home (crops to their plots, sacks to the shed, animals
## still following the scarecrow to the pen; #21: loose animals stay loose). #13: grows crops_total for any field that just sprouted (state.night is
## the night that just finished; nights_survived isn't set to it until right after this signal),
## so the morning snapshot (retry, the save file) already has it right. The new field's units
## themselves flip from DORMANT to HOME in loot.sync_from_state(), at the morning that follows.