Struct SingleMutEntity

Source
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>

Source

pub fn get_component<T: Component + Send + Sync>(&self) -> &T

Gets a reference to a component on an entity

Source

pub fn get_resource<T: Resource + Send + Sync>(&self) -> &T

Gets a reference to a resource

Source

pub fn try_get_component<T: Component + Send + Sync>(&self) -> Option<&Box<T>>

Gets a mutable reference to a component on an entity

Source

pub fn get_component_mut<T: Component + Send + Sync>(&mut self) -> &mut T

Gets a tuple of references to components on an entity

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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

Source

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
Source§

impl<T> Component for T
where T: 'static,