extends Node2D
class_name BeeSpawner

var bee = preload("res://entities/Bee.tscn")

@onready var beehive = get_node("../Beehive")

var bee_count = 0 
var max_bees = 10
var spawn_interval = 3
var spawn_timer = 0.0

func _ready():
	Log.pr("Bee Spawner ready")

func spawn_bee():
	var bee_instance = bee.instantiate()
	add_child(bee_instance)
	bee_instance.position = beehive.global_position
	# bee_instance.connect("bee_died", self, "bee_died")

func _process(delta):
	spawn_timer += delta

	if spawn_timer > spawn_interval and bee_count < max_bees and beehive.dancer_in_range:
		spawn_bee()
		spawn_timer = 0.0
		bee_count += 1
		Log.pr("Bee count: " + str(bee_count))	
