1 unstable release
0.1.0 | Nov 12, 2021 |
---|
#1426 in Encoding
Used in hv-guarded-borrow
255KB
5.5K
SLoC
Heavy ECS - hecs
shim
This crate exists to provide a shim between hecs
and Heavy, for the reason that at current Heavy
depends on several extensions to hecs
we hope to upstream soon. Until that happens, this crate
contains direct copy of our fork of the hecs
source code, subject to the same license as hecs
itself.
Once the fork is upstreamed this crate will become a single module with a single line that reexports
hecs
.
This is not expected to be used outside of Heavy.
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, (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
~1–1.3MB
~20K SLoC