feat: Add berry debug binds

This commit is contained in:
demenik
2025-12-01 16:00:38 +01:00
parent 08c5312a85
commit 323f9e1e9e
2 changed files with 23 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ cargo run
- `Shift + Enter`: Duration of the current phase is set to 3 seconds.
- `Left Mouse Button` on Tile: Rotate tile state.
- `Shift + Arrow Up`: Add one berry to your inventory
- `Shift + Arrow Down`: Remove one berry from your inventory
---

View File

@@ -11,6 +11,9 @@ impl Plugin for InventoryPlugin {
app.init_resource::<Inventory>();
app.add_systems(Update, buttons.run_if(in_state(AppState::GameScreen)));
#[cfg(debug_assertions)]
app.add_systems(Update, debug_modify_berries);
}
}
@@ -40,3 +43,21 @@ fn buttons(
}
}
}
#[cfg(debug_assertions)]
fn debug_modify_berries(
mut commands: Commands,
mut inventory: ResMut<Inventory>,
mut items: Query<&mut ItemStack>,
keys: Res<ButtonInput<KeyCode>>,
) {
if keys.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight]) {
if keys.just_pressed(KeyCode::ArrowUp) {
println!("Adding 1 berry using debug bind");
inventory.update_item_stack(&mut commands, &mut items, ItemType::Berry, 1);
} else if keys.just_pressed(KeyCode::ArrowDown) {
println!("Removing 1 berry using debug bind");
inventory.update_item_stack(&mut commands, &mut items, ItemType::Berry, -1);
}
}
}