소스 검색

Added documentation and examples

raster
Bergmann89 4 년 전
부모
커밋
0454c96e95
4개의 변경된 파일9개의 추가작업 그리고 13개의 파일을 삭제
  1. +1
    -0
      Cargo.lock
  2. +1
    -1
      async-ecs
  3. +1
    -1
      async-ecs-derive
  4. +6
    -11
      space-crush/src/main.rs

+ 1
- 0
Cargo.lock 파일 보기

@@ -30,6 +30,7 @@ name = "async-ecs"
version = "0.1.0"
dependencies = [
"asparit",
"async-ecs-derive",
"futures",
"hashbrown",
"hibitset",


+ 1
- 1
async-ecs

@@ -1 +1 @@
Subproject commit 0c94dac6c2a9307aba8296fb2450314250f2e8d4
Subproject commit 39fa7475beefd197f2d99e8b30ae4ec8c4e5ba12

+ 1
- 1
async-ecs-derive

@@ -1 +1 @@
Subproject commit 19038f49ebecd0d132002e4c42fe1e29440cf5a2
Subproject commit 14f0bdde2d5e4154a9f895e3b0a42970bd2aca5e

+ 6
- 11
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()


불러오는 중...
취소
저장