extends GdUnitTestSuite ## NEO-97: windup interpolation between npc-runtime polls. const NpcRuntimeHudState := preload("res://scripts/npc_runtime_hud_state.gd") static func _telegraph_snapshot(remaining: float) -> Dictionary: return { "npcInstances": [ { "npcInstanceId": "prototype_npc_elite", "state": "telegraph_windup", "activeTelegraph": { "telegraphId": "prototype_elite_slam", "windupRemainingSeconds": remaining, "archetypeKind": "elite", }, } ] } func test_display_windup_remaining_decreases_over_time() -> void: # Arrange var state: RefCounted = NpcRuntimeHudState.new() state.call("apply_snapshot", _telegraph_snapshot(2.0)) var first: float = float(state.call("display_windup_remaining", "prototype_npc_elite")) # Act for _i in 3: await get_tree().process_frame await (Engine.get_main_loop() as SceneTree).create_timer(0.1).timeout var second: float = float(state.call("display_windup_remaining", "prototype_npc_elite")) # Assert assert_that(second).is_less(first) assert_that(second).is_greater(1.85) func test_new_snapshot_reconciles_windup_anchor() -> void: # Arrange var state: RefCounted = NpcRuntimeHudState.new() state.call("apply_snapshot", _telegraph_snapshot(2.5)) await (Engine.get_main_loop() as SceneTree).create_timer(0.05).timeout # Act state.call("apply_snapshot", _telegraph_snapshot(1.8)) var remaining: float = float(state.call("display_windup_remaining", "prototype_npc_elite")) # Assert assert_that(remaining).is_less_equal(1.81) assert_that(remaining).is_greater_equal(1.79)