Struct ecmap::ECMap [] [src]

pub struct ECMap<E: Hash + Eq = u32> {
    // some fields omitted
}

Entity-Component map, implemented as a double HashMap (first over component, then over entity).

See module level documentation for an example.

Methods

impl<E: Hash + Eq + Default> ECMap<E>

fn new_custom() -> ECMap<E>

Returns a new ECMap with a custom entity ID type. If you want to use ECMap::insert_entity (to generate unique entity IDs), use ECMap::new_u32, ECMap::new_usize or ECMap::new_u64 instead.

impl<E: Hash + Eq + Any + Copy> ECMap<E>

fn insert<C: Any>(&mut self, e: E, c: C) -> Option<C>

Inserts or replaces an entity component. The old component, if there was one, is returned. If the entity or component did not at all exist, it is also added.

fn insert_component<C: Any + Debug>(&mut self) -> bool

Inserts a component type and enables debugging for that component. In case the component type already exists, nothing is changed and false is returned.

fn get<C: Any>(&self, e: E) -> Option<&C>

Returns a reference to an entity component, or None if it does not exist.

fn get_mut<C: Any>(&mut self, e: E) -> Option<&mut C>

Returns a mutable reference to an entity component, or None if it does not exist.

fn contains<C: Any>(&self, e: E) -> bool

Check whether an entity component exists.

fn contains_entity(&self, e: E) -> bool

Check whether an entity exists.

fn contains_component<C: Any>(&self) -> bool

Check whether a component exists.

fn remove<C: Any>(&mut self, e: E) -> bool

Removes an entity component.

fn remove_entity(&mut self, e: E) -> bool

Remove an entity (existing components will no longer have that entity).

fn remove_component<C: Any>(&mut self) -> bool

Remove a component (existing entities will no longer have that component).

fn clone_with<C: Any + Clone>(&self) -> Vec<(E, C)>

Clones the component for all entities and returns a Vec of those.

fn iter_with<C: Any>(&self) -> Iter<E, C>

Iterates over all entities having a certain component.

fn iter_mut_with<C: Any>(&mut self) -> IterMut<E, C>

Iterates over all entities having a certain component, yielding mutable references.

impl ECMap<u32>

fn new() -> ECMap<u32>

Returns a new ECMap with u32 as Entity ID.

fn new_u32() -> ECMap<u32>

Returns a new ECMap with u32 as Entity ID.

fn insert_entity(&mut self) -> u32

Generates an Entity ID and inserts it.

impl ECMap<usize>

fn new_usize() -> ECMap<usize>

Returns a new ECMap with usize as Entity ID.

fn insert_entity(&mut self) -> usize

Generates an Entity ID and inserts it.

impl ECMap<u64>

fn new_u64() -> ECMap<u64>

Returns a new ECMap with u64 as Entity ID.

fn insert_entity(&mut self) -> u64

Generates an Entity ID and inserts it.

Trait Implementations

impl<E: Hash + Eq + Debug> Debug for ECMap<E>

fn fmt(&self, f: &mut Formatter) -> Result

Derived Implementations

impl<E: Default + Hash + Eq> Default for ECMap<E>

fn default() -> ECMap<E>