Entity Component System
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Florian Blasius 23fcdac9e7 Remve is_shared add is_origin. 5 days ago
.vscode [feature] init and cleanup system. 7 months ago
examples Introduced ComponentStore 2 weeks ago
src Remve is_shared add is_origin. 5 days ago
tests Introduced ComponentStore 2 weeks ago
.gitignore [update] rust 2018 part I 7 months ago
.gitlab-ci.yml Update .gitlab-ci.yml 6 days ago
CHANGELOG.md Introduced ComponentStore 2 weeks ago
Cargo.toml fix. 2 weeks ago
LICENSE Update. 1 year ago
README.md 0.2 update. 2 weeks ago

README.md

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 organisation (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.2"

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<VecEntityStore> for PrintSystem {
    fn run(&self, entities: &VecEntityStore, ecm: &mut EntityComponentManager) {
        for entity in &entities.inner {
            if let Ok(comp) = ecm.borrow_component::<Name>(*entity) {
                println!("{}", comp.value);
            }
        }
    }
}

fn main() {
    let mut world = World::<VecEntityStore>::new();

    world.create_entity().with(Name { value: String::from("DCES") }).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 documenation

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.