diff --git a/src/debug_plugin.rs b/src/debug_plugin.rs index 3016bee9..635a2b7a 100644 --- a/src/debug_plugin.rs +++ b/src/debug_plugin.rs @@ -5,7 +5,11 @@ pub struct BoidsDebugPlugin; impl Plugin for BoidsDebugPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup) - .add_systems(FixedUpdate, update_cursor); + .add_systems(FixedUpdate, ( + update_cursor, + update_scanner_mode, + print_gizmo_config, + )); } } @@ -44,13 +48,13 @@ impl Default for ScannerWidget { #[derive(Component)] struct Cursor; -#[derive(Component)] +#[derive(Component, Debug)] enum SelectionMode { NearestSingle, CircularArea, } -#[derive(Component)] +#[derive(Component, Debug)] enum ScannerMode { CenterOfMass, Velocity, @@ -77,3 +81,35 @@ fn update_cursor( cursor.translation = cursor_in_world.extend(0.0); } } + +// System to monitor for mouse and keyboard input and then update +// the scanner's modes accordingly. +fn update_scanner_mode( + keycodes: Res>, + mousebuttons: Res>, + mut scanner_query: Query<(&mut SelectionMode, &mut ScannerMode), With>, +) { + // I'm making another assertion that there is exactly one scanner. + let (mut select_mode, mut scan_mode) = scanner_query.get_single_mut().unwrap(); + + // Assign selection mode + if keycodes.just_pressed(KeyCode::Digit1) { + *select_mode = SelectionMode::NearestSingle; + } else if keycodes.just_pressed(KeyCode::Digit2) { + *select_mode = SelectionMode::CircularArea; + } + + // Select property scanning mode + if mousebuttons.just_pressed(MouseButton::Left) { + *scan_mode = ScannerMode::CenterOfMass; + } else if mousebuttons.just_pressed(MouseButton::Right) { + *scan_mode = ScannerMode::Velocity; + } +} + +fn print_gizmo_config( + query: Query<(&SelectionMode, &ScannerMode), With>, +) { + let (select, scan) = query.get_single().unwrap(); + println!("Selection: {select:?}, Scanning: {scan:?}"); +} \ No newline at end of file