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
use std::borrow::Cow;
use crate::{context::MapContext, tcs::system::function::IntoSystem};
mod function;
pub mod stage;
pub trait System: 'static {
fn name(&self) -> Cow<'static, str>;
fn run(&mut self, context: &mut MapContext);
}
pub type BoxedSystem = Box<dyn System>;
pub struct SystemContainer {
system: BoxedSystem,
}
impl SystemContainer {
pub fn new<S: System>(system: S) -> Self {
Self {
system: Box::new(system),
}
}
}
pub trait IntoSystemContainer {
fn into_container(self) -> SystemContainer;
}
impl<S> IntoSystemContainer for S
where
S: IntoSystem,
{
fn into_container(self) -> SystemContainer {
SystemContainer {
system: Box::new(IntoSystem::into_system(self)),
}
}
}
impl IntoSystemContainer for SystemContainer {
fn into_container(self) -> SystemContainer {
self
}
}