use bevy::prelude::*; use crate::{Brick, GameState, WORLD_SIZE}; pub struct DebugPlugin; impl Plugin for DebugPlugin { fn build(&self, app: &mut App) { if !cfg!(feature = "debug") { return; } app.add_systems( Update, ( draw_world_bounds, log_state_transitions.run_if(state_changed::), cheat_codes, ), ); } } fn draw_world_bounds(mut gizmos: Gizmos) { gizmos.rect_2d( Isometry2d::from_translation(WORLD_SIZE / 2.), WORLD_SIZE, LinearRgba::RED, ); } fn log_state_transitions(state: Res>) { info!({ ?state }, "State changed"); } fn cheat_codes( mut commands: Commands, input: Res>, bricks: Query>, ) { if input.pressed(KeyCode::Digit1) { let mut iter = bricks.iter(); _ = iter.next(); for entity in iter { commands.entity(entity).despawn(); } } }