Say I want to script an enemy AI's behavior with coroutines using await and timers, i.e. something like this
func _ready():
var coroutine = await AI()
func AI():
while true:
# crouch for 1 second
animator.play("crouch")
await get_tree().create_timer(1).timeout
# jump and wait for landing
animator.play("jump")
jump()
await landed
# repeat cycle
Is there a way to cancel the coroutine after it's started? i.e., if the entity died, I would want to immediately interrupt the coroutine and play a death animation.