From 779d4eeef08f52a5d9dee2df33de065bebd698ba Mon Sep 17 00:00:00 2001 From: Jan Hohenheim Date: Mon, 26 Feb 2024 11:41:24 +0100 Subject: [PATCH] Do some trivial updates --- src/dev.rs | 2 +- src/ingame_menu.rs | 2 +- src/level_instantiation/map.rs | 2 +- src/player_control/actions.rs | 14 ++++++++------ src/player_control/camera/kind.rs | 2 +- src/player_control/camera/rig.rs | 4 ++-- src/player_control/camera/rig/arm.rs | 2 +- src/player_control/player_embodiment.rs | 8 ++++---- src/world_interaction/dialog.rs | 2 +- src/world_interaction/interactions_ui.rs | 6 +++--- 10 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/dev.rs b/src/dev.rs index f0e1342f..808b3cf2 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -36,7 +36,7 @@ fn default_editor_controls() -> bevy_editor_pls::controls::EditorControls { editor_controls.insert( Action::PlayPauseEditor, Binding { - input: UserInput::Single(Button::Keyboard(KeyCode::G)), + input: UserInput::Single(Button::Keyboard(KeyCode::KeyG)), conditions: vec![BindingCondition::ListeningForText(false)], }, ); diff --git a/src/ingame_menu.rs b/src/ingame_menu.rs index 53d38b68..5a9976da 100644 --- a/src/ingame_menu.rs +++ b/src/ingame_menu.rs @@ -22,7 +22,7 @@ fn handle_pause( mut paused: Local, ) { for action in actions.iter() { - let toggled = action.just_pressed(UiAction::TogglePause); + let toggled = action.just_pressed(&UiAction::TogglePause); if toggled { if *paused { *paused = false; diff --git a/src/level_instantiation/map.rs b/src/level_instantiation/map.rs index e59322ba..f35b2930 100644 --- a/src/level_instantiation/map.rs +++ b/src/level_instantiation/map.rs @@ -10,7 +10,7 @@ pub(crate) fn map_plugin(app: &mut App) { .add_systems( Update, show_loading_screen - .run_if(not(any_with_component::()).and_then(in_state(GameState::Playing))), + .run_if(not(any_with_component::).and_then(in_state(GameState::Playing))), ); } diff --git a/src/player_control/actions.rs b/src/player_control/actions.rs index 09faf8fd..bf36ed94 100644 --- a/src/player_control/actions.rs +++ b/src/player_control/actions.rs @@ -119,16 +119,18 @@ pub(crate) fn remove_actions_when_frozen( mut camera_actions_query: Query<&mut ActionState>, ) { for mut player_actions in player_actions_query.iter_mut() { - player_actions.action_data_mut(PlayerAction::Move).axis_pair = Some(default()); - player_actions.release(PlayerAction::Jump); - player_actions.release(PlayerAction::Interact); - player_actions.release(PlayerAction::Sprint); + player_actions + .action_data_mut(&PlayerAction::Move) + .axis_pair = Some(default()); + player_actions.release(&PlayerAction::Jump); + player_actions.release(&PlayerAction::Interact); + player_actions.release(&PlayerAction::Sprint); } for mut camera_actions in camera_actions_query.iter_mut() { camera_actions - .action_data_mut(CameraAction::Orbit) + .action_data_mut(&CameraAction::Orbit) .axis_pair = Some(default()); - camera_actions.action_data_mut(CameraAction::Zoom).value = default(); + camera_actions.action_data_mut(&CameraAction::Zoom).value = default(); } } diff --git a/src/player_control/camera/kind.rs b/src/player_control/camera/kind.rs index 6f14e7d0..aad13294 100644 --- a/src/player_control/camera/kind.rs +++ b/src/player_control/camera/kind.rs @@ -14,7 +14,7 @@ pub(crate) fn update_kind( config: Res, ) { for (mut camera, actions) in camera_query.iter_mut() { - let zoom = actions.clamped_value(CameraAction::Zoom); + let zoom = actions.clamped_value(&CameraAction::Zoom); let zoomed_out = zoom < -1e-5; let zoomed_in = zoom > 1e-5; let new_kind = match camera.kind { diff --git a/src/player_control/camera/rig.rs b/src/player_control/camera/rig.rs index f1d34094..d4565bfb 100644 --- a/src/player_control/camera/rig.rs +++ b/src/player_control/camera/rig.rs @@ -58,7 +58,7 @@ pub(crate) fn update_rig( fn get_camera_movement(actions: &ActionState) -> Vec2 { actions - .axis_pair(CameraAction::Orbit) + .axis_pair(&CameraAction::Orbit) .map(|pair| pair.xy()) .unwrap_or_default() } @@ -112,7 +112,7 @@ fn set_desired_distance( actions: &ActionState, config: &GameConfig, ) { - let zoom = actions.clamped_value(CameraAction::Zoom) * config.camera.third_person.zoom_speed; + let zoom = actions.clamped_value(&CameraAction::Zoom) * config.camera.third_person.zoom_speed; let (min_distance, max_distance) = match camera.kind { IngameCameraKind::ThirdPerson => ( config.camera.third_person.min_distance, diff --git a/src/player_control/camera/rig/arm.rs b/src/player_control/camera/rig/arm.rs index be776fd7..ec46430a 100644 --- a/src/player_control/camera/rig/arm.rs +++ b/src/player_control/camera/rig/arm.rs @@ -87,7 +87,7 @@ fn get_distance_to_collision( fn get_distance_such_that_min_distance_from_collision_is_ensured( hit: RayHitData, - direction: Vec3, + direction: Direction3d, min_distance: f32, ) -> f32 { // Wall diff --git a/src/player_control/player_embodiment.rs b/src/player_control/player_embodiment.rs index 0d53b9ba..342a269d 100644 --- a/src/player_control/player_embodiment.rs +++ b/src/player_control/player_embodiment.rs @@ -46,7 +46,7 @@ fn handle_jump(mut player_query: Query<(&ActionState, &mut Jump), #[cfg(feature = "tracing")] let _span = info_span!("handle_jump").entered(); for (actions, mut jump) in &mut player_query { - jump.requested |= actions.pressed(PlayerAction::Jump); + jump.requested |= actions.pressed(&PlayerAction::Jump); } } @@ -58,11 +58,11 @@ fn handle_horizontal_movement( #[cfg(feature = "tracing")] let _span = info_span!("handle_horizontal_movement").entered(); let Some((camera, camera_transform)) = camera_query.iter().next() else { - return; + return Ok(()); }; for (actions, mut walk, mut sprint) in &mut player_query { - let Some(axis) = actions.axis_pair(PlayerAction::Move) else { + let Some(axis) = actions.axis_pair(&PlayerAction::Move) else { continue; }; if let Some(movement) = axis.max_normalized() { @@ -88,7 +88,7 @@ fn handle_horizontal_movement( let direction = forward_action * modifier + sideways_action; walk.direction = Some(direction); - sprint.requested = actions.pressed(PlayerAction::Sprint); + sprint.requested = actions.pressed(&PlayerAction::Sprint); } } } diff --git a/src/world_interaction/dialog.rs b/src/world_interaction/dialog.rs index 71e25903..5d90b4f1 100644 --- a/src/world_interaction/dialog.rs +++ b/src/world_interaction/dialog.rs @@ -14,7 +14,7 @@ pub(crate) fn dialog_plugin(app: &mut App) { .add_systems( Update, ( - spawn_dialogue_runner.run_if(resource_added::()), + spawn_dialogue_runner.run_if(resource_added::), unfreeze_after_dialog.after(ExampleYarnSpinnerDialogueViewSystemSet), ), ); diff --git a/src/world_interaction/interactions_ui.rs b/src/world_interaction/interactions_ui.rs index 5f35f713..430f88c2 100644 --- a/src/world_interaction/interactions_ui.rs +++ b/src/world_interaction/interactions_ui.rs @@ -31,7 +31,7 @@ pub(crate) fn interactions_ui_plugin(app: &mut App) { .run_if( not(is_frozen) .and_then(in_state(GameState::Playing)) - .and_then(any_with_component::()), + .and_then(any_with_component::), ), ); } @@ -135,7 +135,7 @@ fn display_interaction_prompt( mut freeze: ResMut, ) { let Some(opportunity) = interaction_opportunity.0 else { - return; + return Ok(()); }; let dialog_target = dialog_target_query.get(opportunity)?; let window = primary_windows @@ -150,7 +150,7 @@ fn display_interaction_prompt( ui.label("E: Talk"); }); for actions in actions.iter() { - if actions.just_pressed(PlayerAction::Interact) { + if actions.just_pressed(&PlayerAction::Interact) { let mut dialogue_runner = dialogue_runner.single_mut(); dialogue_runner.start_node(&dialog_target.node); freeze.freeze();