Bees return nectar, UI stuff

This commit is contained in:
Dan Baker 2024-05-04 15:13:59 +01:00
parent 76e7ec7ec7
commit 5865778c77
12 changed files with 175 additions and 17 deletions

View file

@ -5,9 +5,6 @@ class_name BeeIdle
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")

View file

@ -0,0 +1,25 @@
extends State
class_name BeeReturning
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
@onready var target = get_tree().get_first_node_in_group("beehive")
func enter(_msg := {}):
Log.pr("I return to the hive!")
bee.animation_player.play("Flying")
func update(delta : float) -> void:
if target:
if bee.position.distance_to(target.position) > 3:
bee.velocity = (target.get_global_position() - bee.position).normalized() * bee.speed * delta
bee.move_and_collide(bee.velocity)
bee.look_at(target.position)
else:
# Deposit the nectar and return it idle state
bee.deposit_nectar()
state_transition.emit(self, "Idle")

View file

@ -5,10 +5,11 @@ class_name BeeTravelling
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
var t = 0
var return_to_hive : bool = false
func enter(_msg := {}):
Log.pr("I am on the move!")
return_to_hive = false
## Get the next target location from the bee
if bee.just_gathering:
target = bee.get_current_director() # We want to go back the way we came
@ -16,12 +17,22 @@ func enter(_msg := {}):
else:
target = bee.get_next_target()
Log.pr(bee, target)
# If we have no target, we are returning to the hive
if !target:
Log.pr("No more drones to visit, going to go back to the hive")
return_to_hive = true
bee.animation_player.play("Flying")
pass
func update(delta : float) -> void:
if return_to_hive:
state_transition.emit(self, "Returning")
return
if target:
if bee.position.distance_to(target.position) > 3:
@ -36,4 +47,3 @@ func update(delta : float) -> void:
else:
state_transition.emit(self, "Idle")
pass