pub struct DialogueRunner { /* private fields */ }
Expand description

The main type to interact with the dialogue system. Created by calling either YarnProject::create_dialogue_runner or YarnProject::build_dialogue_runner.

Implementations§

source§

impl DialogueRunner

source

pub fn continue_in_next_update(&mut self) -> &mut Self

Tells the dialogue runner to try to advance the dialogue in the next update. This method must be called by the dialogue view when the user clicks on a button to show the next line.

Note that the actual advancement of the dialogue will be postponed until the following conditions are met:

source

pub fn will_continue_in_next_update(&self) -> bool

Returns whether the dialogue runner will try to advance the dialogue in the next update. This can return true multiple updates in a row if the conditions mentioned in DialogueRunner::continue_in_next_update are not yet met.

source

pub fn select_option(&mut self, option: OptionId) -> Result<&mut Self>

If the dialogue is currently waiting for the user to select an option, this method will select the option with the given id. Implies DialogueRunner::continue_in_next_update.

source

pub fn is_running(&self) -> bool

Returns whether the dialogue runner is currently running. Returns false if:

source

pub fn is_waiting_for_option_selection(&self) -> bool

Returns whether the dialogue runner is currently waiting for the user to select an option. If this is true, DialogueRunner::select_option must be called before the dialogue can continue. Calling DialogueRunner::continue_in_next_update will panic in this case.

source

pub fn run_selected_options_as_lines( &mut self, run_selected_options_as_lines: bool ) -> &mut Self

If set, every line the user selects will emit a PresentLineEvent. Defaults to false.

source

pub fn runs_selected_options_as_lines(&self) -> bool

If set, every line the user selects will emit a PresentLineEvent. Defaults to false.

source

pub fn stop(&mut self) -> &mut Self

Stops the execution of the dialogue. Any pending dialogue events will still be sent in the next update, including a DialogueCompleteEvent. After this, DialogueRunner::start_node must be called before the dialogue can be advanced again.

source

pub fn start_node(&mut self, node_name: impl AsRef<str>) -> &mut Self

Starts the dialogue at the given node. This method must be called after creation or after calling DialogueRunner::stop before the dialogue can be advanced. Implies DialogueRunner::continue_in_next_update. If the dialogue was already running, this method will panic.

See DialogueRunner::try_start_node for a fallible version of this method.

source

pub fn try_start_node( &mut self, node_name: impl AsRef<str> ) -> Result<&mut Self>

Fallible version of DialogueRunner::start_node.

source

pub fn get_tags_for_node(&self, node_name: &str) -> Option<Vec<String>>

Returns the tags for the node node_name.

The tags for a node are defined by setting the tags header in the node’s source code. This header must be a space-separated list

Returns None if the node is not present in the program.

source

pub fn node_exists(&self, node_name: &str) -> bool

Gets a value indicating whether a specified node exists in the Yarn files.

source

pub fn current_node(&self) -> Option<String>

Gets the name of the node that this Dialogue is currently executing. This is None if DialogueRunner::is_running is false.

source

pub fn variable_storage(&self) -> &dyn VariableStorage

Returns a shallow clone of the registered VariableStorage. The storage used can be overridden by calling DialogueRunnerBuilder::with_variable_storage.

source

pub fn variable_storage_mut(&mut self) -> &mut dyn VariableStorage

Returns a shallow mutable clone of the registered VariableStorage. The storage used can be overridden by calling DialogueRunnerBuilder::with_variable_storage.

source

pub fn update_line_availability( &mut self, loaded_untyped_assets: &Assets<LoadedUntypedAsset> ) -> bool

Returns whether both the text and asset providers have loaded all their lines.

source

pub fn set_language(&mut self, language: impl Into<Language>) -> &mut Self

Sets the language of both the text and asset providers. Same as calling DialogueRunner::set_text_language and DialogueRunner::set_asset_language.

source

pub fn set_text_language(&mut self, language: impl Into<Language>) -> &mut Self

Sets the language of the text provider.

source

pub fn set_asset_language(&mut self, language: impl Into<Language>) -> &mut Self

Sets the language of all asset providers. If no asset providers where added via DialogueRunnerBuilder::add_asset_provider, this will do nothing.

source

pub fn library(&self) -> &Library

Returns the library of functions that can be called from Yarn files.

source

pub fn library_mut(&mut self) -> &mut Library

Mutably returns the library of functions that can be called from Yarn files.

source

pub fn commands(&self) -> &YarnCommands

Returns the command registrations that can be called from Yarn files.

source

pub fn commands_mut(&mut self) -> &mut YarnCommands

Mutably returns the command registrations that can be called from Yarn files.

source

pub fn text_language(&self) -> Option<Language>

Returns the language used by the TextProvider. If there are no Localizations available, this will return None.

source

pub fn asset_language(&self) -> Option<Language>

Returns the language used by the AssetProviders. If there are no Localizations available, this will return None. Panics if the asset providers have different languages.

source

pub fn inner(&self) -> InnerDialogue<'_>

Returns a struct that can be used to access a portion of the underlying [Dialogue]. This is advanced functionality.

source

pub fn inner_mut(&mut self) -> InnerDialogueMut<'_>

Mutably returns a struct that can be used to access a portion of the underlying [Dialogue]. This is advanced functionality.

source

pub fn text_provider(&self) -> &dyn TextProvider

Returns the registered TextProvider. By default, this is a StringsFileTextProvider.

source

pub fn asset_provider<T: 'static>(&self) -> Option<&T>

Returns the registered AssetProvider of the given type if it was previously registered with DialogueRunnerBuilder::add_asset_provider.

source

pub fn asset_providers(&self) -> impl Iterator<Item = &dyn AssetProvider>

Iterates over all registered AssetProviders.

Trait Implementations§

source§

impl Component for DialogueRunner
where Self: Send + Sync + 'static,

§

type Storage = TableStorage

A marker type indicating the storage type used for this component. This must be either [TableStorage] or [SparseStorage].
source§

impl Debug for DialogueRunner

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyExt for T
where T: Any + ?Sized,

§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<C> Bundle for C
where C: Component,

§

fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId) )

§

unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
where F: for<'a> FnMut(&'a mut T) -> OwningPtr<'a>,

§

impl<T, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

§

fn coerce_box_to(self: Box<X>) -> Box<T>

§

fn coerce_ref_to(&self) -> &T

§

fn coerce_mut_to(&mut self) -> &mut T

§

impl<T> Downcast for T
where T: 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.
§

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.
§

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.
§

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.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
§

impl<C> DynamicBundle for C
where C: Component,

§

fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

§

impl<T> Settings for T
where T: 'static + Send + Sync,