aboutsummaryrefslogtreecommitdiff
path: root/src/actor/events.rs
blob: e24e7f3597469b5b701283a75b3be8b04a354720 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Actor-related events

use bevy::prelude::*;
use yarnspinner::{core::LineId, runtime::{Command, DialogueOption, Line, OptionId}};

/// Event called by user to progress dialogue
#[derive(Debug, Event)]
pub enum ContinueDialogueEvent {
    /// Continue to next line of dialogue for given actor entity
    Continue(Entity),
    /// Submit option selection to given actor entity
    SelectedOption { 
        /// Target actor entity
        actor: Entity,
        /// Selected option ID
        option: OptionId 
    },
}

/// Event called by plugin in response to a corresponding yarnspinner dialogue events
///
/// The user should catch these events to update UI, and never call it directly.
#[derive(Event)]
pub enum DialogueEvent {
    /// Recieved new line of dialogue
    Line {
        /// Actor entity
        actor: Entity,
        /// Line of dialogue received
        line: Line,
    },
    /// Dialogue complete
    DialogueComplete {
        /// Actor entity
        actor: Entity,
    },
    /// Encountered an option selection
    Options {
        /// Actor entity
        actor: Entity,
        /// Options to select from
        options: Vec<DialogueOption>,
    },
    /// Triggered a yarnspinner command
    Command {
        /// Actor entity
        actor: Entity,
        /// Triggered command
        command: Command,
    },
    /// Node started
    NodeStart {
        /// Actor entity
        actor: Entity,
        /// Name of started node
        name: String,
    },
    /// Node complete
    NodeComplete {
        /// Actor entity
        actor: Entity,
        /// Name of completed node
        name: String,
    },
    /// Received line hints
    LineHints {
        /// Actor entity
        actor: Entity,
        /// Lines affected
        lines: Vec<LineId>,
    },
}