pub struct ModloaderPlugin(/* private fields */);Expand description
This plugin adds Wasvy modding support to App
use wasvy::prelude::*;
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(ModloaderPlugin::default())
// etcLooking for next steps? See: Mods
§Examples
§Run custom schedules
In this example, Wasvy is used to load mods that affect a physics simulation.
In the host:
use wasvy::prelude::*;
#[derive(ScheduleLabel, Clone, Debug, PartialEq, Eq, Hash, Default)]
struct SimulationStart;
// The schedule must be added to the world's Schedules Resource
app.add_schedule(Schedule::new(SimulationStart));
app.add_plugins(
// We don't want mods to run systems in any other schedules
ModloaderPlugin::unscheduled()
.enable_schedule(ModSchedule::FixedUpdate)
.enable_schedule(ModSchedule::new_custom("simulation-start", SimulationStart))
);In the mod:
fn setup(){
..
app.add_systems(&Schedule::FixedUpdate, vec![..]);
app.add_systems(&Schedule::Custom("simulation-start".to_string()), vec![..]);
// This one will be ignored and throw a warning
app.add_systems(&Schedule::PreUpdate, vec![..]);
}Implementations§
Source§impl ModloaderPlugin
impl ModloaderPlugin
Sourcepub fn new(schedules: ModSchedules) -> Self
pub fn new(schedules: ModSchedules) -> Self
Creates a new modloader that will schedule mods be run during the provided Schedules
Sourcepub fn unscheduled() -> Self
pub fn unscheduled() -> Self
Creates plugin with no schedules.
This means that by default loaded mods will not run unless you enable schedules manually using ModloaderPlugin::enable_schedule
If you want wasvy to run on all schedules use ModloaderPlugin::default() or ModloaderPlugin::new
Sourcepub fn set_despawn_behaviour(
self,
despawn_behaviour: ModDespawnBehaviour,
) -> Self
pub fn set_despawn_behaviour( self, despawn_behaviour: ModDespawnBehaviour, ) -> Self
Sets the despawn behaviour for when mods are despawned (or reloaded).
The default behaviour is to despawn all entities the mod spawned. See DespawnEntities.
Sourcepub fn enable_schedule(self, schedule: ModSchedule) -> Self
pub fn enable_schedule(self, schedule: ModSchedule) -> Self
Enables a new schedule with the modloader.
When mods add a system to this schedule, then wasvy will automatically add them to the schedule.
If a mod tries to call add_system with an schedule that isn’t enabled this will just produce a warning.
In debug mode, this will panic if the schedule is already added.
Sourcepub fn set_setup_schedule(self, schedule: impl ScheduleLabel) -> Self
pub fn set_setup_schedule(self, schedule: impl ScheduleLabel) -> Self
Configures during which schedule the modloader sets up new systems.
Defaults to Bevy’s First schedule.
Schedules can’t be modified while in use, therefore a schedule can’t both be used to setup mods and run mod systems simultaneously.
Sourcepub fn add_functionality<F>(self, f: F) -> Self
pub fn add_functionality<F>(self, f: F) -> Self
Use this function to add custom functionality that will be passed to the WASM module.
Sourcepub fn with_codec(self, codec: impl WasvyCodec) -> Self
pub fn with_codec(self, codec: impl WasvyCodec) -> Self
Apply a custom codec for serializing data to/from mods
Defaults to [JsonCodec]
Trait Implementations§
Source§impl Default for ModloaderPlugin
impl Default for ModloaderPlugin
Source§impl Plugin for ModloaderPlugin
impl Plugin for ModloaderPlugin
Source§fn ready(&self, _app: &App) -> bool
fn ready(&self, _app: &App) -> bool
finish should be called.Source§fn finish(&self, _app: &mut App)
fn finish(&self, _app: &mut App)
App, once all plugins registered are ready. This can
be useful for plugins that depends on another plugin asynchronous setup, like the renderer.Source§fn cleanup(&self, _app: &mut App)
fn cleanup(&self, _app: &mut App)
Auto Trait Implementations§
impl !Freeze for ModloaderPlugin
impl RefUnwindSafe for ModloaderPlugin
impl Send for ModloaderPlugin
impl Sync for ModloaderPlugin
impl Unpin for ModloaderPlugin
impl UnsafeUnpin for ModloaderPlugin
impl UnwindSafe for ModloaderPlugin
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
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>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn 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>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which 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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
self file descriptor. Read moreSource§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more