Struct rinecs::operators::URef [−][src]
pub struct URef<'a, T: OneToOneComponent<'a>, R> { /* fields omitted */ }
Matches a component in another entity referenced through a component that Derefs to an Entity:
Entity A Entity C
Component(Entity) ───────────────► AnotherCompoenent
Entity B Entity D
Component(Entity) ───────────────► AnotherCompoenent
Allows to create OneToOne relations between entities components.
In the following example we create 2 entities that reference their geometry from other entities.
References have to implement OneToOneComponent.
As opposed to Ref and NToOneComponent this operator returns a plain iterator for write access to the referenced component since OneToOneComponent ensures that the references are unique and so the iterator won’t ever access the same component mutably more than once.
#[derive(Debug)] struct Vertex; #[derive(OneToOneComponent, Debug, Hash)] struct GeometryRef(Entity); #[derive(Component, Debug)] struct Geometry(Vec<Vertex>); #[derive(Component, Debug)] struct Position{x: f32, y: f32}; let mut world = World::new(); let geometry1 = world.new_entity().add(Geometry(vec![Vertex, Vertex, Vertex])).build(); let geometry2 = world.new_entity().add(Geometry(vec![Vertex, Vertex, Vertex])).build(); let a = world.new_entity() .add(GeometryRef(geometry1)) .add(Position{x: 0.0, y: 0.0}) .build(); let b = world.new_entity() .add(GeometryRef(geometry2)) .add(Position{x: 0.0, y: 0.0}) .build(); for geometry in world.iter_for_mut::<URef<GeometryRef, Write<Geometry>>>() { }
Trait Implementations
impl<'a, T, R> DataAccesses for URef<'a, T, R> where
T: OneToOneComponent<'a>,
R: DataAccesses,
[src]
impl<'a, T, R> DataAccesses for URef<'a, T, R> where
T: OneToOneComponent<'a>,
R: DataAccesses,
[src]impl<'a, T: OneToOneComponent<'a>, R: UnorderedData<'a>> Deref for URef<'a, T, R>
[src]
impl<'a, T: OneToOneComponent<'a>, R: UnorderedData<'a>> Deref for URef<'a, T, R>
[src]impl<'a, T: OneToOneComponent<'a>, R: UnorderedData<'a>> DerefMut for URef<'a, T, R>
[src]
impl<'a, T: OneToOneComponent<'a>, R: UnorderedData<'a>> DerefMut for URef<'a, T, R>
[src]impl<'a, T, R> FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef> for URef<'a, T, R> where
T: OneToOneComponent<'a>,
R: UnorderedData<'a> + FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef>,
[src]
impl<'a, T, R> FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef> for URef<'a, T, R> where
T: OneToOneComponent<'a>,
R: UnorderedData<'a> + FromComponent<'a, <R as UnorderedData<'a>>::ComponentsRef>,
[src]fn from_component(
component: <R as UnorderedData<'a>>::ComponentsRef
) -> URef<'a, T, R>
[src]
component: <R as UnorderedData<'a>>::ComponentsRef
) -> URef<'a, T, R>
impl<'a, T, R> UnorderedData<'a> for URef<'a, T, R> where
<T as Component>::Storage: Storage<'s, T>,
R: UnorderedData<'a>,
T: OneToOneComponent<'a> + Component,
<<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>,
[src]
impl<'a, T, R> UnorderedData<'a> for URef<'a, T, R> where
<T as Component>::Storage: Storage<'s, T>,
R: UnorderedData<'a>,
T: OneToOneComponent<'a> + Component,
<<T as Component>::Storage as Storage<'a, T>>::Get: Borrow<T>,
[src]type Iter = RefIter<'a, Self::Storage>
type IterMut = RefIter<'a, Self::Storage>
type Components = <R as UnorderedData<'a>>::Components
type ComponentsRef = <R as UnorderedData<'a>>::ComponentsRef
type Storage = RefStorage<'a, ReadGuardRef<'a, <T as Component>::Storage>, T, <R as UnorderedData<'a>>::Storage, <R as UnorderedData<'a>>::Components, URefData, LazyIndexGuard<'a>>
fn query_mask<E: EntitiesStorage>(entities: &E) -> Bitmask
[src]
fn into_iter<E: EntitiesStorage>(entities: &'a E) -> Self::Iter
[src]
fn into_iter_mut<E: EntitiesStorage>(entities: &'a E) -> Self::IterMut
[src]
fn storage<E: EntitiesStorage>(entities: &'a E) -> Option<Self::Storage>
[src]
impl<'a, T, R> SafeIter<'a> for URef<'a, T, R> where
T: OneToOneComponent<'a>,
R: SafeIter<'a>,
[src]
T: OneToOneComponent<'a>,
R: SafeIter<'a>,
impl<'a, T: OneToOneComponent<'a>, R> SafeStreamingIter<'a> for URef<'a, T, R>
[src]
Auto Trait Implementations
impl<'a, T, R> RefUnwindSafe for URef<'a, T, R> where
R: RefUnwindSafe,
T: RefUnwindSafe,
R: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, R> Send for URef<'a, T, R> where
R: Send,
T: Send,
R: Send,
T: Send,
impl<'a, T, R> Sync for URef<'a, T, R> where
R: Sync,
T: Sync,
R: Sync,
T: Sync,
impl<'a, T, R> Unpin for URef<'a, T, R> where
R: Unpin,
T: Unpin,
R: Unpin,
T: Unpin,
impl<'a, T, R> UnwindSafe for URef<'a, T, R> where
R: UnwindSafe,
T: UnwindSafe,
R: UnwindSafe,
T: UnwindSafe,