use amethyst_error::Error;
use specs_hierarchy::HierarchySystem;
use crate::{
bundle::SystemBundle,
ecs::prelude::{DispatcherBuilder, World},
transform::*,
SystemDesc,
};
#[derive(Debug, Default)]
pub struct TransformBundle<'a> {
dep: &'a [&'a str],
}
impl<'a> TransformBundle<'a> {
pub fn new() -> Self {
TransformBundle {
dep: Default::default(),
}
}
pub fn with_dep(mut self, dep: &'a [&'a str]) -> Self {
self.dep = dep;
self
}
}
impl<'a, 'b, 'c> SystemBundle<'a, 'b> for TransformBundle<'c> {
fn build(
self,
world: &mut World,
builder: &mut DispatcherBuilder<'a, 'b>,
) -> Result<(), Error> {
builder.add(
HierarchySystem::<Parent>::new(world),
"parent_hierarchy_system",
self.dep,
);
builder.add(
TransformSystemDesc::default().build(world),
"transform_system",
&["parent_hierarchy_system"],
);
Ok(())
}
}