[−][src]Struct mecs::entity::Entity
An entity
Methods
impl<'a, S> Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
[src]
S: Storage<'a>,
S::Id: KeyType,
#[must_use]
pub fn new() -> Self
[src]
Creates an empty entity
#[must_use]
pub fn from_components(components: Vec<S>) -> Self
[src]
Creates an entity from a list of components
pub fn add(&mut self, storage: S) -> Option<S>
[src]
Adds a new component to this entity
Return
If this entity already contains a component with
the same id as the one in storage
, it is returned.
pub fn remove<C: Component<'a, S>>(&mut self) -> Option<S>
[src]
Remove a component from this entity given it's type
pub fn remove_id(&mut self, id: &S::Id) -> Option<S>
[src]
Removes a component from this entity given it's id
#[must_use]
pub fn get<C: Component<'a, S>>(&self) -> Option<&C>
[src]
Returns a reference to a component given it's type
Return
If either the component is not present in this entity or the component could not be build from the storage associated with it's id, this function will return None.
#[must_use]
pub fn get_mut<C: Component<'a, S>>(&mut self) -> Option<&mut C>
[src]
Returns a mutable reference to a component given it's type
Return
If either the component is not present in this entity or the component could not be build from the storage associated with it's id, this function will return None.
#[must_use]
pub fn get_id(&self, id: &S::Id) -> Option<&S>
[src]
Returns a reference to a component's storage given it's id
#[must_use]
pub fn get_mut_id(&mut self, id: &S::Id) -> Option<&mut S>
[src]
Returns a mutable reference to a component's storage given it's id
pub fn ids(&self) -> impl Iterator<Item = &<S as Storage<'a>>::Id>
[src]
Returns an iterator over all component ids in this entity
#[must_use]
pub fn components(&self) -> Values<S::Id, S>
[src]
Returns an iterator over all components in this entity
#[must_use]
pub fn components_mut(&mut self) -> ValuesMut<S::Id, S>
[src]
Returns a mutable iterator over all components in this entity
#[must_use]
pub fn has<C: Component<'a, S>>(&self) -> bool
[src]
Checks if this entity has a component given it's type
#[must_use]
pub fn has_id(&self, id: &S::Id) -> bool
[src]
Checks if this entity has a component given it's id
Trait Implementations
impl<'a, S: Clone> Clone for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
S::Id: Clone,
[src]
S: Storage<'a>,
S::Id: KeyType,
S::Id: Clone,
impl<'a, S: Debug> Debug for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
S::Id: Debug,
[src]
S: Storage<'a>,
S::Id: KeyType,
S::Id: Debug,
impl<'a, S> Default for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
[src]
S: Storage<'a>,
S::Id: KeyType,
impl<'a, S: Eq> Eq for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
S::Id: Eq,
[src]
S: Storage<'a>,
S::Id: KeyType,
S::Id: Eq,
impl<'a, S: PartialEq> PartialEq<Entity<'a, S>> for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
S::Id: PartialEq,
[src]
S: Storage<'a>,
S::Id: KeyType,
S::Id: PartialEq,
impl<'a, S> StructuralEq for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
[src]
S: Storage<'a>,
S::Id: KeyType,
impl<'a, S> StructuralPartialEq for Entity<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
[src]
S: Storage<'a>,
S::Id: KeyType,
Auto Trait Implementations
impl<'a, S> RefUnwindSafe for Entity<'a, S> where
S: RefUnwindSafe,
<S as Storage<'a>>::Id: RefUnwindSafe,
S: RefUnwindSafe,
<S as Storage<'a>>::Id: RefUnwindSafe,
impl<'a, S> Send for Entity<'a, S> where
S: Send,
<S as Storage<'a>>::Id: Send,
S: Send,
<S as Storage<'a>>::Id: Send,
impl<'a, S> Sync for Entity<'a, S> where
S: Sync,
<S as Storage<'a>>::Id: Sync,
S: Sync,
<S as Storage<'a>>::Id: Sync,
impl<'a, S> Unpin for Entity<'a, S> where
S: Unpin,
<S as Storage<'a>>::Id: Unpin,
S: Unpin,
<S as Storage<'a>>::Id: Unpin,
impl<'a, S> UnwindSafe for Entity<'a, S> where
S: UnwindSafe,
<S as Storage<'a>>::Id: UnwindSafe,
S: UnwindSafe,
<S as Storage<'a>>::Id: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Component<'static, DynStorage> for T where
T: Debug + 'static,
[src]
T: Debug + 'static,
#[must_use]
fn id() -> TypeId
[src]
#[must_use]
fn get(&DynStorage) -> Option<&T>
[src]
#[must_use]
fn get_mut(&mut DynStorage) -> Option<&mut T>
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,