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

@ -7,8 +7,8 @@ extends Node
## night -> sunset to night in the first NIGHTFALL seconds (the sun becomes the moon);
## dawn -> night to sunrise over the dawn grace (brightening early: by the square root).
## The scarecrow carries a lantern that lights up as it gets dark, and enemies glow faintly at
## night (thief.gdshader night_glow) so they stay readable. The current look eases toward the
## target, so phase changes never pop.
## night (night_glow in thief.gdshader and ufo.gdshader) so they stay readable. The current
## look eases toward the target, so phase changes never pop.
const NIGHTFALL := 8.0
const EASE := 2.5
@ -25,7 +25,8 @@ const SUNRISE := {"elev": 10.0, "yaw": 150.0, "color": Color(1.0, 0.72, 0.58), "
var campaign: CampaignController
var sun: DirectionalLight3D
var env: Environment
var enemy_material: ShaderMaterial
## The flyers' materials (crows, UFOs), given night_glow.
var enemy_materials: Array[ShaderMaterial] = []
## Set by FarmSim: the ground enemies' characters glow too.
var characters: EnemyCharacters
var lantern: OmniLight3D
@ -35,11 +36,11 @@ var current := DAY.duplicate()
func setup(p_campaign: CampaignController, p_sun: DirectionalLight3D, p_env: Environment, player: Node3D,
p_enemy_material: ShaderMaterial) -> void:
p_enemy_materials: Array[ShaderMaterial]) -> void:
campaign = p_campaign
sun = p_sun
env = p_env
enemy_material = p_enemy_material
enemy_materials = p_enemy_materials
env.adjustment_enabled = true
lantern = add_lantern(player)
snap()
@ -108,8 +109,9 @@ func _apply() -> void:
for l in lanterns:
if is_instance_valid(l):
l.light_energy = current["lantern"]
if enemy_material != null:
enemy_material.set_shader_parameter("night_glow", current["glow"])
for m in enemy_materials:
if m != null:
m.set_shader_parameter("night_glow", current["glow"])
if characters != null:
characters.set_night_glow(current["glow"])