amethyst_core/transform/
bundle.rs1use amethyst_error::Error;
4use specs_hierarchy::HierarchySystem;
5
6use crate::{
7 bundle::SystemBundle,
8 ecs::prelude::{DispatcherBuilder, World},
9 transform::*,
10 SystemDesc,
11};
12
13#[derive(Debug, Default)]
27pub struct TransformBundle<'a> {
28 dep: &'a [&'a str],
29}
30
31impl<'a> TransformBundle<'a> {
32 pub fn new() -> Self {
34 TransformBundle {
35 dep: Default::default(),
36 }
37 }
38
39 pub fn with_dep(mut self, dep: &'a [&'a str]) -> Self {
41 self.dep = dep;
42 self
43 }
44}
45
46impl<'a, 'b, 'c> SystemBundle<'a, 'b> for TransformBundle<'c> {
47 fn build(
48 self,
49 world: &mut World,
50 builder: &mut DispatcherBuilder<'a, 'b>,
51 ) -> Result<(), Error> {
52 builder.add(
53 HierarchySystem::<Parent>::new(world),
54 "parent_hierarchy_system",
55 self.dep,
56 );
57 builder.add(
58 TransformSystemDesc::default().build(world),
59 "transform_system",
60 &["parent_hierarchy_system"],
61 );
62 Ok(())
63 }
64}