No description
Find a file
2021-03-29 12:59:20 -04:00
.github Create FUNDING.yml 2021-03-19 12:44:17 -04:00
benches add benchmarks 2020-12-20 18:05:29 -05:00
examples add example 2020-12-20 18:12:51 -05:00
src add comment about unsafe code bit. 2021-03-19 12:34:05 -04:00
.gitignore finaly remove the need to create the bitset early in user code. 2020-12-11 17:42:27 -05:00
Cargo.toml change cargo.toml version. 2021-03-29 12:59:20 -04:00
LICENSE change license to apache 2.0 2021-03-27 13:20:36 -04:00
README.md remove line from readme. 2021-03-27 23:25:30 -04:00

Support an Open Source Developer! ♥️

Become a patron

Entity Component

The entity-component part of a full ECS (Entity-Component-System).

Why would you use this ECS library?

  • Compatible with all platforms, including WASM!
  • Minimal amount of dependencies.
  • Small code size.
  • Stable, tested, benchmarked, 100% completed.

Usage

Add the following to you Cargo.toml file:

entity_component = "*"

Use it like so:

use entity_component::*;

fn main() {
    // Creating components
    struct A(f32);
    struct B(f32);
    // Creating entity repository
    let mut entities = Entities::default();
    // Creating component storages
    let mut storage = Components::<A>::default();
    let mut storage2 = Components::<B>::default();
    // Create entities and add components
    for i in 0..10000 {
        let e = entities.create();
        if i % 5 == 0 {
            storage.insert(e, A(1.0));
        }
        if i % 6 == 0 {
            storage2.insert(e, B(1.0));
        }
    }
    // Join on all entities having both A and B.
    // We take a mutable reference to the A component and an immutable
    // reference to the B component.
    join!(&mut storage && &storage2)
        .for_each(|(s, s2)| s.unwrap().0 += s2.unwrap().0);

    // Same thing, but we also get the entities id that align with the
    // matched components.
    join!(&entities && &mut storage && &storage2)
        .for_each(|(_e, s, s2)| s.unwrap().0 += s2.unwrap().0);
}

Maintainer Information

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