From bc8e3ce9837817ae06e60b1d157a2b6d06eb861b Mon Sep 17 00:00:00 2001 From: Anthony Tornetta Date: Thu, 26 Oct 2023 06:23:10 -0400 Subject: [PATCH] cargo clippy --fix + minor change to prevent duplicate despawning --- .../src/structure/ship/build_mode.rs | 49 ++++++++++--------- .../src/events/blocks/block_events.rs | 4 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/cosmos_client/src/structure/ship/build_mode.rs b/cosmos_client/src/structure/ship/build_mode.rs index 88a386de5..3a4e77424 100644 --- a/cosmos_client/src/structure/ship/build_mode.rs +++ b/cosmos_client/src/structure/ship/build_mode.rs @@ -38,13 +38,11 @@ fn exit_build_mode( local_player_in_build_mode: Query<(), (With, With)>, mut client: ResMut, ) { - if local_player_in_build_mode.get_single().is_ok() { - if input_handler.check_just_pressed(CosmosInputs::ToggleBuildMode) { - client.send_message( - NettyChannelClient::Reliable, - cosmos_encoder::serialize(&ClientReliableMessages::ExitBuildMode), - ); - } + if local_player_in_build_mode.get_single().is_ok() && input_handler.check_just_pressed(CosmosInputs::ToggleBuildMode) { + client.send_message( + NettyChannelClient::Reliable, + cosmos_encoder::serialize(&ClientReliableMessages::ExitBuildMode), + ); } } @@ -177,21 +175,24 @@ fn clear_visuals( mut commands: Commands, ) { for ev in event_reader.iter() { - if let Ok(parent) = parent_query.get(ev.player_entity).map(|p| p.get()) { - if let Ok(sym_visuals) = visuals_query.get(parent) { - if let Some(ent) = sym_visuals.0 { - commands.entity(ent).despawn_recursive(); - } - if let Some(ent) = sym_visuals.1 { - commands.entity(ent).despawn_recursive(); - } - if let Some(ent) = sym_visuals.2 { - commands.entity(ent).despawn_recursive(); - } - } + let Ok(parent) = parent_query.get(ev.player_entity).map(|p| p.get()) else { + continue; + }; + let Some(mut ecmds) = commands.get_entity(parent) else { + continue; + }; + + ecmds.remove::(); - if let Some(mut ecmds) = commands.get_entity(parent) { - ecmds.remove::(); + if let Ok(sym_visuals) = visuals_query.get(parent) { + if let Some(ent) = sym_visuals.0 { + commands.entity(ent).despawn_recursive(); + } + if let Some(ent) = sym_visuals.1 { + commands.entity(ent).despawn_recursive(); + } + if let Some(ent) = sym_visuals.2 { + commands.entity(ent).despawn_recursive(); } } } @@ -251,7 +252,7 @@ fn change_visuals( ..Default::default() }, texture: texture_handle.clone(), - color: Color::rgb(1.0, 0.0, 0.0).into(), + color: Color::rgb(1.0, 0.0, 0.0), }), transform: Transform::from_xyz(coords.x, 0.5, 0.5), ..Default::default() @@ -282,7 +283,7 @@ fn change_visuals( ..Default::default() }, texture: texture_handle.clone(), - color: Color::rgb(0.0, 1.0, 0.0).into(), + color: Color::rgb(0.0, 1.0, 0.0), }), transform: Transform::from_xyz(0.5, coords.y, 0.5), ..Default::default() @@ -313,7 +314,7 @@ fn change_visuals( ..Default::default() }, texture: texture_handle.clone(), - color: Color::rgb(0.0, 0.0, 1.0).into(), + color: Color::rgb(0.0, 0.0, 1.0), }), transform: Transform::from_xyz(0.5, 0.5, coords.z), ..Default::default() diff --git a/cosmos_server/src/events/blocks/block_events.rs b/cosmos_server/src/events/blocks/block_events.rs index 8e9355ec8..04c575c66 100644 --- a/cosmos_server/src/events/blocks/block_events.rs +++ b/cosmos_server/src/events/blocks/block_events.rs @@ -129,12 +129,12 @@ fn unique_push(vec: &mut Vec<(BlockCoordinate, BlockFace)>, item: (BlockCoordina vec.push(item); } -fn calculate_build_mode_blocks<'a>( +fn calculate_build_mode_blocks( mut structure_blocks: Vec<(BlockCoordinate, BlockFace)>, build_mode: &BuildMode, parent: &Parent, structure_entity: Entity, - inventory: &mut Mut<'a, Inventory>, + inventory: &mut Mut<'_, Inventory>, structure: &Structure, ) -> Vec<(BlockCoordinate, BlockFace)> { if parent.get() != structure_entity {