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
pub use entity_component::*;
pub use world_dispatcher::*;
use atomic_refcell_try::AtomicRefMut;
use std::any::Any;
pub trait WorldExt {
fn maintain(&mut self);
}
impl WorldExt for World {
fn maintain(&mut self) {
if let Ok(mut entities) = self.get_mut::<Entities>() {
for (typeid, func) in COMPONENT_REGISTRY.lock().unwrap().iter() {
if let Ok(any) = self.get_by_typeid(typeid) {
let any: AtomicRefMut<dyn Any> = AtomicRefMut::map(any, |j| j.as_any_mut());
func(any, entities.killed());
}
}
entities.clear_killed();
}
}
}