[][src]Struct dces::entity::EntityComponentManager

pub struct EntityComponentManager {
    pub entities: HashMap<Entity, HashMap<TypeId, Box<dyn Any>>>,
    pub shared: HashMap<Entity, RefCell<HashMap<TypeId, Entity>>>,
}

The EntityComponentManager represents the main entity and component storage.

Fields

entities: HashMap<Entity, HashMap<TypeId, Box<dyn Any>>>

The entities with its components.

shared: HashMap<Entity, RefCell<HashMap<TypeId, Entity>>>

Methods

impl EntityComponentManager
[src]

pub fn new() -> Self
[src]

Create sa new entity component manager.

pub fn register_entity(&mut self, entity: Entity)
[src]

Register a new entity.

pub fn remove_entity(&mut self, entity: Entity)
[src]

Removes a entity from the manager.

pub fn register_component<C: Component>(&mut self, entity: Entity, component: C)
[src]

Register a component for the given entity.

pub fn register_shared_component<C: Component>(
    &mut self,
    target: Entity,
    source: Entity
)
[src]

pub fn register_shared_component_box(
    &mut self,
    target: Entity,
    source: SharedComponentBox
)
[src]

pub fn register_component_box(
    &mut self,
    entity: Entity,
    component_box: ComponentBox
)
[src]

Register a component_box for the given entity.

pub fn borrow_component<C: Component>(
    &self,
    entity: Entity
) -> Result<&C, NotFound>
[src]

Returns a reference of a component of type C from the given entity. If the entity does not exists or it dosen't have a component of type C NotFound will be returned.

pub fn borrow_mut_component<C: Component>(
    &mut self,
    entity: Entity
) -> Result<&mut C, NotFound>
[src]

Returns a mutable reference of a component of type C from the given entity. If the entity does not exists or it dosen't have a component of type C NotFound will be returned.

Trait Implementations

impl Default for EntityComponentManager
[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Component for T where
    T: Any
[src]

impl<T> From for T
[src]

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

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

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

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

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

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

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

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

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.