use amethyst::{core::bundle::SystemBundle, ecs::prelude::*, error::Error};
use derive_new::new;
#[derive(Debug, new)]
pub(crate) struct SystemInjectionBundle<S>
where
S: for<'s> System<'s> + Send,
{
system: S,
system_name: String,
system_dependencies: Vec<String>,
}
impl<'a, 'b, S> SystemBundle<'a, 'b> for SystemInjectionBundle<S>
where
S: for<'s> System<'s> + Send + 'a,
{
fn build(
self,
_world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
let system_dependencies = self
.system_dependencies
.iter()
.map(String::as_str)
.collect::<Vec<&str>>();
builder.add(self.system, &self.system_name, &system_dependencies);
Ok(())
}
}