bubbles/runtime/event.rs
1//! [`DialogueEvent`] and [`DialogueOption`] — the output types of the runner.
2
3/// An option presented to the player.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct DialogueOption {
6 /// Display text of the option.
7 pub text: String,
8 /// Whether this option is currently available (guards that evaluate to false make it unavailable).
9 pub available: bool,
10 /// Trailing `#tag` metadata.
11 pub tags: Vec<String>,
12}
13
14/// Events emitted by [`crate::Runner`] one at a time via [`crate::Runner::next_event`].
15#[non_exhaustive]
16#[derive(Debug, Clone, PartialEq)]
17pub enum DialogueEvent {
18 /// A node has started executing.
19 NodeStarted(String),
20 /// A line of dialogue ready to display.
21 Line {
22 /// Optional speaker name.
23 speaker: Option<String>,
24 /// Text with all `{expr}` fragments already substituted.
25 text: String,
26 /// Trailing `#tag` metadata.
27 tags: Vec<String>,
28 },
29 /// A set of options for the player to choose from.
30 Options(Vec<DialogueOption>),
31 /// A host command to execute.
32 Command {
33 /// Command name.
34 name: String,
35 /// Arguments with `{expr}` substituted.
36 args: Vec<String>,
37 /// Trailing tags.
38 tags: Vec<String>,
39 },
40 /// The current node has finished.
41 NodeComplete(String),
42 /// All dialogue has finished.
43 DialogueComplete,
44}