diff --git a/Cargo.lock b/Cargo.lock index f995e25..989db05 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -30,6 +30,7 @@ name = "async-ecs" version = "0.1.0" dependencies = [ "asparit", + "async-ecs-derive", "futures", "hashbrown", "hibitset", diff --git a/async-ecs b/async-ecs index 0c94dac..39fa747 160000 --- a/async-ecs +++ b/async-ecs @@ -1 +1 @@ -Subproject commit 0c94dac6c2a9307aba8296fb2450314250f2e8d4 +Subproject commit 39fa7475beefd197f2d99e8b30ae4ec8c4e5ba12 diff --git a/async-ecs-derive b/async-ecs-derive index 19038f4..14f0bdd 160000 --- a/async-ecs-derive +++ b/async-ecs-derive @@ -1 +1 @@ -Subproject commit 19038f49ebecd0d132002e4c42fe1e29440cf5a2 +Subproject commit 14f0bdde2d5e4154a9f895e3b0a42970bd2aca5e diff --git a/space-crush/src/main.rs b/space-crush/src/main.rs index e6f82f0..521669a 100644 --- a/space-crush/src/main.rs +++ b/space-crush/src/main.rs @@ -48,8 +48,8 @@ async fn run() -> Result<(), Error> { info!("World initialized!"); let mut dispatcher = Dispatcher::builder() - .with(ParMove, "move", &[])? - .with(ParAccelerate, "accelerate", &["move"])? + .with_async(ParMove, "move", &[])? + .with_async(ParAccelerate, "accelerate", &["move"])? .build(); info!("Setup done!"); @@ -153,25 +153,21 @@ impl<'a> System<'a> for SeqMove { } } -impl<'a> AsyncSystem<'a> for SeqAccelerate { +impl<'a> System<'a> for SeqAccelerate { type SystemData = (WriteStorage<'a, Velocity>, ReadStorage<'a, Acceleration>); - type Future = futures::future::Ready<()>; - fn run(&mut self, (mut velocity, acceleration): Self::SystemData) -> Self::Future { + fn run(&mut self, (mut velocity, acceleration): Self::SystemData) { for (velocity, acceleration) in (&mut velocity, &acceleration).join() { velocity.x += acceleration.x; velocity.y += acceleration.y; } - - futures::future::ready(()) } } impl<'a> AsyncSystem<'a> for ParMove { type SystemData = (WriteStorage<'a, Position>, ReadStorage<'a, Velocity>); - type Future = BoxFuture<'a, ()>; - fn run(&mut self, (mut position, velocity): Self::SystemData) -> Self::Future { + fn run_async(&mut self, (mut position, velocity): Self::SystemData) -> BoxFuture<'a, ()> { async move { (&mut position, &velocity) .par_join() @@ -188,9 +184,8 @@ impl<'a> AsyncSystem<'a> for ParMove { impl<'a> AsyncSystem<'a> for ParAccelerate { type SystemData = (WriteStorage<'a, Velocity>, ReadStorage<'a, Acceleration>); - type Future = BoxFuture<'a, ()>; - fn run(&mut self, (mut velocity, acceleration): Self::SystemData) -> Self::Future { + fn run_async(&mut self, (mut velocity, acceleration): Self::SystemData) -> BoxFuture<'a, ()> { async move { (&mut velocity, &acceleration) .par_join()