pub trait AssetProvider: Debug + Send + Sync {
    // Required methods
    fn as_any(&self) -> &dyn Any;
    fn as_any_mut(&mut self) -> &mut dyn Any;
    fn get_language(&self) -> Option<Language>;
    fn set_language(&mut self, language: Option<Language>);
    fn set_localizations(&mut self, localizations: Localizations);
    fn set_asset_server(&mut self, asset_server: AssetServer);
    fn update_asset_availability(
        &mut self,
        loaded_untyped_assets: &Assets<LoadedUntypedAsset>
    ) -> bool;
    fn accept_line_hints(&mut self, line_ids: &[LineId]);
    fn get_assets(&self, line: &UnderlyingYarnLine) -> LineAssets;
}
Expand description

Trait for providing assets for lines, e.g. audio files or character portraits. If the audio_assets feature is enabled, you can use the bundled [AudioAssetProvider] struct to retrieve audio files. You can also fetch assets in a similar way by using the FileExtensionAssetProvider struct.

Required Methods§

source

fn as_any(&self) -> &dyn Any

Returns the type as a [dyn Any]. Used for polymorphism. Should be implemented like this:


fn as_any(&self) -> &dyn Any {
   self
}
source

fn as_any_mut(&mut self) -> &mut dyn Any

Returns the type as a mutable [dyn Any]. Used for polymorphism. Should be implemented like this:

fn as_any_mut(&mut self) -> &mut dyn Any {
    self
}
source

fn get_language(&self) -> Option<Language>

Returns the Language that this AssetProvider is currently using. If there are no Localizations set, this returns None.

source

fn set_language(&mut self, language: Option<Language>)

Sets the Language that this AssetProvider should use. If there are Localizations available, this should only be called with Some. Since this method can be called by the user, implementors should check if the Language is available via Localizations::supports_language and panic if it isn’t.

source

fn set_localizations(&mut self, localizations: Localizations)

Sets the available Localizations.

source

fn set_asset_server(&mut self, asset_server: AssetServer)

Sets the [AssetServer] used. This is a simple clone of the one found in the Bevy ECS [World].

source

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

Returns whether the assets for all lines announced by AssetProvider::accept_line_hints are available, i.e. have been loaded and are ready to be used. This method is allowed to process already loaded assets to make them ready for delivery.

source

fn accept_line_hints(&mut self, line_ids: &[LineId])

Passes the LineIds that this AssetProvider should soon provide assets for. These are the LineIds that are contained in the current node and are not required to be actually reached.

source

fn get_assets(&self, line: &UnderlyingYarnLine) -> LineAssets

Returns the LineAssets for the given UnderlyingYarnLine. Will only be called if AssetProvider::update_asset_availability returns true, so an implementor is expected to panic if the assets are not available.

Implementors§