Crate rs_ecs

source ·
Expand description

A reasonably simple entity component system (ECS).

The design is based on hecs but it is not thread-safe and has a significantly reduced API surface.

§Example


let mut world = World::new();

let entity = world.alloc();
world.insert(entity, (42_u32, true));

let entity = world.alloc();
world.insert(entity, (23_u32, "hello".to_string()));

for number in Query::<&u32>::new().borrow(&world).iter() {
    println!("{}", number);
}

for (_entity, number, string) in Query::<(&Entity, &u32, &String)>::new().borrow(&world).iter() {
    println!("{}, {}", string, number);
}

Structs§

  • Collects component types which can be cloned or copied
  • An opaque entity identifier.
  • A query specification to indicate which entities match the inner query, but without borrowing any components.
  • Query to get an iterator over all entities with a certain combination of components.
  • Used to iterate through the entities which match a certain Query.
  • Provides random access to the entities which match a certain Query.
  • Query to access the specified components of a single entity.
  • Used to iterate through the entities which match a certain Query in parallel.
  • Borrow of the World for a Query. Required to obtain an iterator.
  • An immutable borrow of a resource.
  • A mutable borrow of a resource.
  • A type map for holding resources.
  • A query specification to iterate over entities with a certain component, but without borrowing that component.
  • A query specification to iterate over entities without a certain component.
  • The world storing entities and their components.

Traits§

  • Type level specification of a query for a certain set of components.