4 releases (2 stable)

1.1.0 Jun 22, 2020
1.0.0 Jun 9, 2020
0.1.1 Feb 16, 2020
0.1.0 Feb 16, 2020

#1218 in Game dev

MIT license

26KB
546 lines

tecs

TeaECS is a simple Rust ECS. I'm building this project for learning purposes.

This project doesn't have the ambition to be as good or better than popular ECS libraries such as Legion or Specs. It is however heavily inspired by them.

The entities' data are stored in unique Vecs (one for each component type).

tecs doesn't provide parallel processing features.

Using tecs

Creating entities

let mut ecs = Ecs::new();
let entity_id = ecs.new_entity()
    .with_component(Position { x: 0.5, y: 0.3 })
    .with_component(Speed { x: 1.0, y: 2.0 })
    .build();

Removing entities

ecs.remove_entity(1);

Querying the Ecs

let mut ecs = Ecs::new();
ecs.new_entity()
    .with_component(Position { x: 0.5, y: 0.3 })
    .with_component(Speed { x: 1.0, y: 2.0 })
    .build();
ecs.new_entity()
    .with_component(Position { x: 1.2, y: 2.2 })
    .with_component(Speed { x: 0.5, y: 0.1 })
    .build();

for (position, speed) in <(Mut<Position>, Imm<Speed>)>::iter(&mut ecs) {
    position.x += speed.x;
    position.y += speed.y;
}

Contributing

Feel free to create issues and pull requests to the project.

Dependencies

~440KB