extends Node2D signal enemy_defeat @export var common_parent: Node2D @export var path_follow: PathFollow2D @export var target: PackedScene @export var common_target: Node2D @export var respawn_timer: Timer @export var respawn_duration = 2.0 @export var respawn_multiplier = 0.25 func spawn(): var instance = target.instantiate() # Randomize path_follow.progress_ratio = randi() instance.position = path_follow.position var target_scale = randf_range(0.2, 0.95) instance.scale = Vector2(target_scale, target_scale) instance.speed = randi_range(800, 1400) instance.target = common_target instance.connect("enemy_defeat", _on_enemy_defeat) # Add into common parent common_parent.add_child(instance) func _on_wave_finished(): for child in common_parent.get_children(): if not child is Timer: child.queue_free() respawn_timer.stop() func _on_wave_started(count): var additional = respawn_multiplier * (count - 1) respawn_timer.wait_time = respawn_duration - additional respawn_timer.start() func _on_enemy_defeat(): enemy_defeat.emit()