YarnCancellationToken
Token for signalling cancellation to async presenters.
class_name YarnCancellationToken
extends RefCountedInherits from RefCounted
#Nested Types
- CancellationMode enum
#Properties
#cancellation_mode
var cancellation_mode: intType int
#is_cancelled
var is_cancelled: boolType bool
#is_hurry_up_requested
var is_hurry_up_requested: bool = falseType bool
#is_next_content_requested
var is_next_content_requested: bool = falseType bool
#Signals
#cancellation_requested
signal cancellation_requested(mode: int)Parameters
modeint
#hurry_up_requested
signal hurry_up_requested()#next_content_requested
signal next_content_requested()#Methods
#escalate_to_next_content()
func escalate_to_next_content() -> void#request_hurry_up()
func request_hurry_up() -> void#request_next_content()
func request_next_content() -> void#should_hurry()
func should_hurry() -> boolReturns bool
#should_skip()
func should_skip() -> boolReturns bool
#wait_for_any_cancellation()
func wait_for_any_cancellation() -> intReturns int
#wait_for_cancellation(float)
Returns the cancellation mode, or NONE if timed out. Tokens are single-use.
func wait_for_cancellation(timeout: float = 0.0) -> intParameters
timeoutfloat
Returns int
#wait_for_next_content()
Resumes when next content is requested, or immediately if it already has been. This is the core of the coroutine-style presenter contract:
func run_line(line: YarnLine, token: YarnCancellationToken = null):
label.text = line.text
await token.wait_for_next_content()
label.text = ""Once this resumes, you are promising to finish promptly and return: the runner holds the line open until every presenter's run_line has actually returned. Nothing enforces the promise, so a presenter that keeps running holds up the whole dialogue.func wait_for_next_content() -> voidGenerated from Yarn Spinner for Godot GDScript 3.3.