extends Node2D

@export var map_generator : Node
@export var bunny_generator : Node

var bunnys = []
var gen_data : Dictionary
var wave : int
var in_wave_gen : bool

func _ready():
	gen_data = map_generator.generate() as Dictionary
	print("time for generation: " + str(gen_data.time))
	pass

func _process(_delta):
	if bunnys.size() == 0 and !in_wave_gen:
		in_wave_gen = true
		wave += 1
		bunnys = await bunny_generator.spawn_batched_wave(25, 0.25, gen_data.free_tiles.duplicate(), TEAM.EVIL, wave * 250, 3)
		for bunny in bunnys:
			bunny.sub_on_death(func(bunny): bunnys.erase(bunny))
			bunny.sub_on_death(func(bunny): bunny.queue_free())
		in_wave_gen = false
	pass
