9 releases

0.3.0 Aug 13, 2020
0.2.0 Nov 15, 2019
0.1.6 Jan 16, 2019
0.1.2 Dec 29, 2018
0.1.1 Oct 15, 2018

#158 in Game dev

Download history 57/week @ 2021-06-07 56/week @ 2021-06-14 45/week @ 2021-06-21 44/week @ 2021-06-28 55/week @ 2021-07-05 48/week @ 2021-07-12 66/week @ 2021-07-19 50/week @ 2021-07-26 66/week @ 2021-08-02 69/week @ 2021-08-09 41/week @ 2021-08-16 49/week @ 2021-08-23 16/week @ 2021-08-30 41/week @ 2021-09-06 39/week @ 2021-09-13 34/week @ 2021-09-20

268 downloads per month
Used in 4 crates (3 directly)

MIT license

52KB
1K SLoC

DCES

DCES is a library that provides a variant of the Entity Component System: https://en.wikipedia.org/wiki/Entity–component–system.

The goal of DCES is a lightweight ECS library with zero dependencies used by UI frameworks and game engines. It is being developed as part of OrbTk an (G)UI framework written in Rust. All widgets and properties of OrbTk are handled by DCES.

Build status MIT licensed crates.io docs.rs

Features:

  • Register entities with components
  • Share components between entities
  • Register systems and read / write components of entities
  • Order systems execution by priority
  • Register container for entity organization (Vec, HashMap, Custom Container, ...)
  • Register init and cleanup system

Usage

To include DCES in your project, just add the dependency line to your Cargo.toml file:

dces = "0.3"

To use DCES master, just add the dependency line to your Cargo.toml file:

dces = { git = https://gitlab.redox-os.org/redox-os/dces-rust.git }

Example

use dces::prelude::*;

#[derive(Default)]
struct Name {
    value: String,
}

struct PrintSystem;

impl System<EntityStore, ComponentStore> for PrintSystem {
    fn run(&self, ecm: &mut EntityComponentManager<EntityStore, ComponentStore>) {
        let (e_store, c_store) = ecm.stores();

        for entity in &e_store.inner {
            if let Ok(comp) = c_store.get::<Name>(*entity) {
                println!("{}", comp.value);
            }
        }
    }
}

fn main() {
    let mut world = World::<EntityStore, ComponentStore>::new();

    world
        .create_entity()
        .components(
            ComponentBuilder::new()
                .with(Name {
                    value: String::from("DCES"),
                })
                .build(),
        )
        .build();

    world.create_system(PrintSystem).build();
    world.run();
}

You could find additional examples in the examples/ directory.

You can start the basic example by executing the following command:

cargo run --example basic

Build and run documentation

You can build and run the latest documentation by executing the following command:

cargo doc --no-deps --open

Future features

  • Concurrency of systems with same priority
  • Advanced example
  • Book

Inspirations

FAQ

Why not Specs

Because DCES is developed to fulfill the requirements of OrbTk. To reduce the dependency tree of OrbTk DCES depends on zero crates.

License

Licensed under MIT license (LICENSE).

No runtime deps

Features

  • no_std