1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use specs::prelude::DispatcherBuilder;
use specs_hierarchy::HierarchySystem;
use bundle::{Result, SystemBundle};
use transform::*;
#[derive(Default)]
pub struct TransformBundle<'a> {
dep: &'a [&'a str],
}
impl<'a> TransformBundle<'a> {
pub fn new() -> Self {
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, builder: &mut DispatcherBuilder<'a, 'b>) -> Result<()> {
builder.add(
HierarchySystem::<Parent>::new(),
"parent_hierarchy_system",
self.dep,
);
builder.add(
TransformSystem::new(),
"transform_system",
&["parent_hierarchy_system"],
);
Ok(())
}
}