My _ready function looks like:
func _ready():
while true:
yield(_execute_state(), "completed")
_execute_state
function waits for timers so one average call takes like 3 seconds. It matches the state of the game object to an enum and does some stuff like animating a laser pointed to player, lock target shoot.
But in between all of this the player can fire bullets to the game object, eventually killing it. So, when that happens I want _execute_state
to leave everything (firing bullets with delay, moving laser, etc.) and play the die animation instead. But I don't know how! How to stop a function from executing whatever it is doing?