# WAIT FOR THE ANIMATION TO FINISH, then react to HOW it ended. # # Play() returns instantly; PlayAndAwait() SUSPENDS until the clip ends and # hands back a play_animation_result enum telling you the outcome. Because it # suspends, call it from a context -- here we spawn one so the # button handler itself stays non-suspending. PlayThenReact(Presser : agent) : void = if: Sequence := EmoteAnim? Character := Presser.GetFortCharacter[] Controller := Character.GetPlayAnimationController[] then: # Suspends right here until the clip completes or is interrupted. Result := Controller.PlayAndAwait(Sequence, ?PlayCount := 1.0) case (Result): play_animation_result.Completed => Print("Finished cleanly") play_animation_result.Interrupted => Print("Something interrupted it") play_animation_result.Error => Print("Playback errored")