1use bevy::prelude::*;
2
3use crate::SimulState;
4
5#[derive(Default)]
6pub struct KeybindsPlugin {
7 _priv_fields_placeholder: (),
8}
9impl Plugin for KeybindsPlugin {
10 fn build(&self, app: &mut App) {
11 app.add_systems(Update, sys::hero_hop.run_if(SimulState::is_running_cond()));
12 }
13}
14
15pub mod sys {
16 use bevy::prelude::*;
17
18 use crate::simul::HeroHop;
19
20 pub fn hero_hop(
21 kbd_input: Res<ButtonInput<KeyCode>>,
22 mouse_input: Res<ButtonInput<MouseButton>>,
23 touch_input: Res<Touches>,
24 mut hop_announcer: EventWriter<HeroHop>,
25 ) {
26 for press in [
27 kbd_input.just_pressed(KeyCode::Space),
28 mouse_input.just_pressed(MouseButton::Left),
29 touch_input.any_just_pressed(),
30 ]
31 .into_iter()
32 {
33 if press {
34 hop_announcer.send(HeroHop::default());
35 }
36 }
37 }
38}