Skip to content

Commit

Permalink
Do some trivial updates
Browse files Browse the repository at this point in the history
  • Loading branch information
janhohenheim committed Feb 26, 2024
1 parent dcc4baf commit 779d4ee
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)],
},
);
Expand Down
2 changes: 1 addition & 1 deletion src/ingame_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn handle_pause(
mut paused: Local<bool>,
) {
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;
Expand Down
2 changes: 1 addition & 1 deletion src/level_instantiation/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub(crate) fn map_plugin(app: &mut App) {
.add_systems(
Update,
show_loading_screen
.run_if(not(any_with_component::<Player>()).and_then(in_state(GameState::Playing))),
.run_if(not(any_with_component::<Player>).and_then(in_state(GameState::Playing))),
);
}

Expand Down
14 changes: 8 additions & 6 deletions src/player_control/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,18 @@ pub(crate) fn remove_actions_when_frozen(
mut camera_actions_query: Query<&mut ActionState<CameraAction>>,
) {
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();
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/player_control/camera/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn update_kind(
config: Res<GameConfig>,
) {
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 {
Expand Down
4 changes: 2 additions & 2 deletions src/player_control/camera/rig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub(crate) fn update_rig(

fn get_camera_movement(actions: &ActionState<CameraAction>) -> Vec2 {
actions
.axis_pair(CameraAction::Orbit)
.axis_pair(&CameraAction::Orbit)
.map(|pair| pair.xy())
.unwrap_or_default()
}
Expand Down Expand Up @@ -112,7 +112,7 @@ fn set_desired_distance(
actions: &ActionState<CameraAction>,
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,
Expand Down
2 changes: 1 addition & 1 deletion src/player_control/camera/rig/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/player_control/player_embodiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn handle_jump(mut player_query: Query<(&ActionState<PlayerAction>, &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);
}
}

Expand All @@ -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() {
Expand All @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/world_interaction/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub(crate) fn dialog_plugin(app: &mut App) {
.add_systems(
Update,
(
spawn_dialogue_runner.run_if(resource_added::<YarnProject>()),
spawn_dialogue_runner.run_if(resource_added::<YarnProject>),
unfreeze_after_dialog.after(ExampleYarnSpinnerDialogueViewSystemSet),
),
);
Expand Down
6 changes: 3 additions & 3 deletions src/world_interaction/interactions_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<DialogueRunner>()),
.and_then(any_with_component::<DialogueRunner>),
),
);
}
Expand Down Expand Up @@ -135,7 +135,7 @@ fn display_interaction_prompt(
mut freeze: ResMut<ActionsFrozen>,
) {
let Some(opportunity) = interaction_opportunity.0 else {
return;
return Ok(());
};
let dialog_target = dialog_target_query.get(opportunity)?;
let window = primary_windows
Expand All @@ -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();
Expand Down

0 comments on commit 779d4ee

Please sign in to comment.