Struct ABC_ECS::EntitiesAndComponents
source · pub struct EntitiesAndComponents { /* private fields */ }Implementations§
source§impl EntitiesAndComponents
impl EntitiesAndComponents
pub fn new() -> Self
sourcepub fn get_components(&self, entity: Entity) -> &AnyMap
pub fn get_components(&self, entity: Entity) -> &AnyMap
Gets a reference to all the components on an entity Returns an AnyMap, which can be used to get a reference to a component This should rarely if ever be used
sourcepub fn get_components_mut(&mut self, entity: Entity) -> &mut AnyMap
pub fn get_components_mut(&mut self, entity: Entity) -> &mut AnyMap
Gets a mutable reference to the components on an entity If the entity does not exist, it will panic
sourcepub fn try_get_component<T: 'static>(&self, entity: Entity) -> Option<&Box<T>>
pub fn try_get_component<T: 'static>(&self, entity: Entity) -> Option<&Box<T>>
Gets a reference to a component on an entity If the component does not exist on the entity, it will return None
sourcepub fn try_get_component_mut<T: 'static>(
&mut self,
entity: Entity
) -> Option<&mut Box<T>>
pub fn try_get_component_mut<T: 'static>( &mut self, entity: Entity ) -> Option<&mut Box<T>>
Gets a mutable reference to a component on an entity If the component does not exist on the entity, it will return None
sourcepub fn get_component<T: 'static>(&self, entity: Entity) -> &T
pub fn get_component<T: 'static>(&self, entity: Entity) -> &T
Gets a reference to a component on an entity If the component does not exist on the entity, it will panic
sourcepub fn get_component_mut<T: 'static>(&mut self, entity: Entity) -> &mut T
pub fn get_component_mut<T: 'static>(&mut self, entity: Entity) -> &mut T
Gets a mutable reference to a component on an entity If the component does not exist on the entity, it will panic
sourcepub fn add_entity(&mut self) -> Entity
pub fn add_entity(&mut self) -> Entity
Adds an entity to the game engine Returns the entity
sourcepub fn add_component_to<T: Component>(&mut self, entity: Entity, component: T)
pub fn add_component_to<T: Component>(&mut self, entity: Entity, component: T)
Adds a component to an entity If the component already exists on the entity, it will be overwritten