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"
According to ECS Design Crossroads, specs
fulfills all the requirements, has In-place modification updates, and Generational ID entities.
See ecs_bench for single- and multi-threaded performance comparisons.
Component
)! Neither Copy
or even Clone
bounds are needed.Entity creation:
rust
let mut planner = {
let mut w = specs::World::new();
// All components types should be registered before working with them
w.register::<Position>();
w.register::<Speed>();
// create_now() of World provides with an EntityBuilder to add components to an Entity
w.create_now().with(Position(0)).with(Speed(2)).build();
w.create_now().with(Position(-1)).with(Speed(100)).build();
w.create_now().with(Position(127)).build();
// Planner is used to run systems on the specified world with a specified number of threads
specs::Planner::new(w, 4)
};
System run:
rust
planner.run1w1r(|p: &mut Position, s: &Speed| {
*p += *s;
});