Crate despero_hecs

source ·
Expand description

A handy ECS

hecs provides a high-performance, minimalist entity-component-system (ECS) world. It is a library, not a framework. In place of an explicit “System” abstraction, a World’s entities are easily queried from regular code. Organize your application however you like!

In order of importance, hecs pursues:

  • fast traversals
  • a simple interface
  • a small dependency closure
  • exclusion of externally-implementable functionality
let mut world = World::new();
// Nearly any type can be used as a component with zero boilerplate
let a = world.spawn((123, true, "abc"));
let b = world.spawn((42, false));
// Systems can be simple for loops
for (id, (mut number, &flag)) in world.query_mut::<(&mut i32, &bool)>() {
  if flag { *number *= 2; }
}
// Random access is simple and safe
assert_eq!(*world.get::<&i32>(a).unwrap(), 246);
assert_eq!(*world.get::<&i32>(b).unwrap(), 42);

Re-exports

Modules

Structs

Enums

Traits

  • Types that can be components, implemented automatically for all Send + Sync + 'static types
  • &T or &mut T where T is some component type
  • &T where T is some component type

Derive Macros