specs
Specs is an Entity-Component System written in Rust. It aims for parallel systems execution with high ergonomics and flexibility. The name can be interpret in a number of ways:
- "SPECS Parallel ECS"
- "Super Powerful ECS"
- "Special ECS"
Classification
According to ECS Design Crossroads, specs
fulfills all the requirements, has In-place modification updates, and Generational ID entities.
Features
- Automatic execution of the systems in parallel. Follows Rust ownership rules, where each component storage behaves as a variable. Depends on the order, in which systems are started.
- Component storage is abstract behind the trait. One can use vectors, hashmaps, trees, or whatever else.
- New components can be registered at any point from user modules. They don't have to be POD.
- No virtual calls, low overhead.
Why is it fast
- Do you know many other natively parallel ECS in Rust?
- Abstract storage means you can choose the most efficient one according to your needs. You can even roll in your own.
- No virtual calls during systems processing means you work with the data directly.
See ecs_bench for single- and multi-threaded performance comparisons.
Why is it cool
- Your system can be as simple as a closure working on some components, no redundant info or boilerplate is needed. At the same time, you can manually fiddle with entities and components, and it would still be safe and convenient.
- Your components can be anything (as long as they implement
Component
)! NeitherCopy
or evenClone
bounds are needed. - Your component storages can be anything. Consider crazy stuff like a BSP tree, or a database over the network. Some storages can safely allow sharing their components between entities, some can not - but it's up to you to choose.
Examples
Entity creation:
let mut planner = ;
System run:
planner.run1w1r;
Custom system: