Aspect

Struct Aspect 

Source
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

Source

pub fn check(&self, entity: &Entity) -> bool

Source§

impl Aspect

Source

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
Hide additional examples
examples/spawn_system.rs (line 19)
18    fn aspect(&self) -> Aspect {
19        Aspect::all::<SpawnPoint>()
20    }
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    }
Source

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
Hide additional examples
examples/systems.rs (line 44)
43    fn aspect(&self) -> Aspect {
44        Aspect::all2::<Position, Dead>()
45    }
Source

pub fn all3<T: Any + Component, T1: Any + Component, T2: Any + Component>() -> Aspect

Examples found in repository?
examples/multiple_fields.rs (line 22)
21    fn aspect(&self) -> Aspect {
22        Aspect::all3::<Position, Health, Alive>()
23    }
Source

pub fn all4<T: Any + Component, T1: Any + Component, T2: Any + Component, T3: Any + Component>() -> Aspect

Source

pub fn all5<T: Any + Component, T1: Any + Component, T2: Any + Component, T3: Any + Component, T4: Any + Component>() -> Aspect

Source

pub fn except<T: Any + Component>(self) -> Aspect

Examples found in repository?
examples/systems.rs (line 33)
32    fn aspect(&self) -> Aspect {
33        Aspect::all::<Position>().except::<Dead>()
34    }
Source

pub fn except2<T: Any + Component, T1: Any + Component>(self) -> Aspect

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.