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_idle.gd
Normal file
37
entities/bee/states/bee_idle.gd
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
extends State
|
||||
class_name BeeIdle
|
||||
|
||||
@export var animator : AnimationPlayer
|
||||
|
||||
@onready var bee = get_parent().get_parent() # 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, "Traveling")
|
||||
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, "Traveling")
|
||||
pass
|
||||
Loading…
Add table
Add a link
Reference in a new issue