extends Node2D class_name Bee @onready var fsm = $StateMachine as FiniteStateMachine @onready var drone_manager = get_tree().get_first_node_in_group("dronemanager") as DroneManager @onready var animation_player = $AnimationPlayer as AnimationPlayer @export var nectar : int = 0 @export var speed : int = 30 var latest_target_director : int = 0 # This is updated when the bee enters or exits a flower patch var in_range_of_flowers : bool = false var just_gathering : bool = false # Used to check if the bee has just been gathering to return to their previous director func _ready(): speed = randi_range(35,55) # Randomise the bee speed a bit Log.pr("I have never bee-n so ready!") Log.pr(fsm.current_state.name) func get_current_director(): return drone_manager.get_director(latest_target_director) ## Get the next target to move to ## If we have no nectar, we need to go up the director list ## If we have nectar, we need to go down the director list ## If we are at the lower director, we need to go the hive ## If we are at the highest director, we need to go to a flower func get_next_target(): if nectar == 0: Log.pr("I have no nectar") ## If there is a next directory drone, lets go to it var next_drone = drone_manager.get_next_director(latest_target_director) if next_drone: Log.pr("Next drone target", next_drone) latest_target_director = next_drone.visit_order return next_drone ## If there is no next drone, check for a collector drone var collector_drone = drone_manager.get_collector() if collector_drone: Log.pr("Collector drone target", collector_drone) return collector_drone else: Log.pr("I have nectar") ## Let's go home, we need the previous director drones location var previous_drone = drone_manager.get_previous_director(latest_target_director) if previous_drone: Log.pr("Previous drone target", previous_drone) latest_target_director = previous_drone.visit_order return previous_drone func deposit_nectar(): GameState.add_nectar() nectar = 0 latest_target_director = 0 just_gathering = false