Task #19: UFO model built from primitives

UFOs no longer reuse the crow's bird mesh. EnemySystem.build_ufo_mesh()
merges the mesh arrays of two CylinderMesh hull halves, a TorusMesh rim, a
hemisphere SphereMesh dome and eight small sphere lights into one ArrayMesh
(about 1.65 m across, -0.13..0.45 m about its origin), with per-part vertex
colors and (glow, metalness) in UV.

A second HordeRenderer (ufo_renderer) draws it with the new
game/resources/ufo.gdshader: albedo from COLOR, no flap, a slow spin and bob
with a per-enemy phase, chasing rim lights, and the bird shader's hit flash
(INSTANCE_CUSTOM.g) and night_glow. Both batches mirror the dense slots
(write_new, move_slot, clear), and commit_render scales each slot to nothing
in the batch that doesn't draw its type. DayNight now takes a list of enemy
materials and sets night_glow on both.

UFOs get their own arrival cue (kenney/digital/powerUp2.ogg, previously
unused) instead of the crow's caw. HordeRenderer.is_drawn() backs the new
test_roster checks: a UFO is drawn by the UFO batch only, a crow by the
bird batch only, a thief by neither, also after a swap-removal; and the
saucer's size and centering.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Forrest 2026-10-06 12:55:14 -04:00
parent 26b735d3e6
commit 9cb01f1ede
8 changed files with 264 additions and 35 deletions

View file

@ -5,8 +5,8 @@ extends Node3D
## creates it and setup() connects it to the farm's systems:
## * scarecrow: footsteps, its weapons (a pitchfork's whoosh and what it strikes, corn shots,
## a pumpkin bomb's toss and burst), hurt, fall, fear and fear ready, patching and patched
## * enemies: crow caws and thieves' / fence breakers' arrivals (from where they come in), hits
## and deaths by type
## * enemies: crow caws and thieves' / fence breakers' / UFOs' arrivals (from where they come
## in), hits and deaths by type
## * theft: grabbed, dropped, recovered, carried off (with an alarm tone), animals following
## * building: placed, refused, dismantled, hit, broken (with a breach alarm), repaired,
## automated defenses firing, traps springing, the repair hammering
@ -57,6 +57,7 @@ const CUES := {
"crow_die": {"files": ["synth/crow_squawk.wav"], "db": -2.0, "pitch": 0.1, "gap": 0.05, "max": 3},
"thief_arrive": {"files": ["kenney/rpg/creak*.ogg"], "db": 0.0, "pitch": 0.1, "gap": 0.8},
"breaker_arrive": {"files": ["kenney/impact/impactWood_heavy_000.ogg"], "db": 4.0, "pitch": 0.0, "gap": 0.8},
"ufo_arrive": {"files": ["kenney/digital/powerUp2.ogg"], "db": -3.0, "pitch": 0.06, "gap": 0.7, "max": 2},
"enemy_die": {"files": ["kenney/impact/impactPunch_heavy_00*.ogg"], "db": -3.0, "pitch": 0.1, "gap": 0.05, "max": 3},
# Theft and alerts
"grab": {"files": ["kenney/rpg/handleSmallLeather.ogg"], "db": -4.0, "pitch": 0.1, "gap": 0.1},
@ -218,8 +219,8 @@ func setup(p_sim: FarmSim) -> void:
sim.waves.arrived.connect(func(h: int, at: Vector2) -> void:
var d := sim.enemies.resolve_handle(h)
var type := sim.enemies.type[d] if d >= 0 else EnemySystem.TYPE_THIEF
# thief, crow, breaker, and a UFO (no cue of its own yet: it flies in like a crow).
var arrive_cues := ["thief_arrive", "crow_arrive", "breaker_arrive", "crow_arrive"]
# thief, crow, breaker, UFO
var arrive_cues := ["thief_arrive", "crow_arrive", "breaker_arrive", "ufo_arrive"]
play(arrive_cues[type], Vector3(at.x, 0.0, at.y)))
var kit := sim.scarecrow
kit.damaged.connect(func(hp: int) -> void: play("fall" if hp <= 0 else "hurt"))