[][src]Struct rinecs::operators::ReadRef

pub struct ReadRef<'a, T: 'a + NToOneComponent, Ref: 'a + Component> { /* fields omitted */ }

Operator that matches entities that contain a component through a reference

A reference to another entity is any component that implements Deref<Target=Entity>

The first parameter to ReadRef indicates the reference component the second the referenced

#[derive(Component, Debug)]
struct Position(f32,f32);

#[derive(Component, Debug)]
struct GeometryRef(Entity);

#[derive(Component, Debug)]
struct Geometry;


let geom = world.new_entity()
    .add(Geometry)
    .build();

world.new_entity()
    .add(GeometryRef(geom))
    .add(Position(0., 0.))
    .build();

world.new_entity()
    .add(GeometryRef(geom))
    .add(Position(10., 10.))
    .build();

for (geom, pos) in entities.iter_for::<(ReadRef<GeometryRef, Geometry>, Read<Position>)>(){
    // draw geometry at position
}

Will select all entities that reference a Geometry through a GeometryRef and have a position then draw the geometry at that position.

This allow to have only one copy of the geometry that is referenced by multiple entities

When deriving Component for a tuple struct with only one element it'll also derive Deref for that element so in this case GeometryRef automatically can be used with ReadRef

Trait Implementations

impl<'a, T, Ref> UnorderedData<'a> for ReadRef<'a, T, Ref> where
    T: 'a + NToOneComponentSend,
    Ref: Component + Send,
    <<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>, 
[src]

impl<'a, T, Ref> ParUnorderedData<'a> for ReadRef<'a, T, Ref> where
    T: 'a + NToOneComponentSend,
    Ref: Component + Send,
    <<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>, 
[src]

impl<'a, T, Ref> UnorderedDataLocal<'a> for ReadRef<'a, T, Ref> where
    T: 'a + NToOneComponentThreadLocal,
    Ref: Component,
    <<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>, 
[src]

impl<'a, T: 'a + NToOneComponent, Ref: 'a + Component> FromComponent<'a, &'a Ref> for ReadRef<'a, T, Ref>
[src]

impl<'a, T: 'a + NToOneComponent, Ref: 'a + Component> Deref for ReadRef<'a, T, Ref>
[src]

The resulting type after dereferencing.

Auto Trait Implementations

impl<'a, T, Ref> Send for ReadRef<'a, T, Ref> where
    Ref: Sync,
    T: Sync

impl<'a, T, Ref> Sync for ReadRef<'a, T, Ref> where
    Ref: Sync,
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T
[src]

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[f32; 3]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[u32; 2]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<u32>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[i32; 2]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[[f32; 4]; 4]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[u32; 4]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[i32; 3]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[[f32; 3]; 3]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<i32> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[f32; 4]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[f32; 2]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[i32; 2]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[[f32; 4]; 4]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<i32>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[u32; 2]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<u32> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[f32; 3]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[f32; 2]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[u32; 3]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[i32; 3]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[u32; 3]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<[i32; 4]> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<[[f32; 3]; 3]>,
    U: Deref<Target = T>, 
[src]

impl<U, T> AsUniform for U where
    T: AsUniform<dyn AsRef<f32> + 'static>,
    U: Deref<Target = T>, 
[src]

impl<T> Any for T where
    T: Any
[src]

impl<T> SetParameter for T
[src]

Sets value as a parameter of self.