Fixed firearm frozen bug

This commit is contained in:
Franklin 2023-11-15 11:07:02 -04:00
parent 9538f73075
commit 8c30ba6d9f
3 changed files with 6 additions and 4 deletions

View File

@ -73,7 +73,7 @@ pub fn capture_hand_usage(
for (player, mut player_inventory, _player_entity, player_transform, mut player_firing_info) in player_query.iter_mut() { for (player, mut player_inventory, _player_entity, player_transform, mut player_firing_info) in player_query.iter_mut() {
// Equipping gun // Equipping gun
// Validate player has primary item, and secondary item in inventory // Validate player has primary item, and secondary item in inventory
if !resources.game_ui_state.any_window() { if !resources.game_ui_state.any_window() && !player_firing_info.is_reloading {
if resources.keyboard_input.just_pressed(KeyCode::Key1) { if resources.keyboard_input.just_pressed(KeyCode::Key1) {
if let Some(primary_item) = player_inventory.get_primary() { if let Some(primary_item) = player_inventory.get_primary() {
if let Some(primary_firearm) = primary_item.get_firearm() { if let Some(primary_firearm) = primary_item.get_firearm() {
@ -108,14 +108,13 @@ pub fn capture_hand_usage(
Some(current_slot) => { Some(current_slot) => {
player_inventory::drop_slot_in_game_world(&mut commands, player_transform, &mut inventory_changed_events, &mut player_inventory, &resources.assets_gltf, &resources.loaded_gltf_assets, current_slot); player_inventory::drop_slot_in_game_world(&mut commands, player_transform, &mut inventory_changed_events, &mut player_inventory, &resources.assets_gltf, &resources.loaded_gltf_assets, current_slot);
equipment_change_event_writer.send(EquipmentChangeEvent(Equipment::Nothing)); equipment_change_event_writer.send(EquipmentChangeEvent(Equipment::Nothing));
player_inventory.current_slot = None;
}, },
None => {}, None => {},
} }
} }
} }
// Firearm stuff // Firearm stuff
if let Equipment::Firearm(player_firearm) = player.0.equipment.clone() { if let Equipment::Firearm(player_firearm) = player.0.equipment.clone() {
player_firing_info player_firing_info

View File

@ -38,6 +38,7 @@ pub fn change_equipment(
let Ok((mut player, player_firing_info)) = player_query.get_single_mut() else { let Ok((mut player, player_firing_info)) = player_query.get_single_mut() else {
return; return;
}; };
//if player_firing_info.is_reloading { return; }
// Primary firearm change // Primary firearm change
let player_hands = player_hands_query.single_mut(); let player_hands = player_hands_query.single_mut();

View File

@ -44,6 +44,7 @@ pub fn setup_inventory_screen(mut commands: Commands) {
flex_direction: FlexDirection::Column, flex_direction: FlexDirection::Column,
..Default::default() ..Default::default()
}, },
background_color: BackgroundColor(Color::RED),
..Default::default() ..Default::default()
}) })
.set_parent(background_id) .set_parent(background_id)
@ -65,10 +66,11 @@ pub fn setup_inventory_screen(mut commands: Commands) {
}) })
.set_parent(background_id) .set_parent(background_id)
.id(); .id();
} }
pub fn update_inventory_screen( pub fn update_inventory_screen(
mut commands: Commands, //mut commands: Commands,
game_ui_state: Res<GameUiState>, game_ui_state: Res<GameUiState>,
mut inventory_screen_query: Query<&mut Visibility, With<InventoryScreenUiMarker>>, mut inventory_screen_query: Query<&mut Visibility, With<InventoryScreenUiMarker>>,
) { ) {