Skip to content
Snippets Groups Projects
Verified Commit 6913fb2c authored by Louis's avatar Louis :fire:
Browse files

apply clippy suggestions

parent 54a96c57
No related branches found
No related tags found
No related merge requests found
...@@ -153,7 +153,7 @@ mod test { ...@@ -153,7 +153,7 @@ mod test {
let project = Project::from_bytes(project_data).expect("Failed to parse project file"); let project = Project::from_bytes(project_data).expect("Failed to parse project file");
for layer in project.defs.layers.iter() { for layer in project.defs.layers.iter() {
for auto_rule_group in layer.auto_rule_groups.iter() {} for _auto_rule_group in layer.auto_rule_groups.iter() {}
} }
} }
} }
...@@ -8,7 +8,7 @@ use bevy::prelude::*; ...@@ -8,7 +8,7 @@ use bevy::prelude::*;
use crate::assets::LevelIndex; use crate::assets::LevelIndex;
use crate::ldtk::EntityInstance; use crate::ldtk::EntityInstance;
use crate::system::ActiveLevel; use crate::system::ActiveLevel;
use crate::{get_ldtk_tile_scale, LdtkLayer, LdtkLevel}; use crate::{LdtkLayer, LdtkLevel};
#[derive(SystemParam)] #[derive(SystemParam)]
pub struct MapQuery<'w, 's> { pub struct MapQuery<'w, 's> {
......
use bevy::prelude::{Handle, Image, TextureAtlas}; use bevy::prelude::{Image, TextureAtlas};
use bevy::render::render_resource::TextureFormat; use bevy::render::render_resource::TextureFormat;
use bevy::render::texture::TextureFormatPixelInfo; use bevy::render::texture::TextureFormatPixelInfo;
......
...@@ -5,7 +5,7 @@ use std::path::Path; ...@@ -5,7 +5,7 @@ use std::path::Path;
use bevy::math::{IVec2, Rect, UVec2, Vec2}; use bevy::math::{IVec2, Rect, UVec2, Vec2};
use num_traits::AsPrimitive; use num_traits::AsPrimitive;
use quadtree_rs::area::{Area, AreaBuilder}; use quadtree_rs::area::AreaBuilder;
use quadtree_rs::point::Point; use quadtree_rs::point::Point;
use quadtree_rs::Quadtree; use quadtree_rs::Quadtree;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
...@@ -148,7 +148,7 @@ impl LdtkLevel { ...@@ -148,7 +148,7 @@ impl LdtkLevel {
self.properties.get(&name.to_string()) self.properties.get(&name.to_string())
} }
pub fn property_or_null(&self, name: impl ToString) -> &Value { pub fn property_or_null(&self, name: impl ToString) -> &Value {
self.property(name).unwrap_or_else(|| &Value::Null) self.property(name).unwrap_or(&Value::Null)
} }
pub fn get_indexer(&self) -> Indexer { pub fn get_indexer(&self) -> Indexer {
Indexer::new(px_to_grid(self.level.px_wid), px_to_grid(self.level.px_hei)) Indexer::new(px_to_grid(self.level.px_wid), px_to_grid(self.level.px_hei))
...@@ -170,10 +170,10 @@ impl From<Level> for LdtkLevel { ...@@ -170,10 +170,10 @@ impl From<Level> for LdtkLevel {
let fields = std::mem::take(&mut value.field_instances); let fields = std::mem::take(&mut value.field_instances);
for field in fields { for field in fields {
properties.insert(field.identifier, field.value.unwrap_or_else(|| Value::Null)); properties.insert(field.identifier, field.value.unwrap_or(Value::Null));
} }
let level_width = value.px_wid; let _level_width = value.px_wid;
let level_height = value.px_hei; let level_height = value.px_hei;
let mut level = Self { let mut level = Self {
...@@ -196,14 +196,14 @@ impl From<Level> for LdtkLevel { ...@@ -196,14 +196,14 @@ impl From<Level> for LdtkLevel {
for field in entity.field_instances.iter() { for field in entity.field_instances.iter() {
properties.insert( properties.insert(
field.identifier.clone(), field.identifier.clone(),
field.value.as_ref().unwrap_or_else(|| &Value::Null).clone(), field.value.as_ref().unwrap_or(&Value::Null).clone(),
); );
} }
let width = entity.width; let _width = entity.width;
let height = entity.height; let height = entity.height;
let left_x = entity.px[0]; let _left_x = entity.px[0];
let bottom_y = level_height - (entity.px[1] + height); let _bottom_y = level_height - (entity.px[1] + height);
let size = IVec2::new(entity.width as i32, entity.height as i32); let size = IVec2::new(entity.width as i32, entity.height as i32);
let position = IVec2::new(level.level.px_wid as i32, level.level.px_hei as i32) let position = IVec2::new(level.level.px_wid as i32, level.level.px_hei as i32)
...@@ -216,15 +216,12 @@ impl From<Level> for LdtkLevel { ...@@ -216,15 +216,12 @@ impl From<Level> for LdtkLevel {
collides: true, collides: true,
}; };
match AreaBuilder::default() if let Ok(point) = AreaBuilder::default()
.anchor(Point::from((position.x as i64, position.y as i64))) .anchor(Point::from((position.x as i64, position.y as i64)))
.dimensions((size.x as i64, size.y as i64)) .dimensions((size.x as i64, size.y as i64))
.build() .build()
{ {
Ok(point) => { collider_quads.insert(point, entity);
collider_quads.insert(point, entity);
}
Err(_) => {}
} }
} }
} }
...@@ -424,7 +421,7 @@ fn convert_map_types(map: &Map<String, Value>) -> HashMap<String, Value> { ...@@ -424,7 +421,7 @@ fn convert_map_types(map: &Map<String, Value>) -> HashMap<String, Value> {
impl Properties { impl Properties {
pub fn as_string(&self, name: impl ToString) -> Option<String> { pub fn as_string(&self, name: impl ToString) -> Option<String> {
self.get(&name.to_string()).and_then(|value| match value { self.get(&name.to_string()).and_then(|value| match value {
Value::String(value) => Some(format!("{}", value)), Value::String(value) => Some(value.to_string()),
Value::Bool(value) => Some(format!("{}", value)), Value::Bool(value) => Some(format!("{}", value)),
Value::Number(value) => Some(format!("{}", value)), Value::Number(value) => Some(format!("{}", value)),
_ => None, _ => None,
...@@ -492,17 +489,11 @@ impl Properties { ...@@ -492,17 +489,11 @@ impl Properties {
} }
} }
pub fn is_null(&self, name: impl ToString) -> bool { pub fn is_null(&self, name: impl ToString) -> bool {
match self.0.get(&name.to_string()) { matches!(self.0.get(&name.to_string()), Some(Value::Null))
Some(Value::Null) => true,
_ => false,
}
} }
pub fn is_null_or_undefined(&self, name: impl ToString) -> bool { pub fn is_null_or_undefined(&self, name: impl ToString) -> bool {
match self.0.get(&name.to_string()) { matches!(self.0.get(&name.to_string()), None | Some(Value::Null))
None | Some(Value::Null) => true,
_ => false,
}
} }
pub fn is_null_or_falsy(&self, name: impl ToString) -> bool { pub fn is_null_or_falsy(&self, name: impl ToString) -> bool {
...@@ -607,24 +598,18 @@ impl WorldLayer { ...@@ -607,24 +598,18 @@ impl WorldLayer {
} }
pub fn for_each_tile(&self, mut cb: impl FnMut(i64, i64, &WorldTile)) { pub fn for_each_tile(&self, mut cb: impl FnMut(i64, i64, &WorldTile)) {
match &self.layer_data { if let LayerType::GidTiles(map) = &self.layer_data {
LayerType::GidTiles(map) => { map.iter().for_each(|(pos, tile)| {
map.iter().for_each(|(pos, tile)| { cb(pos.0, pos.1, tile);
cb(pos.0, pos.1, tile); });
});
}
_ => {}
} }
} }
pub fn for_each_tile_mut(&mut self, mut cb: impl FnMut(i64, i64, &mut WorldTile)) { pub fn for_each_tile_mut(&mut self, mut cb: impl FnMut(i64, i64, &mut WorldTile)) {
match &mut self.layer_data { if let LayerType::GidTiles(map) = &mut self.layer_data {
LayerType::GidTiles(map) => { map.iter_mut().for_each(|(pos, tile)| {
map.iter_mut().for_each(|(pos, tile)| { cb(pos.0, pos.1, tile);
cb(pos.0, pos.1, tile); });
});
}
_ => {}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment