pub struct DialoguePlayer {
pub tree: DialogueTree,
pub current_node: Option<String>,
pub typewriter: Option<TypewriterState>,
pub state: DialogueState,
pub flags: HashMap<String, bool>,
pub history: Vec<String>,
pub chars_per_sec: f32,
pub choices: Vec<Choice>,
pub selected_choice: usize,
/* private fields */
}Expand description
Drives a DialogueTree.
Fields§
§tree: DialogueTree§current_node: Option<String>§typewriter: Option<TypewriterState>§state: DialogueState§flags: HashMap<String, bool>§history: Vec<String>§chars_per_sec: f32§choices: Vec<Choice>Available choices (after typewriter completes on a Choice node).
selected_choice: usizeImplementations§
Source§impl DialoguePlayer
impl DialoguePlayer
pub fn new(tree: DialogueTree) -> Self
pub fn with_speed(self, chars_per_sec: f32) -> Self
pub fn is_finished(&self) -> bool
pub fn is_typing(&self) -> bool
Sourcepub fn visible_text(&self) -> &str
pub fn visible_text(&self) -> &str
Current visible text (typewriter output).
Sourcepub fn current(&self) -> Option<&DialogueNode>
pub fn current(&self) -> Option<&DialogueNode>
The current node (for speaker/portrait/emotion access).
Sourcepub fn tick(&mut self, dt: f32) -> Option<DialogueEvent>
pub fn tick(&mut self, dt: f32) -> Option<DialogueEvent>
Advance by dt. Returns an event if something notable happened.
Sourcepub fn advance(&mut self) -> Option<DialogueEvent>
pub fn advance(&mut self) -> Option<DialogueEvent>
Player pressed “advance” (confirm/space).
Sourcepub fn select_prev(&mut self)
pub fn select_prev(&mut self)
Move selection up/down in choice list.
pub fn select_next(&mut self)
pub fn select(&mut self, idx: usize)
pub fn get_flag(&self, f: &str) -> bool
pub fn set_flag(&mut self, f: impl Into<String>, v: bool)
Auto Trait Implementations§
impl Freeze for DialoguePlayer
impl RefUnwindSafe for DialoguePlayer
impl Send for DialoguePlayer
impl Sync for DialoguePlayer
impl Unpin for DialoguePlayer
impl UnsafeUnpin for DialoguePlayer
impl UnwindSafe for DialoguePlayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.