Merge #29: cutscene kit and roof luggage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-07 22:00:01 -04:00
commit 78ff549407
4 changed files with 773 additions and 133 deletions

View file

@ -4,8 +4,9 @@ extends RefCounted
## the simulation tick; settings apply and persist from the pause menu; Restart the night and
## Save & quit to menu put the farm back at the saved morning without touching the save; a
## damaged save can't be continued; quitting a hosted co-op game from the pause menu leaves the
## scarecrow unfrozen; the failure screen and Retry; the farmers' return and the final
## assessment; the first day's and night's tips; and the sounds hooked to the game.
## scarecrow unfrozen; the failure screen and Retry; the farmers' return (their car loaded with
## roof luggage) and the final assessment; the first day's and night's tips; and the sounds hooked
## to the game.
const P := CampaignController.Phase
const SAVE := "user://test_flow_save.json"
@ -325,6 +326,7 @@ func _ending() -> void:
r.check(c.state.phase == P.FARMERS_RETURN and not SaveGame.exists(SAVE), "the last dawn ends the vacation and deletes the save")
r.check(ending.running and ending.stage == "drive" and main.get_viewport().get_camera_3d() == ending._camera and not _hud_visible(),
"the farmers' return starts: the cutscene camera, no HUD")
_luggage(ending._car)
var horn := int(sim.audio.played.get("horn", 0))
var steps := 0
while ending.stage == "drive" and steps < 3000:
@ -367,6 +369,40 @@ func _ending() -> void:
and main.main_menu.continue_button.disabled, "Main menu after the ending: a fresh farm behind the menu, nothing to continue")
## The car comes home loaded (CutsceneKit.load_roof): a pile of luggage, straps, and a mattress
## hanging off the side, all riding on the car, with the pile on top of the car's mesh (its
## AABB) and no collision; and it sways with the driving.
func _luggage(car: Node3D) -> void:
var luggage := CutsceneKit.luggage_of(car)
var car_top := -INF
for m in car.get_children():
if m is MeshInstance3D:
car_top = maxf(car_top, ((m as MeshInstance3D).transform * (m as MeshInstance3D).get_aabb()).end.y)
var ok := luggage != null and luggage.get_parent() == car and luggage.pieces.size() >= 8 and luggage.straps.size() >= 2 \
and luggage.hanging != null and luggage.find_children("*", "CollisionObject3D", true, false).is_empty()
var low := INF
var high := -INF
if ok:
for piece in luggage.pieces:
var b := CutsceneKit.mesh_bounds(piece, car)
ok = ok and b.has_volume() and piece.get_parent() == luggage
low = minf(low, b.position.y)
high = maxf(high, b.end.y)
var hang := CutsceneKit.mesh_bounds(luggage.hanging, car)
ok = ok and hang.get_center().y > car_top - 0.1 and hang.get_center().x < CutsceneKit.roof_of(car).position.x
r.check(ok and absf(low - car_top) < 0.01 and high > car_top + 0.8,
"the car comes loaded: %d pieces on the roof from its top (%.2f m) up to %.2f m, strapped, a mattress hanging off the side"
% [luggage.pieces.size() if luggage != null else 0, car_top, high])
var swayed := false
if luggage != null:
for i in 30:
luggage.sway(DT, 1.5, -8.0) # a hard left turn, braking
swayed = luggage.lean.x > 0.02 and luggage.lean.y > 0.02 and luggage.rotation.z > 0.0
luggage.settle()
swayed = swayed and luggage.rotation == Vector3.ZERO
r.check(swayed, "it sways: forward when braking, out to the right on a left turn")
func _audio() -> void:
var audio := sim.audio
var missing: Array[String] = []