Crate dces[][src]

DCES

DCES is a library that provides a variant of the entity component system.

Features:

  • Filter and sort entities for systems
  • Define priorities (run order) for systems

The library is still WIP. API changes are possible.

MIT licensed

Example

extern crate dces;
use dces::prelude::*;

struct Name { value: String }

struct PrintSystem;

impl System for PrintSystem {
    fn run(&self, entities: &Vec<Entity>, ecm: &mut EntityComponentManager) {
        for entity in entities {
            if let Ok(comp) = ecm.borrow_component::<Name>(*entity) {
                println!("{}", comp.value);
            }
        }
    }
}

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

    world.create_entity().with(Name { value: String::from("DCES") }).build();
    world.create_system(PrintSystem).build();

    world.run();
}

Re-exports

pub use self::entity::Component;
pub use self::entity::ComponentBox;
pub use self::entity::Entity;
pub use self::entity::EntityBuilder;
pub use self::entity::EntityComponentManager;
pub use self::entity::EntityContainer;
pub use self::entity::VecEntityContainer;
pub use self::error::NotFound;
pub use self::system::EntitySystem;
pub use self::system::EntitySystemBuilder;
pub use self::system::EntitySystemManager;
pub use self::system::Priority;
pub use self::system::System;
pub use self::world::World;

Modules

entity
error
prelude
system
world