pub struct SingleMutEntity<'a> { /* private fields */ }Expand description
This struct is very similar to the EntitiesAndComponents struct but it only allows access to components on a single entity for safety reasons
Implementations§
Source§impl<'a> SingleMutEntity<'a>
impl<'a> SingleMutEntity<'a>
Sourcepub fn get_component<T: Component + Send + Sync>(&self) -> &T
pub fn get_component<T: Component + Send + Sync>(&self) -> &T
Gets a reference to a component on an entity
Sourcepub fn try_get_component<T: Component + Send + Sync>(&self) -> Option<&Box<T>>
pub fn try_get_component<T: Component + Send + Sync>(&self) -> Option<&Box<T>>
Gets a mutable reference to a component on an entity
Sourcepub fn get_component_mut<T: Component + Send + Sync>(&mut self) -> &mut T
pub fn get_component_mut<T: Component + Send + Sync>(&mut self) -> &mut T
Gets a tuple of references to components on an entity
Sourcepub fn try_get_component_mut<T: Component + Send + Sync>(
&mut self,
) -> Option<&mut Box<T>>
pub fn try_get_component_mut<T: Component + Send + Sync>( &mut self, ) -> Option<&mut Box<T>>
Gets a mutable reference to a component on an entity
Sourcepub fn get_components<'b, T: ComponentsRef<'b> + Send + Sync + 'static>(
&'b self,
) -> T::Result
pub fn get_components<'b, T: ComponentsRef<'b> + Send + Sync + 'static>( &'b self, ) -> T::Result
Gets a tuple of references to components on an entity
Sourcepub fn try_get_components<'b, T: TryComponentsRef<'b> + Send + Sync + 'static>(
&'b self,
) -> T::Result
pub fn try_get_components<'b, T: TryComponentsRef<'b> + Send + Sync + 'static>( &'b self, ) -> T::Result
Gets a tuple of references to components on an entity If the component does not exist on the entity it will return None
Sourcepub fn get_components_mut<'b, T: ComponentsMut<'b> + Send + Sync + 'static>(
&'b mut self,
) -> T::Result
pub fn get_components_mut<'b, T: ComponentsMut<'b> + Send + Sync + 'static>( &'b mut self, ) -> T::Result
Gets a mutable reference to a component on an entity If the component does not exist on the entity, it will panic
Sourcepub fn try_get_components_mut<'b, T: TryComponentsMut<'b> + Send + Sync + 'static>(
&'b mut self,
) -> T::Result
pub fn try_get_components_mut<'b, T: TryComponentsMut<'b> + Send + Sync + 'static>( &'b mut self, ) -> T::Result
Gets a mutable reference to a component on an entity If the component does not exist on the entity it will return None
Sourcepub fn remove_component<T: Component + Send + Sync>(&mut self)
pub fn remove_component<T: Component + Send + Sync>(&mut self)
Removes a component from an entity If the component does not exist on the entity, it will do nothing
Sourcepub fn add_component<T: Component + Send + Sync>(&mut self, component: T)
pub fn add_component<T: Component + Send + Sync>(&mut self, component: T)
Adds a component to an entity If the component already exists on the entity, it will be overwritten
Sourcepub fn has_component<T: Component + Send + Sync>(&self) -> bool
pub fn has_component<T: Component + Send + Sync>(&self) -> bool
Checks if an entity has a certain component Returns true if the entity has the component, false otherwise
Sourcepub fn remove_entity(&mut self)
pub fn remove_entity(&mut self)
Removes the entity from the game engine If you call this function, the struct will be useless and will panic if you try to use it
Sourcepub fn get_entity(&self) -> Entity
pub fn get_entity(&self) -> Entity
Gets the entity that this struct is referencing useful for relating data in prestep and single_entity_step functions
Auto Trait Implementations§
impl<'a> Freeze for SingleMutEntity<'a>
impl<'a> !RefUnwindSafe for SingleMutEntity<'a>
impl<'a> !Send for SingleMutEntity<'a>
impl<'a> !Sync for SingleMutEntity<'a>
impl<'a> Unpin for SingleMutEntity<'a>
impl<'a> !UnwindSafe for SingleMutEntity<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more