Animate pixel unit idle stances

This commit is contained in:
2026-06-19 19:59:08 +09:00
parent 36001c8b2f
commit 8cb611ac1a
3 changed files with 98 additions and 13 deletions

View File

@@ -1447,8 +1447,11 @@ func _check_pixel_unit_helpers(failures: Array[String]) -> void:
for method_name in [
"_draw_pixel_unit_sprite",
"_pixel_unit_sprite_profile",
"_unit_idle_phase",
"_unit_idle_bob",
"_unit_idle_step",
"_unit_idle_intensity",
"_should_animate_unit_idle",
"_draw_pixel_shield",
"_draw_pixel_spear",
"_draw_pixel_bow",
@@ -1469,6 +1472,7 @@ func _check_pixel_unit_helpers(failures: Array[String]) -> void:
failures.append("missing pixel-map unit helper: %s" % method_name)
_check_pixel_unit_profiles(scene, failures)
_check_pixel_unit_class_labels(scene, failures)
_check_pixel_unit_idle_state(scene, failures)
scene.free()
@@ -1528,3 +1532,56 @@ func _check_pixel_unit_class_labels(scene, failures: Array[String]) -> void:
var label := str(scene._unit_class_abbrev({"class_id": class_id}))
if label != str(expected_labels[class_id]):
failures.append("pixel unit class badge should use Hangul label for %s: %s" % [class_id, label])
func _check_pixel_unit_idle_state(scene, failures: Array[String]) -> void:
if not scene.state.load_battle("res://data/scenarios/001_yellow_turbans.json"):
failures.append("could not load opening battle for pixel idle state helpers")
return
var cao_cao: Dictionary = scene.state.get_unit("cao_cao")
var base_phase: float = scene._unit_idle_phase(cao_cao)
scene._process(0.35)
if absf(scene._unit_idle_phase(cao_cao) - base_phase) > 0.001:
failures.append("pixel idle phase should not advance before battle starts")
scene.battle_started = true
scene.state.battle_status = BattleStateScript.STATUS_ACTIVE
scene._process(0.35)
if scene.unit_idle_time < 0.34:
failures.append("pixel idle clock should advance during active battle: %.3f" % scene.unit_idle_time)
var active_phase: float = scene._unit_idle_phase(cao_cao)
if active_phase <= base_phase:
failures.append("pixel idle phase should advance from scene idle clock")
var expected_phase_delta := 0.35 * BattleSceneScript.UNIT_IDLE_PHASE_SPEED
if absf((active_phase - base_phase) - expected_phase_delta) > 0.01:
failures.append("pixel idle phase should advance by the scene clock speed: %.3f vs %.3f" % [active_phase - base_phase, expected_phase_delta])
if not scene._should_animate_unit_idle():
failures.append("pixel idle animation should be active during player battle control")
var base_intensity: float = scene._unit_idle_intensity(cao_cao)
scene.state.selected_unit_id = "cao_cao"
var selected_intensity: float = scene._unit_idle_intensity(cao_cao)
if selected_intensity <= base_intensity:
failures.append("selected active unit should idle with a livelier stance")
cao_cao["acted"] = true
var acted_intensity: float = scene._unit_idle_intensity(cao_cao)
if acted_intensity >= base_intensity:
failures.append("acted unit idle should settle below active stance")
cao_cao["acted"] = false
cao_cao["hp"] = maxi(1, int(cao_cao.get("max_hp", 1)) / 4)
var wounded_intensity: float = scene._unit_idle_intensity(cao_cao)
if wounded_intensity >= base_intensity:
failures.append("low-HP unit idle should be subdued")
if scene._unit_idle_step("infantry", 0.25, acted_intensity) != 0.0:
failures.append("settled acted unit should not keep marching feet")
scene.dialogue_panel = PanelContainer.new()
scene.dialogue_panel.visible = true
if scene._should_animate_unit_idle():
failures.append("pixel idle animation should pause behind dialogue")
var paused_idle_time: float = scene.unit_idle_time
scene._process(0.35)
if absf(scene.unit_idle_time - paused_idle_time) > 0.001:
failures.append("pixel idle clock should not advance while dialogue is visible")
scene.dialogue_panel.free()
scene.dialogue_panel = null