extends State
class_name BeeIdle

@export var animator : AnimationPlayer

@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works

var idle_time : float = 0.0

func _ready():
	Log.pr(bee, bee.nectar)

func enter(_msg := {}):
	Log.pr("I sit by idl-bee")
	#animator.play("Idle")
	pass
	
func update(delta : float):

	idle_time += delta

	if idle_time > 2.0:
		Log.pr("Been idle for 2 seconds, check for something to do...")
		find_something_to_do()
		idle_time = 0.0
	pass

func find_something_to_do():
	if bee.nectar > 0:
		## Bee has pollen - head home
		Log.pr(bee, "I have nectar, I should return to the hive")
		state_transition.emit(self, "Travelling")
	else:
		## Bee has no pollen - they should move to a flower
		Log.pr(bee, "I have no nectar, I should find a flower")
		state_transition.emit(self, "Travelling")
	pass
