SHARE
TWEET

tower_placer.rs

a guest Jan 21st, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[derive(SystemDesc)]
  2. #[system_desc(name(TowerPlacerDesc))]
  3. pub struct TowerPlacer {
  4.     #[system_desc(event_channel_reader)]
  5.     reader_id: ReaderId<InputEvent<MicroTdBindingTypes>>,
  6. }
  7.  
  8. impl TowerPlacer {
  9.     pub fn new(reader_id: ReaderId<InputEvent<MicroTdBindingTypes>>) -> Self {
  10.         Self { reader_id }
  11.     }
  12. }
  13.  
  14. impl<'s> System<'s> for TowerPlacer {
  15.     type SystemData = (
  16.         Read<'s, EventChannel<InputEvent<MicroTdBindingTypes>>>,
  17.        Entities<'s>,
  18.         WriteStorage<'s, Tower>,
  19.        ReadStorage<'s, Player>,
  20.         WriteStorage<'s, Transform>,
  21.    );
  22.  
  23.    fn run(&mut self, (events, entities, towers, players, transforms): Self::SystemData) {
  24.        for event in events.read(&mut self.reader_id) {
  25.            for (_, transform) in (&players, &transforms).join() {
  26.                match event {
  27.                    InputEvent::ActionPressed(binding) => info!("{}", binding),
  28.                    _ => {}
  29.                }
  30.            }
  31.        }
  32.    }
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top