Struct oxygengine_core::ecs::EntityRef
source · [−]pub struct EntityRef<'a> { /* private fields */ }
Expand description
Handle to an entity with any component types
Implementations
sourceimpl<'a> EntityRef<'a>
impl<'a> EntityRef<'a>
sourcepub fn get<T>(&self) -> Option<Ref<'a, T>> where
T: Component,
pub fn get<T>(&self) -> Option<Ref<'a, T>> where
T: Component,
Borrow the component of type T
, if it exists
Panics if the component is already uniquely borrowed from another entity with the same components.
sourcepub fn get_mut<T>(&self) -> Option<RefMut<'a, T>> where
T: Component,
pub fn get_mut<T>(&self) -> Option<RefMut<'a, T>> where
T: Component,
Uniquely borrow the component of type T
, if it exists
Panics if the component is already borrowed from another entity with the same components.
sourcepub fn component_types(&self) -> impl Iterator<Item = TypeId> + 'a
pub fn component_types(&self) -> impl Iterator<Item = TypeId> + 'a
Enumerate the types of the entity’s components
Convenient for dispatching component-specific logic for a single entity. For example, this
can be combined with a HashMap<TypeId, Box<dyn Handler>>
where Handler
is some
user-defined trait with methods for serialization, or to be called after spawning or before
despawning to maintain secondary indices.
Trait Implementations
impl<'a> Copy for EntityRef<'a>
impl<'a> Send for EntityRef<'a>
impl<'a> Sync for EntityRef<'a>
Auto Trait Implementations
impl<'a> !RefUnwindSafe for EntityRef<'a>
impl<'a> Unpin for EntityRef<'a>
impl<'a> !UnwindSafe for EntityRef<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more