specs

Build Status Crates.io Gitter

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

Why is it fast

See ecs_bench for single- and multi-threaded performance comparisons.

Why is it cool

Examples

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; }); Custom system: rust impl System<u32> for MySystem { fn run(&mut self, arg: RunArg, context: u32) { let mut numbers = arg.fetch(|w| w.write::<u32>()); for n in (&numbers).iter() { *n += context; } } }