flame-engine / flame-engine/flame
improvement(flame_jenny): Allow DialogueRunner to be cancelled
- Dominant language
- Dart
- Stars
- 10.8k
- Forks
- 1k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 21
Description
# What could be improved
A method to cleanly cancel an in-progress DialogueRunner. e.g. `DialogRunner.cancelDialogue`.
The `cancelDialogue` method should still trigger the proper DialogueView methods. For example `onNodeComplete` and `onDialogueComplete` - _or_ - a new method could be introduced to DialogueView called `onDialogueCancel`. Cancelling should also still complete the future returned by `startDialogue`.
Thoughts on approach?
# Why should this be improved
Suddenly cancelling a dialogue outside of normal flow might be necessary, for example, if the user exits to menu. It could also happen if there are NPC dialogues happening that need to be cancelled when the player leaves the scene. There are many other cases, too.
It doesn't seem possible to do this currently, unless I just haven't found it yet? According to the comments, the method called `jumpToNode` apparently would do this if called with a `null` node. However, this is an internal method and not accessible outside of the runner.
# Any risks?
Since this would be a new method, the risks are lower. The risks are that the user would need to account for an abrupt cancel in the code and could not rely on the standard dialog flow always completing. For example, there could be a risk that `onLineStart` is immediately followed with `onDialogueCancel`, and the developer would need to account for it.
# More information
I would be interested in contributing this improvement, but I would like guidance from the original developer(s) on the best way to approach this.
Contributor guide
Assessment
This issue has not been assessed yet.