Skip to content

Commit

Permalink
cargo clippy --fix + minor change to prevent duplicate despawning
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyTornetta committed Oct 26, 2023
1 parent 4ac139c commit bc8e3ce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 26 deletions.
49 changes: 25 additions & 24 deletions cosmos_client/src/structure/ship/build_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,11 @@ fn exit_build_mode(
local_player_in_build_mode: Query<(), (With<LocalPlayer>, With<BuildMode>)>,
mut client: ResMut<RenetClient>,
) {
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),
);
}
}

Expand Down Expand Up @@ -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::<SymmetryVisuals>();

if let Some(mut ecmds) = commands.get_entity(parent) {
ecmds.remove::<SymmetryVisuals>();
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();
}
}
}
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions cosmos_server/src/events/blocks/block_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit bc8e3ce

Please sign in to comment.