Bee State Machine
This commit is contained in:
parent
20bcab01b1
commit
752131c955
16 changed files with 467 additions and 13 deletions
37
entities/bee/states/bee_traveling.gd
Normal file
37
entities/bee/states/bee_traveling.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
extends State
|
||||
class_name BeeTraveling
|
||||
|
||||
@export var animator : AnimationPlayer
|
||||
|
||||
@export var target : Drone = null
|
||||
|
||||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
|
||||
var t = 0
|
||||
|
||||
func enter(_msg := {}):
|
||||
Log.pr("I am on the move!")
|
||||
## Get the next target location from the bee
|
||||
target = bee.get_next_target()
|
||||
|
||||
#animator.play("Idle")
|
||||
|
||||
pass
|
||||
|
||||
func update(delta : float):
|
||||
|
||||
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:
|
||||
# Bee has arrived at location, if its the hive or a collector drone do the things
|
||||
if(target.name == "CollectorDrone"):
|
||||
state_transition.emit(self, "Gathering")
|
||||
else:
|
||||
state_transition.emit(self, "Idle")
|
||||
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue