extends Node2D

@export var enemies: Array[PackedScene]
@export var num_circles: int = 3
@export var enemies_per_circle: int = 8
@export var radius_step: float = 100.0
@export var initial_radius: float = 150.0

func _ready() -> void:
	spawn_concentric_horde()

func spawn_concentric_horde() -> void:
	for i in range(num_circles):
		var current_radius = initial_radius + (i * radius_step)
		
		for j in range(enemies_per_circle):
			spawn_enemy_at_random_angle(current_radius)

func spawn_enemy_at_random_angle(radius: float) -> void:
	var random_angle = randf_range(0, 2 * PI)

	var spawn_pos = Vector2(
		radius * cos(random_angle),
		radius * sin(random_angle)
	)

	var idx1 = randi() % len(enemies)
	var idx2 = randi() % len(enemies)
	var idx = min(idx1, idx2)
	print(idx)
	var enemy_instance = enemies[idx].instantiate()
	add_child(enemy_instance)
	
	enemy_instance.position = spawn_pos
