[−][src]Struct mecs::world::World
Collection of entities
Id
Each entity has it's own unique id, that will not be re-used even after the entity is removed from this world. The entity id 0 is reserved to mean a null entity, that is, an entity which does not exist.
Methods
impl<'a, S> World<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
[src]
S: Storage<'a>,
S::Id: KeyType,
#[must_use]
pub fn new() -> Self
[src]
Create a new empty world
#[must_use]
pub fn from_entities(entities: Vec<Entity<'a, S>>) -> Self
[src]
Creates a world from a list of entities
pub fn add(&mut self, entity: Entity<'a, S>) -> EntityId
[src]
Adds an entity to this world
pub fn remove(&mut self, id: EntityId) -> Option<Entity<'a, S>>
[src]
Removes an entity from this world given it's id
#[must_use]
pub fn get(&self, id: EntityId) -> Option<&Entity<'a, S>>
[src]
Returns a reference to an entity given it's id
#[must_use]
pub fn get_mut(&mut self, id: EntityId) -> Option<&mut Entity<'a, S>>
[src]
Returns a mutable reference to an entity given it's id
pub fn add_pred<F>(&mut self, f: F) -> usize where
F: Fn(&Entity<'a, S>) -> bool + 'static,
[src]
F: Fn(&Entity<'a, S>) -> bool + 'static,
Registers a predicate to filter entities through
pub fn iter_all(&self) -> impl Iterator<Item = &Entity<'a, S>>
[src]
Returns an iterator over all entities in this world
pub fn iter_mut_all(&mut self) -> impl Iterator<Item = &mut Entity<'a, S>>
[src]
Returns a mutable iterator over all entities in this world
#[must_use]
pub fn iter_pred(&self, id: usize) -> Option<PredIter<'a, '_, S>>
[src]
Returns an iterator over a predicate
#[must_use]
pub fn iter_pred_mut(&mut self, id: usize) -> Option<PredIterMut<'a, '_, S>>
[src]
Returns a mutable iterator over a predicate
Trait Implementations
impl<'a, S> Default for World<'a, S> where
S: Storage<'a>,
S::Id: KeyType,
[src]
S: Storage<'a>,
S::Id: KeyType,
impl<'a, S> Eq for World<'a, S> where
S: Storage<'a> + Eq,
S::Id: KeyType,
[src]
S: Storage<'a> + Eq,
S::Id: KeyType,
impl<'a, S> PartialEq<World<'a, S>> for World<'a, S> where
S: Storage<'a> + PartialEq,
S::Id: KeyType,
[src]
S: Storage<'a> + PartialEq,
S::Id: KeyType,
Auto Trait Implementations
impl<'a, S> !RefUnwindSafe for World<'a, S>
impl<'a, S> !Send for World<'a, S>
impl<'a, S> !Sync for World<'a, S>
impl<'a, S> Unpin for World<'a, S> where
S: Unpin,
<S as Storage<'a>>::Id: Unpin,
S: Unpin,
<S as Storage<'a>>::Id: Unpin,
impl<'a, S> !UnwindSafe for World<'a, S>
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> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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>,