Struct shard_ecs::registry::Registry [−][src]
pub struct Registry { /* fields omitted */ }
Expand description
The primary construct in the Shard Entity Component System (ECS).
Implementations
pub fn create_entity<'c, G: ComponentGroup<'c>>(
&mut self,
components: G
) -> Result<Entity, G>
pub fn create_entity<'c, G: ComponentGroup<'c>>(
&mut self,
components: G
) -> Result<Entity, G>
Creates a new entity using the provided components. Returns Ok with a Entity if successful, or Err(components) if not. Returns Err if the provided component group is invalid or an internal limit is exceeded. Panics in case of allocation failure.
Removes the entity from the registry. This function return false if the entity given is invalid.
Removes the entity from the registry if it matches the given component group exactly. Otherwise, it simply leaves the entity as is. This function return None if either entity given is invalid, or does not match the given component group.
Returns true if a given entity has the specified component. Returns false if entity is invalid or does not have the specified component.
pub fn has_components<'registry, G: ComponentGroup<'registry>>(
&'registry self,
entity: Entity
) -> bool
pub fn has_components<'registry, G: ComponentGroup<'registry>>(
&'registry self,
entity: Entity
) -> bool
Returns true if a given entity has all of the specified components.
Returns false if entity is invalid or does not have all of the specified components.
If you need to check for only a single components, prefer to use Registry::has_component
instead.
Returns a reference to the specified component if the entity has it. Returns false if entity is invalid or does not have the specified component.
pub fn get_components<'registry, G: ComponentGroup<'registry>>(
&'registry self,
entity: Entity
) -> Option<G::RefTuple>
pub fn get_components<'registry, G: ComponentGroup<'registry>>(
&'registry self,
entity: Entity
) -> Option<G::RefTuple>
Returns a tuple of references to the specified components if the entity has all of them.
Returns false if entity is invalid or does not have the specified components.
If you need to get only a single component, use Registry::get_component
instead.
Returns a mutable reference to the specified component if the entity has it.
Returns false if entity is invalid or does not have the specified component.
If you need to get only a single component, use Registry::get_component_mut
instead.
pub fn get_components_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self,
entity: Entity
) -> Option<G::MutRefTuple>
pub fn get_components_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self,
entity: Entity
) -> Option<G::MutRefTuple>
Returns a tuple of mutable references to the specified components if the entity has all of them. Returns false if entity is invalid or does not have the specified components.
Adds a given component to the entity if it’s not yet present. Returns the original component in case of failure for any reason. Reasons for failure:
- Invalid entity provided.
- Destination archetype could not be created.
Returns an iterator which iterates over all entities in the registry.
pub fn iter_components_matching<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceRefTuple> + 'registry
pub fn iter_components_matching<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceRefTuple> + 'registry
Returns an iterator which iterates over all components in archetypes matching the specified predicate.
pub fn iter_components_matching_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceMutRefTuple> + 'registry
pub fn iter_components_matching_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceMutRefTuple> + 'registry
Returns an iterator which mutably iterates over all components in archetypes matching the specified predicate.
pub fn iter_entity_components_matching<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceRefTuple)> + 'registry
pub fn iter_entity_components_matching<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceRefTuple)> + 'registry
Returns an iterator which iterates over all entities and components in archetypes matching the specified predicate.
pub fn iter_entity_components_matching_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceMutRefTuple)> + 'registry
pub fn iter_entity_components_matching_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceMutRefTuple)> + 'registry
Returns an iterator which mutably iterates over all entities and components in archetypes matching the specified predicate.
pub fn iter_filtered_components_matching<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry self,
filter_closure: F
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceRefTuple> + 'registry
pub fn iter_filtered_components_matching<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry self,
filter_closure: F
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceRefTuple> + 'registry
Returns an iterator which iterates over all components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.
pub fn iter_filtered_components_matching_mut<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry mut self,
filter_closure: F
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceMutRefTuple> + 'registry
pub fn iter_filtered_components_matching_mut<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry mut self,
filter_closure: F
) -> impl Iterator<Item = <G as ComponentGroup<'registry>>::SliceMutRefTuple> + 'registry
Returns an iterator which mutably iterates over all components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.
pub fn iter_filtered_entity_components_matching<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry self,
filter_closure: F
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceRefTuple)> + 'registry
pub fn iter_filtered_entity_components_matching<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry self,
filter_closure: F
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceRefTuple)> + 'registry
Returns an iterator which iterates over all entities and components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.
pub fn iter_filtered_entity_components_matching_mut<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry mut self,
filter_closure: F
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceMutRefTuple)> + 'registry
pub fn iter_filtered_entity_components_matching_mut<'registry, G: ComponentGroup<'registry>, F: Fn(&ArchetypeDescriptor) -> bool + 'registry>(
&'registry mut self,
filter_closure: F
) -> impl Iterator<Item = (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceMutRefTuple)> + 'registry
Returns an iterator which mutably iterates over all entities and components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.
pub fn iter_components_exact<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> <G as ComponentGroup<'registry>>::SliceRefTuple
pub fn iter_components_exact<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> <G as ComponentGroup<'registry>>::SliceRefTuple
Returns a tuple of component slices if the exact archetype matching the predicate exists.
pub fn iter_components_exact_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> <G as ComponentGroup<'registry>>::SliceMutRefTuple
pub fn iter_components_exact_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> <G as ComponentGroup<'registry>>::SliceMutRefTuple
Returns a tuple of mutable component slices if the exact archetype matching the predicate exists.
pub fn iter_entity_components_exact<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceRefTuple)
pub fn iter_entity_components_exact<'registry, G: ComponentGroup<'registry>>(
&'registry self
) -> (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceRefTuple)
Returns a tuple of an entity slice and component slices if the exact archetype matching the predicate exists.
pub fn iter_entity_components_exact_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceMutRefTuple)
pub fn iter_entity_components_exact_mut<'registry, G: ComponentGroup<'registry>>(
&'registry mut self
) -> (&'registry [Entity], <G as ComponentGroup<'registry>>::SliceMutRefTuple)
Returns a tuple of an entity slice and mutable component slices if the exact archetype matching the predicate exists.