Clippy fixes

main
Elijah C. Voigt 2 years ago
parent e031ebd22a
commit 023dd9dc00

@ -25,7 +25,7 @@ fn inspect(
// Spawn default GLTF scene
commands.spawn((
SceneBundle {
scene: Handle::Weak(id.clone()),
scene: Handle::Weak(*id),
..default()
},
InspectScene,

@ -1,14 +1,4 @@
use bevy::core_pipeline::experimental::taa::TemporalAntiAliasSettings;
use bevy::core_pipeline::prepass::MotionVectorPrepass;
use bevy::core_pipeline::tonemapping::DebandDither;
use bevy::core_pipeline::Skybox;
use bevy::pbr::ExtendedMaterial;
use bevy::pbr::MaterialExtension;
use bevy::pbr::OpaqueRendererMethod;
use bevy::pbr::ScreenSpaceAmbientOcclusionBundle;
use bevy::prelude::*;
use bevy::render::render_resource::*;
use bevy::render::view::ColorGrading;
use crate::prelude::*;
type MyMat = ExtendedMaterial<StandardMaterial, MatExt>;
@ -82,7 +72,7 @@ fn apply_skybox(
});
cameras.iter().for_each(|e| {
commands.entity(e).insert(Skybox(handle.clone()));
commands.entity(e).insert(Skybox { image: handle.clone(), brightness: 1.0 });
});
*done = true;

@ -39,7 +39,7 @@ fn main() {
fn iter_all(t: &toml::Table, key: &str) -> Vec<(String, toml::Value)> {
t.iter()
.flat_map(|(k, v)| {
let nk = if key == "" {
let nk = if key.is_empty() {
k.to_string()
} else {
format!("{}_{}", key, k)
@ -69,5 +69,5 @@ fn locate(t: &toml::Table, key: &str) -> Option<toml::Value> {
}
fn get<'de, T: Deserialize<'de>>(t: &toml::Table, key: &str) -> Option<T> {
locate(t, key).map(|val| val.try_into().ok()).flatten()
locate(t, key).and_then(|val| val.try_into().ok())
}

@ -145,5 +145,5 @@ fn toggle_volume(mut vol: ResMut<AudioVolume>) {
fn control_volume(vol: Res<AudioVolume>, query: Query<&AudioSource>) {
query
.iter()
.for_each(|aud_src| aud_src.set_volume((*vol).0));
.for_each(|aud_src| aud_src.set_volume(vol.0));
}

@ -6,7 +6,7 @@ impl Plugin for DebugPlugin {
fn build(&self, app: &mut App) {
app.add_plugins((
FrameTimeDiagnosticsPlugin,
EntityCountDiagnosticsPlugin::default(),
EntityCountDiagnosticsPlugin,
SystemInformationDiagnosticsPlugin,
))
.init_resource::<DebugInfo>()

@ -203,8 +203,8 @@ fn initialize(mut commands: Commands, board: Res<game::Board>, assets: Res<Asset
side,
DisplayState::Display3d,
Display3d,
piece.clone(),
index.clone(),
*piece,
*index,
SceneBundle { ..default() },
game::Selectable,
));
@ -757,16 +757,16 @@ fn select(
.filter(|ev| ev.state == ButtonState::Pressed)
.for_each(|_| {
windows.iter().for_each(|window| {
window.cursor_position().and_then(|pos| {
window.cursor_position().map(|pos| {
cameras.iter().for_each(|(camera, gt)| {
camera.viewport_to_world(gt, pos).and_then(|ray| {
camera.viewport_to_world(gt, pos).map(|ray| {
query
.iter()
.filter_map(|(entity, handle, gt)| {
meshes.get(handle).map(|mesh| (entity, mesh, gt))
})
.for_each(|(entity, mesh, gt)| {
hit::intersects3d(&ray, mesh, &gt).and_then(|_hit| {
hit::intersects3d(&ray, mesh, gt).map(|_hit| {
selectable
.iter()
.find_map(|(e, &board_index, &side)| {
@ -793,15 +793,15 @@ fn select(
.for_each(|&board_index| {
info!("Board index selected: {:?}", board_index);
selections
.send(game::Selection(board_index.clone()));
.send(game::Selection(board_index));
});
Some(())
()
});
});
Some(())
()
});
});
Some(())
()
});
});
});
@ -812,7 +812,7 @@ fn selected_gizmo(
mut gizmos: Gizmos,
) {
selected.iter().for_each(|transform| {
gizmos.cuboid(transform.clone(), Color::GREEN);
gizmos.cuboid(*transform, Color::GREEN);
})
}
@ -1090,7 +1090,7 @@ fn scale_lighting(
if let Some(Original(v)) = original {
val.intensity = v.intensity * spot_tweak;
} else {
commands.entity(entity).insert(Original(val.clone()));
commands.entity(entity).insert(Original(*val));
val.intensity *= spot_tweak;
}
});
@ -1103,7 +1103,7 @@ fn scale_lighting(
if let Some(Original(v)) = original {
val.intensity = v.intensity * point_tweak;
} else {
commands.entity(entity).insert(Original(val.clone()));
commands.entity(entity).insert(Original(*val));
val.intensity *= point_tweak;
}
});

@ -197,8 +197,8 @@ impl CaptureFlow {
/// Fade out, then store, then fade in
pub(crate) fn next(&self) -> Option<Self> {
match self {
Self::FadeOut(e) => Some(Self::Store(e.clone())),
Self::Store(e) => Some(Self::FadeIn(e.clone())),
Self::FadeOut(e) => Some(Self::Store(*e)),
Self::Store(e) => Some(Self::FadeIn(*e)),
Self::FadeIn(_) => None,
}
}
@ -297,7 +297,7 @@ impl Board {
.map(|p| (p, BoardIndex { x, y }))
})
})
.filter_map(|r| r)
.flatten()
.collect()
}
Side::B => {
@ -309,7 +309,7 @@ impl Board {
.map(|p| (p, BoardIndex { x, y }))
})
})
.filter_map(|r| r)
.flatten()
.collect()
}
}
@ -322,7 +322,7 @@ impl Board {
.enumerate()
.flat_map(|(y, nested)| {
nested.iter().enumerate().filter_map(move |(x, p)| {
p.as_ref().map(|val| (BoardIndex { x, y }, val.clone()))
p.as_ref().map(|val| (BoardIndex { x, y }, *val))
})
})
.collect()
@ -337,7 +337,7 @@ impl Board {
if from == to {
Err(GameError::NullMove)
} else {
match self.at(from.clone()) {
match self.at(from) {
Some(from_piece) => {
// Check if this is a valid move for this piece
if self.valid_moves(from).contains(&to) {
@ -351,7 +351,7 @@ impl Board {
if self.inner[to.y][to.x].is_some() {
moves.push(Move {
epoch,
from: to.clone(),
from: to,
to: None,
});
}
@ -359,8 +359,8 @@ impl Board {
// Capture the intened move in the moves ledger
moves.push(Move {
epoch,
from: from.clone(),
to: Some(to.clone()),
from: from,
to: Some(to),
});
self.inner[to.y][to.x] = Some(*from_piece);
@ -500,7 +500,7 @@ impl Board {
impl std::fmt::Display for Board {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.inner.iter().rev().for_each(|row| {
let _ = write!(f, "+--+--+--+--+--+--+--+--+\n");
let _ = writeln!(f, "+--+--+--+--+--+--+--+--+");
let _ = write!(f, "|");
row.iter().for_each(|piece| {
let _ = match piece {
@ -508,7 +508,7 @@ impl std::fmt::Display for Board {
None => write!(f, " |"),
};
});
let _ = write!(f, "\n");
let _ = writeln!(f);
});
let _ = write!(f, "+--+--+--+--+--+--+--+--+");
Ok(())
@ -552,7 +552,7 @@ pub(crate) fn update_board(
match to {
Some(to_idx) => {
info!("Moving piece {:?} {:?} -> {:?}", entity, from, to_idx);
*index = to_idx.clone();
*index = *to_idx;
if !(*played) {
audio_events.send(audio::AudioEvent::PutDown);
audio_events.send(audio::AudioEvent::StopIdle);
@ -853,8 +853,8 @@ fn cancel_place(current: Query<&BoardIndex, With<Selected>>, mut events: EventWr
current.iter().for_each(|board_index| {
info!("De-selecting piece at {:?}", board_index);
events.send(Move {
from: board_index.clone(),
to: Some(board_index.clone()),
from: *board_index,
to: Some(*board_index),
..default()
});
});
@ -938,7 +938,7 @@ fn reset_game(
.for_each(|(e, (i, p))| {
commands
.entity(e)
.insert((i.clone(), p.clone()))
.insert((*i, *p))
.remove::<Captured>();
});
}

@ -96,7 +96,6 @@ fn init_intro_text(
text: Text {
sections: text
.chars()
.into_iter()
.map(|c| TextSection {
value: c.to_string(),
style: TextStyle {
@ -208,7 +207,7 @@ fn manage_scroll_text_animation(
commands.entity(e).insert(Visibility::Hidden);
}
// Locate the last entity we were operating with
while let Some(entity) = paragraphs.next() {
for entity in paragraphs.by_ref() {
if curr.0 == Some(entity) {
break;
}

@ -21,8 +21,8 @@ pub(crate) use bevy::{
mouse::{MouseButtonInput, MouseMotion, MouseScrollUnit, MouseWheel},
ButtonState,
},
pbr::ScreenSpaceAmbientOcclusionQualityLevel,
pbr::{
ScreenSpaceAmbientOcclusionQualityLevel, OpaqueRendererMethod,
ExtendedMaterial, MaterialExtension, ScreenSpaceAmbientOcclusionBundle,
ScreenSpaceAmbientOcclusionSettings,
},
@ -31,7 +31,7 @@ pub(crate) use bevy::{
render::{
mesh::{MeshVertexAttribute, VertexAttributeValues},
render_resource::{
AsBindGroup, ShaderRef, TextureViewDescriptor, TextureViewDimension, VertexFormat,
*, AsBindGroup, ShaderRef, TextureViewDescriptor, TextureViewDimension, VertexFormat,
},
view::ColorGrading,
},

@ -79,7 +79,7 @@ impl Tweaks {
fn iter_all(t: &toml::Table, key: &str) -> Vec<(String, toml::Value)> {
t.iter()
.flat_map(|(k, v)| {
let nk = if key == "" {
let nk = if key.is_empty() {
k.to_string()
} else {
format!("{}_{}", key, k)

@ -66,7 +66,7 @@ fn manage_cursor(
fn interactive_button(
mut events: Query<(Entity, &mut UiImage, &Interaction), (With<Button>, Changed<Interaction>)>,
mut writer: EventWriter<audio::AudioEvent>,
mut children: Query<&Children>,
children: Query<&Children>,
mut texts: Query<(&mut Text, &mut Style)>,
tweaks_file: Res<tweak::GameTweaks>,
tweaks: Res<Assets<tweak::Tweaks>>,
@ -83,7 +83,7 @@ fn interactive_button(
Interaction::None => {
ui_image.texture = resting_handle.clone();
let mut ts = texts.iter_many_mut(children.iter_descendants(entity));
while let Some((mut t, mut s)) = ts.fetch_next() {
while let Some((t, mut s)) = ts.fetch_next() {
s.right = Val::Auto;
info!("TODO: Change text color");
info!("TODO: Change position");
@ -93,7 +93,7 @@ fn interactive_button(
ui_image.texture = depressed_handle.clone();
writer.send(audio::AudioEvent::MenuHover);
let mut ts = texts.iter_many_mut(children.iter_descendants(entity));
while let Some((mut t, mut s)) = ts.fetch_next() {
while let Some((t, mut s)) = ts.fetch_next() {
s.right = Val::Px(0.0);
info!("TODO: Change text color");
info!("TODO: Change position");
@ -103,7 +103,7 @@ fn interactive_button(
ui_image.texture = depressed_handle.clone();
writer.send(audio::AudioEvent::MenuSelect);
let mut ts = texts.iter_many_mut(children.iter_descendants(entity));
while let Some((mut t, mut s)) = ts.fetch_next() {
while let Some((t, mut s)) = ts.fetch_next() {
s.right = Val::Px(0.0);
info!("TODO: Change text color");
info!("TODO: Change position");

Loading…
Cancel
Save