[−][src]Crate hecs
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 i32, &bool)>().iter() { 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);
Structs
Archetype | A collection of entities having the same component types |
ArchetypesGeneration | Determines freshness of information derived from |
BatchedIter | Batched version of |
BuiltEntity | The output of an |
Entity | Lightweight unique ID of an entity |
EntityBuilder | Helper for incrementally constructing a bundle of components with dynamic component types |
EntityRef | Handle to an entity with any component types |
Iter | Iterator over all of a world's entities |
MissingComponent | Error indicating that an entity did not have a required component |
NoSuchEntity | Error indicating that no entity with a particular ID exists |
QueryBorrow | A borrow of a |
QueryIter | Iterator over the set of entities with the components in |
QueryOne | A borrow of a |
Ref | Shared borrow of an entity's component |
RefMut | Unique borrow of an entity's component |
SpawnBatchIter | Entity IDs created by |
With | Query transformer skipping entities that do not have a |
Without | Query transformer skipping entities that have a |
World | An unordered collection of entities, each having any number of distinctly typed components |
Enums
Access | Type of access a |
ComponentError | Errors that arise when accessing components |
Traits
Bundle | A statically typed collection of components |
Component | Types that can be components, implemented automatically for all |
DynamicBundle | A dynamically typed collection of components |
Query | A collection of component types to fetch from a |
Derive Macros
Bundle | Implement |