ten3roberts / hecs-schedule

Pararell execution framwork for hecs
MIT License
8 stars 3 forks source link

How CommandBuffers are used in a system? #4

Closed konceptosociala closed 1 year ago

konceptosociala commented 1 year ago

There is not examples of using CommandBuffer in a system,

fn create_camera(
    cmd: CommandBuffer,
){
    cmd.spawn(CameraBundle{
        camera: Camera::builder().build(),
        transform: Transform::default(),
    });
}

so this causes the compilation error

error[E0277]: the trait bound `fn(hecs_schedule::CommandBuffer) {create_camera}: hecs_schedule::System<_, _>` is not satisfied
  --> examples/test.rs:8:15
   |
8  |         .add_system(create_camera)
   |          ---------- ^^^^^^^^^^^^^ the trait `hecs_schedule::System<_, _>` is not implemented for `fn(hecs_schedule::CommandBuffer) {create_camera}`
   |          |
   |          required by a bound introduced by this call
   |
   = help: the trait `hecs_schedule::System<Args, Ret>` is implemented for `NamedSystem<F>`
note: required by a bound in `despero::Despero::add_system`
  --> /home/viburno/Dokumentujo/Rusto/despero/src/lib.rs:51:22
   |
51 |         S: 'static + System<Args, Ret> + Send,
   |                      ^^^^^^^^^^^^^^^^^ required by this bound in `despero::Despero::add_system`
ten3roberts commented 1 year ago

Yes, you will have to use the Write accessor, much like when accessing the whole world.

I added the usage to the README.

Thanks for the issue :)