1 unstable release
new 0.5.0 | Mar 14, 2025 |
---|
#1697 in Game dev
310KB
5.5K
SLoC
Gloss Hecs
A small wrapper around hecs with convenience functions.
To be used with gloss.
lib.rs
:
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);
Dependencies
~45–77MB
~1.5M SLoC