Merge task #24: nights by count, per-night enemy speed and HP, F3 night jump

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 16:05:39 -04:00
commit f5bfdc4bef
9 changed files with 259 additions and 22 deletions

View file

@ -29,11 +29,8 @@ extends Node
const SCARECROW_RADIUS := 0.4
const HUNT_INTERVAL := 0.4
const NIGHT_PLANS: Array[String] = [
"res://game/resources/nights/night_1.tres", "res://game/resources/nights/night_2.tres",
"res://game/resources/nights/night_3.tres", "res://game/resources/nights/night_4.tres",
"res://game/resources/nights/night_5.tres",
]
## Night n's plan file (night_plan_path), for n in 1..GameConfig.campaign_nights.
const NIGHT_PLAN_PATH := "res://game/resources/nights/night_%d.tres"
@export var campaign: CampaignController
@export var zones: FarmZones
@ -116,6 +113,28 @@ var _rebuild_ticks: int = 0
var _goop_rng := RandomNumberGenerator.new()
## Where night n's plan lives: game/resources/nights/night_<n>.tres.
static func night_plan_path(n: int) -> String:
return NIGHT_PLAN_PATH % n
## The plans of nights 1..nights, by night_plan_path. A missing (or unreadable) file is an error,
## and that night plays the last plan that loaded (as WaveDirector.plan_for does past the end).
static func load_night_plans(nights: int) -> Array[NightPlan]:
var plans: Array[NightPlan] = []
var last: NightPlan = null
for n in range(1, nights + 1):
var path := night_plan_path(n)
var plan: NightPlan = load(path) as NightPlan if ResourceLoader.exists(path) else null
if plan == null:
push_error("Night %d has no plan at %s: it plays %s" % [n, path, "night %d's" % (n - 1) if last != null else "none"])
plan = last
else:
last = plan
plans.append(plan)
return plans
func _ready() -> void:
var t0 := Time.get_ticks_msec()
config = campaign.config
@ -240,10 +259,7 @@ func _ready() -> void:
waves = WaveDirector.new()
waves.name = "Waves"
add_child(waves)
var plans: Array[NightPlan] = []
for path in NIGHT_PLANS:
plans.append(load(path) as NightPlan)
waves.setup(campaign, enemies, zones, plans)
waves.setup(campaign, enemies, zones, load_night_plans(config.campaign_nights))
for c in _goals["escape"]:
if animal_field[c] < FarmNavigation.UNREACHABLE: # not shut in by the props around it
waves.ground_spawns.append(nav.cell_center(c))