6 stable releases

1.2.1 Jun 21, 2021
1.2.0 May 14, 2021
1.1.2 Mar 29, 2021

#989 in Game dev

Download history 3/week @ 2024-08-26 16/week @ 2024-09-23

97 downloads per month

Apache-2.0

175KB

Planck ECS Planck ECS

The full ECS (Entity-Component-System) library.

Support an Open Source Developer! ♥️
Become a patron

Composed of two smaller libraries:

Read the documentation.

Why would you use this ECS library?

  • Compatible with all platforms, including WASM!
  • Fast enough on every operation, not just iteration.
  • Minimal amount of dependencies.
  • Small code size.
  • Stable, tested, benchmarked, 100% completed.
  • Ability to handle system errors instead of crashing.
  • Convert both functions and closures into systems!
  • Safe: only 3 unsafe in total. (compared to hundreds in mainstream ECS libraries!)

Usage

Add the following to you Cargo.toml file:

planck_ecs = "*"

Use it like so:

use planck_ecs::*;
fn main() {
    #[derive(Default)]
    pub struct A;

    let mut world = World::default();

    let sys = (|comps: &mut Components<A>, entities: &mut Entities| {
        let entity = entities.create();
        comps.insert(entity, A);
        Ok(())
    }).system();

    let mut dispatch = DispatcherBuilder::new().add_system(sys).build(&mut world);
    dispatch.run_seq(&world).unwrap();
    dispatch.run_seq(&world).unwrap();
    dispatch.run_seq(&world).unwrap();

    assert!(world.get::<Components<A>>().is_ok());
}

For more examples, see the two following repositories' example folders and documentation:

Maintainer Information

  • Maintainer: Jojolepro
  • Contact: jojolepro [at] jojolepro [dot] com
  • Website: jojolepro.com
  • Patreon: patreon

Dependencies

~0.6–1.4MB
~25K SLoC