Struct shard_ecs::Registry

source ·
pub struct Registry { /* private fields */ }
Expand description

The primary construct in the Shard Entity Component System (ECS).

Implementations

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.

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.

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.

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.

Removes a given component from the entity if it’s present. Returns the component in if successful. Reasons for failure:

  • Invalid entity provided.
  • Destination archetype could not be created.

Returns an iterator which iterates over all entities in the registry.

Returns an iterator which iterates over all components in archetypes matching the specified predicate.

Returns an iterator which mutably iterates over all components in archetypes matching the specified predicate.

Returns an iterator which iterates over all entities and components in archetypes matching the specified predicate.

Returns an iterator which mutably iterates over all entities and components in archetypes matching the specified predicate.

Returns an iterator which iterates over all components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.

Returns an iterator which mutably iterates over all components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.

Returns an iterator which iterates over all entities and components in archetypes matching the specified predicate. Archetypes not matching the filter closure are excluded.

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.

Returns a tuple of component slices if the exact archetype matching the predicate exists.

Returns a tuple of mutable component slices if the exact archetype matching the predicate exists.

Returns a tuple of an entity slice and component slices if the exact archetype matching the predicate exists.

Returns a tuple of an entity slice and mutable component slices if the exact archetype matching the predicate exists.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.