Anvaya
ECS like dynamic storage in ~500 LOC.
🚧 WIP toy project. Use at your own risk ⚠️
use *;
// Create Components (of any type with no boilerplate)...
;
;
// World and spawn...
let mut world = new;
world.spawn.insert.insert;
world.spawn.insert.insert;
// Query and filter...
let mut query = world.query;
let mut results = query
.
.
.unwrap
.map;
// Validate...
assert_eq!;
assert_eq!;
Features
- Simple implementation using the
TypeMapdata structure. - No
unsafe, noClone, no smart pointers/atomics. JustBox<dyn Any>. - Uses
Slabas default tabular storage. But allows swapping it for your own custom storage by impl a few traits likeStorageetc. Seecustom_storage.rsexample.
The above features are subject to change based on the goals of the project.
Limitations
- Does not strictly follow an ECS architecture (with Archetypes etc).
- Currently supports only few methods and limited queries. Queries to get or mutate multiple components together are not yet supported.
Goals
- Allow more ECS like queries and mutations in the future.
- Thus follow a more ECS like architecture to achieve the above.
Motivations
- Started as a toy project experimenting with dynamic storage in a strictly type safe language like Rust.
- With the end goal of building an ECS like data structure, there were key learnings wrt Generic Types, Traits, and Lifetimes in Rust.
- Type storage using
Box<dyn Any>and type identifications usingTypeIDled to creation of data structures likeTypeMap. This was the key inspiration to start this project.