notSpore/evolve-die-repeat/molecular/prey/nucleotide_prey_state_machi...

18 lines
602 B
GDScript

extends StateMachine
enum States {IDLE, RANDOMMOVEMENT, FEEDING, FLEEING}
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
super()
await owner.ready
func transition_to_next_state(target: int, data: Dictionary = {}) -> void:
match target:
States.IDLE: _transition_to_next_state("Idle", data)
States.RANDOMMOVEMENT: _transition_to_next_state("RandomMovement", data)
States.FEEDING: _transition_to_next_state("Feeding", data)
States.FLEEING: _transition_to_next_state("Fleeing", data)
_: push_error("Trying to transition to unknown state {target}")