[][src]Struct mecs::world::World

pub struct World<'a, S> where
    S: Storage<'a>,
    S::Id: KeyType, 
{ /* fields omitted */ }

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]

#[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]

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]

impl<'a, S> Eq for World<'a, S> where
    S: Storage<'a> + Eq,
    S::Id: KeyType, 
[src]

impl<'a, S> PartialEq<World<'a, S>> for World<'a, S> where
    S: Storage<'a> + PartialEq,
    S::Id: KeyType, 
[src]

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

impl<'a, S> !UnwindSafe for World<'a, S>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.