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:
parent
26b735d3e6
commit
9cb01f1ede
8 changed files with 264 additions and 35 deletions
|
|
@ -35,6 +35,7 @@ func run(r: GameTestRunner) -> void:
|
|||
_thieves(r, sim, player)
|
||||
_breakers(r, sim, player)
|
||||
_ufos(r, sim, player)
|
||||
_batches(r, sim)
|
||||
_characters(r, sim)
|
||||
_alerts(r, farm, sim, player)
|
||||
_scenarios(r, farm, sim)
|
||||
|
|
@ -280,6 +281,55 @@ func _ufos(r: GameTestRunner, sim: FarmSim, player: PlayerCharacter) -> void:
|
|||
probe.free()
|
||||
|
||||
|
||||
## Flyers are drawn by two MultiMesh batches: crows by the bird one, UFOs by their own saucer
|
||||
## (built from primitives). Each batch draws only its type, also after a swap-removal moves a UFO
|
||||
## into a crow's slot; ground enemies are in neither.
|
||||
func _batches(r: GameTestRunner, sim: FarmSim) -> void:
|
||||
var es := sim.enemies
|
||||
var birds := es.renderer
|
||||
var saucers := es.ufo_renderer
|
||||
_step(sim, 1)
|
||||
var base_birds := _drawn_count(birds, es.active_count)
|
||||
var base_saucers := _drawn_count(saucers, es.active_count)
|
||||
var crow := es.spawn(EnemySystem.TYPE_CROW, 20.0, -30.0, Vector2.UP)
|
||||
var thief := es.spawn(EnemySystem.TYPE_THIEF, 22.0, -30.0, Vector2.UP)
|
||||
var ufo := es.spawn(EnemySystem.TYPE_UFO, 24.0, -30.0, Vector2.UP)
|
||||
_step(sim, 1)
|
||||
var d_crow := es.resolve_handle(crow)
|
||||
var d_thief := es.resolve_handle(thief)
|
||||
var d_ufo := es.resolve_handle(ufo)
|
||||
r.check(d_ufo >= 0 and saucers.is_drawn(d_ufo) and not birds.is_drawn(d_ufo),
|
||||
"a UFO is drawn by the UFO batch, not the bird batch")
|
||||
r.check(d_crow >= 0 and birds.is_drawn(d_crow) and not saucers.is_drawn(d_crow), "a crow is still drawn by the bird batch, and only there")
|
||||
r.check(d_thief >= 0 and not birds.is_drawn(d_thief) and not saucers.is_drawn(d_thief), "a thief is in neither batch (its character draws it)")
|
||||
es.apply_hit_handle(crow, 99)
|
||||
_step(sim, 1)
|
||||
d_ufo = es.resolve_handle(ufo)
|
||||
r.check(d_ufo == d_crow and saucers.is_drawn(d_ufo) and not birds.is_drawn(d_ufo)
|
||||
and _drawn_count(birds, es.active_count) == base_birds and _drawn_count(saucers, es.active_count) == base_saucers + 1,
|
||||
"the UFO swapped into the dead crow's slot is still drawn as a saucer only")
|
||||
var mesh := EnemySystem.build_ufo_mesh()
|
||||
var box := mesh.get_aabb()
|
||||
var center := box.get_center()
|
||||
r.check(box.size.x > 1.4 and box.size.x < 1.8 and absf(box.size.x - box.size.z) < 0.03 and absf(center.x) < 0.01
|
||||
and absf(center.z) < 0.01 and box.position.y > -1.5 and box.end.y < 1.0
|
||||
and (mesh.surface_get_format(0) & Mesh.ARRAY_FORMAT_COLOR) != 0,
|
||||
"the saucer is round, %.2f m across, centered, from %.2f to %.2f m about its origin, and colored per part"
|
||||
% [box.size.x, box.position.y, box.end.y])
|
||||
for hh in [thief, ufo]:
|
||||
es.apply_hit_handle(hh, 99)
|
||||
_step(sim, 1)
|
||||
sim.characters._process(EnemyCharacters.CORPSE_TIME + 0.1)
|
||||
|
||||
|
||||
func _drawn_count(rend: HordeRenderer, n: int) -> int:
|
||||
var drawn := 0
|
||||
for slot in n:
|
||||
if rend.is_drawn(slot):
|
||||
drawn += 1
|
||||
return drawn
|
||||
|
||||
|
||||
## Ground enemies are drawn by pooled characters; flyers aren't.
|
||||
func _characters(r: GameTestRunner, sim: FarmSim) -> void:
|
||||
var es := sim.enemies
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue