You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
672 B

  1. use specs::{Dispatcher as Inner, DispatcherBuilder, World};
  2. use crate::{
  3. resources::Global,
  4. systems::{Movement, Process},
  5. };
  6. pub struct Dispatcher<'a, 'b> {
  7. dispatcher: Inner<'a, 'b>,
  8. }
  9. impl<'a, 'b> Dispatcher<'a, 'b> {
  10. pub fn new(world: &mut World) -> Self {
  11. world.insert(Global::default());
  12. let mut dispatcher = DispatcherBuilder::new()
  13. .with(Process::default(), "process", &[])
  14. .with(Movement::default(), "movement", &[])
  15. .build();
  16. dispatcher.setup(world);
  17. Self { dispatcher }
  18. }
  19. pub fn process(&mut self, world: &World) {
  20. self.dispatcher.dispatch(world);
  21. }
  22. }