extends Node func _ready() -> void: GameState.start_new_run() var game := preload("res://scenes/game/game.tscn").instantiate() add_child(game) game.set_physics_process(false) var ship := game.get_node("PlayerShip") as CharacterBody2D ship.set_physics_process(false) ship.get_node("WeaponController").set_physics_process(false) var systems := ship.get_node("ExtensionSystems") systems.set_physics_process(false) for enemy in get_tree().get_nodes_in_group("enemies"): enemy.queue_free() await get_tree().process_frame var hud := game.get_node("HUD") hud.call("_toggle_debug") var inventory := ship.get_node("ShipInventory") as ShipInventory var before := Vector3i(inventory.ammunition, inventory.irradiated_ammunition, inventory.missile_ammunition) var button := hud.get_node("HUDRoot/DebugActions/AddAmmunition") as Button button.pressed.emit() button.pressed.emit() assert(Vector3i(inventory.ammunition, inventory.irradiated_ammunition, inventory.missile_ammunition) == before + Vector3i(20, 20, 20)) systems.call("activate", 5) var drones := get_tree().get_nodes_in_group("player_combat_drones") assert(drones.size() == 3) for drone in drones: drone.set_physics_process(false) assert(drone.scale == Vector2(0.5, 0.5)) # Stationary formation converges to fixed positions in front, with no idle orbit. _step(ship, drones, 120) for drone in drones: assert(drone.global_position.distance_to(drone.call("formation_position")) < 2.0) assert((drone.global_position - ship.global_position).dot(Vector2.UP.rotated(ship.rotation)) > 60.0) # Forward flight and a turn inherit mother velocity without position snapping. ship.velocity = Vector2(0, -200) var previous_velocity: Vector2 = drones[0].get("velocity") _step(ship, drones, 1) assert((drones[0].get("velocity") as Vector2).distance_to(previous_velocity) <= 650.0 / 60.0 + 0.01) _step(ship, drones, 119) for drone in drones: assert(drone.global_position.distance_to(drone.call("formation_position")) < 12.0) ship.set("angular_velocity", 0.6) _step(ship, drones, 120, true) for drone in drones: assert(drone.global_position.distance_to(drone.call("formation_position")) < 15.0) ship.set("angular_velocity", 0.0) ship.velocity = Vector2.ZERO _step(ship, drones, 120) for drone in drones: assert(drone.global_position.distance_to(drone.call("formation_position")) < 2.0) assert((drone.get("velocity") as Vector2).length() < 3.0) print("DEBUG_AMMO_DRONE_FORMATION_TEST: PASS (debug ammo x10 repeatable, half scale, fixed forward formation, acceleration bound, moving/turning mother tracking, smooth stop)") get_tree().quit() func _step(ship: CharacterBody2D, drones: Array[Node], frames: int, turning := false) -> void: for frame in frames: if turning: ship.rotation += 0.6 / 60.0 ship.velocity = Vector2.UP.rotated(ship.rotation) * 200.0 ship.position += ship.velocity / 60.0 for drone in drones: drone.call("_physics_process", 1.0 / 60.0)