ecs-tiny 0.1.0

A minimal ECS supporting entity and component insertion/removal, association, and single-type iteration.
Documentation

ecs-tiny

crates.io doc.rs

A minimal ECS supporting entity and component insertion/removal, association, and single-type iteration.

Usages

Create new ecs instance and inserts new entity:

let mut ecs = ecs_tiny::ECS::new();

let entity_key0 = ecs.insert_entity();
let entity_key1 = ecs.insert_entity();

Inserts new component associated with specified entity:

let comp_key0 = ecs.insert_component(entity_key, 42);
let comp_key1 = ecs.insert_component(entity_key, 63);
let comp_key2 = ecs.insert_component(entity_key, 42);
let comp_key3 = ecs.insert_component(entity_key, ());

Iterates over all components associated with specified entity:

for comp in ecs.iter_comp_mut_by_entity::<i32>(entity_key0) {
    *comp += 1;
}

Iterates over all components of specified type:

for comp in ecs.iter_comp_mut::<i32>() {
    *comp += 1;
}

Removes specified component:

ecs.remove_comp::<i32>(comp_key0);

Removes specified entity:

ecs.remove_entity(entity_key1);