1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use edict::{action::ActionEncoder, scheduler::Scheduler, world::World, EntityId};
use edict_proc::Component;
#[derive(Component)]
pub struct Foo;
fn main() {
let mut world = World::new();
let mut scheduler = Scheduler::new();
scheduler.add_system(allocate_system);
scheduler.add_system(spawn_system);
scheduler.run_sequential(&mut world);
scheduler.run_sequential(&mut world);
assert_eq!(world.query::<&Foo>().iter().count(), 4);
}
fn allocate_system(world: &World, mut encoder: ActionEncoder) {
let entity = world.allocate();
encoder.insert(entity, Foo);
}
fn spawn_system(mut encoder: ActionEncoder) {
let _entity: EntityId = encoder.spawn((Foo,));
}