use crate::{Scene, SceneList, WorldSceneExt};
use bevy_ecs::{error::Result, world::World};
pub trait SpawnSystem {
fn spawn(self) -> impl FnMut(&mut World) -> Result;
}
impl<F: FnMut() -> S + Send + Sync + 'static, S: Scene> SpawnSystem for F {
fn spawn(mut self) -> impl FnMut(&mut World) -> Result {
move |world: &mut World| -> Result {
world.spawn_scene(self())?;
Ok(())
}
}
}
pub trait SpawnListSystem {
fn spawn(self) -> impl FnMut(&mut World) -> Result;
}
impl<F: FnMut() -> S + Send + Sync + 'static, S: SceneList> SpawnListSystem for F {
fn spawn(mut self) -> impl FnMut(&mut World) -> Result {
move |world: &mut World| -> Result {
world.spawn_scene_list(self())?;
Ok(())
}
}
}