Struct ABC_ECS::EntitiesAndComponents
source · pub struct EntitiesAndComponents { /* private fields */ }Implementations§
source§impl EntitiesAndComponents
impl EntitiesAndComponents
pub fn new() -> Self
sourcepub fn add_entity(&mut self) -> Entity
pub fn add_entity(&mut self) -> Entity
Adds an entity to the game engine Returns the entity
pub fn add_entity_with<T: OwnedComponents<Input = T>>( &mut self, components: T ) -> Entity
pub fn remove_entity(&mut self, entity: Entity)
sourcepub fn get_entities(&self) -> Vec<Entity>
pub fn get_entities(&self) -> Vec<Entity>
Gets a reference to all the entities in the game engine Should rarely if ever be used
sourcepub fn get_nth_entity(&self, index: usize) -> Option<Entity>
pub fn get_nth_entity(&self, index: usize) -> Option<Entity>
Gets a copy of an entity at a certain index
sourcepub fn get_entity_count(&self) -> usize
pub fn get_entity_count(&self) -> usize
Gets the number of entities in the game engine
sourcepub fn get_all_components(&self, entity: Entity) -> &AnyMap
pub fn get_all_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_all_components_mut(&mut self, entity: Entity) -> &mut AnyMap
pub fn get_all_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: Component>(&self, entity: Entity) -> Option<&Box<T>>
pub fn try_get_component<T: Component>(&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: Component>(
&mut self,
entity: Entity
) -> Option<&mut Box<T>>
pub fn try_get_component_mut<T: Component>( &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_components<'a, T: ComponentsRef<'a> + 'static>(
&'a self,
entity: Entity
) -> T::Result
pub fn get_components<'a, T: ComponentsRef<'a> + 'static>( &'a self, entity: Entity ) -> T::Result
Gets a tuple of references to components on an entity If the component does not exist on the entity, it will panic
sourcepub fn get_components_mut<'a, T: ComponentsMut<'a> + 'static>(
&'a mut self,
entity: Entity
) -> T::Result
pub fn get_components_mut<'a, T: ComponentsMut<'a> + 'static>( &'a mut self, entity: Entity ) -> T::Result
Gets a mutable reference to a component on an entity If the component does not exist on the entity, it will panic
pub fn try_get_components<'a, T: TryComponentsRef<'a> + 'static>( &'a self, entity: Entity ) -> T::Result
pub fn try_get_components_mut<'a, T: TryComponentsMut<'a> + 'static>( &'a mut self, entity: Entity ) -> T::Result
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
pub fn remove_component_from<T: Component>(&mut self, entity: Entity)
sourcepub fn get_entities_with_component<T: Component>(
&self
) -> Flatten<IntoIter<Values<'_, DefaultKey, Entity>>>
pub fn get_entities_with_component<T: Component>( &self ) -> Flatten<IntoIter<Values<'_, DefaultKey, Entity>>>
returns an iterator over all entities with a certain component
pub fn get_entity_count_with_component<T: Component>(&self) -> usize
sourcepub fn get_entity_with_component<T: Component>(
&self,
index: usize
) -> Option<Entity>
pub fn get_entity_with_component<T: Component>( &self, index: usize ) -> Option<Entity>
gets the nth entity with a certain component O(n) use get_entities_with_component if you need to iterate over all entities with a certain component