Is your feature request related to a problem? Please describe.
currently, async methods that return a YarnTask do not allow a caller to provide an optional CancellationToken, e.g.
// DialogueRunner.cs
public async YarnTask StartDialogue(string nodeName)
{
// ... removed code for brevity
dialogueCancellationSource?.Dispose();
dialogueCompletionSource = new YarnTaskCompletionSource();
dialogueCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(this.destroyCancellationToken);
// ... removed code for brevity
because of this, managing cancellation is completely up to the caller, and figuring out how to go about cancellation beyond destroying the respective GameObject is also up to the caller, e.g.
await using CancellationTokenRegistration registration = cancellationToken.Register(
() =>
{
if (_runner.IsDialogueRunning)
_runner.Stop();
}
);
await _runner.StartDialogue(_encounter.DialogueConfig.StartNode);
await _runner.DialogueTask;
Describe the solution you'd like
accept an optional CancellationToken parameter, e.g.
// DialogueRunner.cs
public async YarnTask StartDialogue(string nodeName, CancellationToken cancellationToken = default)
{
// ... removed code for brevity
dialogueCancellationSource?.Dispose();
dialogueCompletionSource = new YarnTaskCompletionSource();
dialogueCancellationSource = CancellationTokenSource.CreateLinkedTokenSource(this.destroyCancellationToken, cancellationToken);
// ... removed code for brevity
Add tags
Is your feature request related to a problem? Please describe.
currently, async methods that return a YarnTask do not allow a caller to provide an optional CancellationToken, e.g.
because of this, managing cancellation is completely up to the caller, and figuring out how to go about cancellation beyond destroying the respective GameObject is also up to the caller, e.g.
Describe the solution you'd like
accept an optional CancellationToken parameter, e.g.
Add tags