checs
An Entity-Component-System library.
Example
This is a very basic example of how to use checs.
You can find this example at examples/basic.rs. Run it with:
Define some components and a World to store them in.
Note: Components are just plain old Rust types.
;
;
impl_storage!;
let mut world = new;
Create entities with initial components.
let player = world.spawn;
world.put;
world.put;
world.put;
let obstacle = world.spawn;
world.put;
world.put;
let trap = world.spawn;
world.put;
let enemy = world.spawn;
world.put;
world.put;
world.put;
Find the entities that have some components.
use LendingIterator;
use Join;
let ps = &world.storage.positions;
let vs = &world.storage.visibles;
let mut query = .join;
while let Some = query.next
// Entity(0) is Visible at (0, 0)
// Entity(1) is Visible at (1, 1)
// Entity(3) is Visible at (1, 4)