Struct recs::Ecs [] [src]

pub struct Ecs { /* fields omitted */ }

Primary data structure containing entity and component data.

Notice that Ecs itself has no type parameters. Its methods to interact with components do, but runtime reflection (via std::any::TypeId) is used to retrieve components from an internal HashMap. Therefore, you can create and use any data structure you want for components.

Tip: using #[derive(Clone)] on your component types will make your life a little easier by enabling the get method, which avoids locking down the Ecs with a mutable or immutable borrow.

Methods

impl Ecs
[src]

Create a new and empty entity-component system (ECS).

Create a new entity in the ECS without components and return its ID.

Return true if the provided entity exists in the system.

Destroy the provided entity, automatically removing any of its components.

Return NotFound::Entity if the entity does not exist or was already deleted.

For the specified entity, add a component of type C to the system.

If the entity already has a component prev of type C, return Some(prev). If not, return None. If the entity does not exist, return NotFound::Entity.

To modify an existing component in place, see borrow_mut.

Return a clone of the requested entity's component of type C, or a NotFound variant if the entity does not exist or does not have that component.

To examine or modify a component without making a clone, see borrow and borrow_mut.

Return true if the specified entity has a component of type C in the system, or NotFound::Entity if the entity does not exist.

Return true if each component type in the filter is present on the entity id.

Return a shared reference to the requested entity's component of type C, or a NotFound variant if the entity does not exist or does not have that component.

Return a mutable reference to the requested entity's component of type C, or a NotFound variant if the entity does not exist or does not have that component.

Return an iterator over every ID in the system.

Collect all entity IDs into a vector (after emptying the vector).

Useful for accessing entity IDs without borrowing the ECS.

Collect the IDs of all entities containing a certain set of component types into a vector.

After calling this method, the vector dest will contain only those entities who have at least each type of component specified in the filter.

Trait Implementations

impl Default for Ecs
[src]

Returns the "default value" for a type. Read more