pub struct Aspect {
pub accept_types: Vec<TypeId>,
pub not_accept_types: Vec<TypeId>,
}Expand description
data for systems, storing which components they should be intrested in
Fields§
§accept_types: Vec<TypeId>§not_accept_types: Vec<TypeId>Implementations§
Source§impl Aspect
impl Aspect
Sourcepub fn all<T: Any + Component>() -> Aspect
pub fn all<T: Any + Component>() -> Aspect
Examples found in repository?
examples/systems.rs (line 17)
16 fn aspect(&self) -> Aspect {
17 Aspect::all::<Position>()
18 }
19
20 fn on_added(&mut self, entity : &mut Entity) {
21 println!("drawer added {}", entity.id);
22 }
23
24 fn process_one(&mut self, entity : &mut Entity) {
25 let pos = entity.get_component::<Position>();
26 println!("{}", pos.pos[0]);
27 }
28}
29
30pub struct DeadDrawerSystem;
31impl System for DeadDrawerSystem {
32 fn aspect(&self) -> Aspect {
33 Aspect::all::<Position>().except::<Dead>()
34 }More examples
examples/process_types.rs (line 32)
31 fn data_aspects(&self) -> Vec<Aspect> {
32 vec![Aspect::all::<Camera>()]
33 }
34 fn process_d(&mut self, entity : &mut Entity, data : &mut DataList) {
35 let cam = data.unwrap_entity();
36 let cam = cam.get_component::<Camera>();
37
38 let pos = entity.get_component::<Position>();
39 let mesh = entity.get_component::<Mesh>();
40
41 println!("{}, {}, seen from camera pos: {:?}", mesh.mesh, pos.pos[0], cam.pos);
42 }
43}
44
45pub struct DeferRenderSystem;
46
47impl System for DeferRenderSystem {
48 fn aspect(&self) -> Aspect {
49 Aspect::all2::<Position, Mesh>()
50 }
51 fn data_aspects(&self) -> Vec<Aspect> {
52 vec![Aspect::all::<Camera>()]
53 }Sourcepub fn all2<T: Any + Component, T1: Any + Component>() -> Aspect
pub fn all2<T: Any + Component, T1: Any + Component>() -> Aspect
Examples found in repository?
examples/process_types.rs (line 29)
28 fn aspect(&self) -> Aspect {
29 Aspect::all2::<Position, Mesh>()
30 }
31 fn data_aspects(&self) -> Vec<Aspect> {
32 vec![Aspect::all::<Camera>()]
33 }
34 fn process_d(&mut self, entity : &mut Entity, data : &mut DataList) {
35 let cam = data.unwrap_entity();
36 let cam = cam.get_component::<Camera>();
37
38 let pos = entity.get_component::<Position>();
39 let mesh = entity.get_component::<Mesh>();
40
41 println!("{}, {}, seen from camera pos: {:?}", mesh.mesh, pos.pos[0], cam.pos);
42 }
43}
44
45pub struct DeferRenderSystem;
46
47impl System for DeferRenderSystem {
48 fn aspect(&self) -> Aspect {
49 Aspect::all2::<Position, Mesh>()
50 }More examples
pub fn all4<T: Any + Component, T1: Any + Component, T2: Any + Component, T3: Any + Component>() -> Aspect
pub fn all5<T: Any + Component, T1: Any + Component, T2: Any + Component, T3: Any + Component, T4: Any + Component>() -> Aspect
pub fn except2<T: Any + Component, T1: Any + Component>(self) -> Aspect
pub fn except3<T: Any + Component, T1: Any + Component, T2: Any + Component>( self, ) -> Aspect
Auto Trait Implementations§
impl Freeze for Aspect
impl RefUnwindSafe for Aspect
impl Send for Aspect
impl Sync for Aspect
impl Unpin for Aspect
impl UnwindSafe for Aspect
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more