[][src]Struct minutiae::container::EntityContainer

pub struct EntityContainer<C: CellState, E: EntityState<C>, M: MutEntityState> {
    pub entities: Slab<(Entity<C, E, M>, usize)>,
    pub positions: Vec<Vec<usize>>,
}

Data structure holding all of the universe's entities. The entities and their state are held in a vector of EntitySlots, each of which either holds an entity or the index of the next empty slot. Using this method, it's possible to add/remove entities from anywhere in the container without causing any allocations.

A second internal structure is used to map universe indexes to entity indexes; it holds the entity indexes of all entities that reside in each universe index.

Fields

entities: Slab<(Entity<C, E, M>, usize)>

(entity, universe_ix)

positions: Vec<Vec<usize>>

A mapping of universe index to entity index

Methods

impl<C: CellState, E: EntityState<C>, M: MutEntityState> EntityContainer<C, E, M>[src]

pub fn new(universe_size: usize) -> Self[src]

pub fn insert(
    &mut self,
    entity: Entity<C, E, M>,
    universe_index: usize
) -> usize
[src]

Inserts an entity into the container, returning its index

pub fn remove(&mut self, entity_index: usize) -> Entity<C, E, M>[src]

Removes an entity from the container, returning it along with its current index in the universe.

pub unsafe fn get(&self, index: usize) -> &Entity<C, E, M>[src]

Returns a reference to the entity contained at the supplied index. Will cause undefined behavior in release mode and panic in debug mode ifthe index is out of bounds or the slot at the specified index is empty.

pub unsafe fn get_mut(&mut self, index: usize) -> &mut Entity<C, E, M>[src]

Returns a mutable reference to the entity contained at the supplied index. Will cause undefined behavior in release mode and panic in debug mode ifthe index is out of bounds or the slot at the specified index is empty.

pub fn get_verify(
    &self,
    index: usize,
    uuid: Uuid
) -> Option<(&Entity<C, E, M>, usize)>
[src]

Checks if 1) an entity exists at the provided index and 2) that its UUID matches the supplied UUID. If so, returns a reference to the contained entity and its corresponding universe index.

pub fn get_verify_mut(
    &mut self,
    index: usize,
    uuid: Uuid
) -> Option<(&mut Entity<C, E, M>, usize)>
[src]

Checks if 1) an entity exists at the provided index and 2) that its UUID matches the supplied UUID. If so, returns the a mutable reference to the contained entity and its corresponding universe index.

pub fn move_entity(&mut self, entity_index: usize, dst_universe_index: usize)[src]

Moves an entity from one location in the universe to another. This function assumes that the supplied index is occupied and that the destination index is sane.

pub fn iter<'a>(
    &'a self
) -> impl Iterator<Item = (&Entity<C, E, M>, usize, usize)>
[src]

Creates an iterator over the entities contained within the container with the format (Entity, entity_index, universe_index).

pub fn get_position_index(&self, entity_index: usize) -> usize[src]

Creates a mutable iterator over the entities contained within the container with the format (Entity, entity_index, universe_index). Returns the position of the entity with the given entity index.

pub fn get_entities_at(&self, universe_index: usize) -> &[usize][src]

Returns a reference to the slice of all the entity_indexes of all entities at a certain universe index.

pub fn len(&self) -> usize[src]

Trait Implementations

impl<C: Clone + CellState, E: Clone + EntityState<C>, M: Clone + MutEntityState> Clone for EntityContainer<C, E, M>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<C: Debug + CellState, E: Debug + EntityState<C>, M: Debug + MutEntityState> Debug for EntityContainer<C, E, M>[src]

Auto Trait Implementations

impl<C, E, M> Send for EntityContainer<C, E, M> where
    C: Send,
    E: Send

impl<C, E, M> Unpin for EntityContainer<C, E, M> where
    C: Unpin,
    E: Unpin,
    M: Unpin

impl<C, E, M> Sync for EntityContainer<C, E, M> where
    C: Sync,
    E: Sync,
    M: Sync

impl<C, E, M> UnwindSafe for EntityContainer<C, E, M> where
    C: UnwindSafe,
    E: UnwindSafe,
    M: UnwindSafe

impl<C, E, M> RefUnwindSafe for EntityContainer<C, E, M> where
    C: RefUnwindSafe,
    E: RefUnwindSafe,
    M: RefUnwindSafe

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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

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

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

impl<T> SetParameter for T[src]

fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Result where
    T: Parameter<Self>, 
[src]

Sets value as a parameter of self.