Commit 9932f1da authored by Rahix's avatar Rahix 🦀

Merge branch 'fix-lints' into 'master'

Fix some more lints

See merge request engel-simulator-2020/game!54
parents a7a3172f 27b555ee
......@@ -105,7 +105,7 @@ impl CollisionWorld {
pub fn interferences_with_point(&self, point: &nalgebra::Point2<f32>) -> Vec<legion::Entity> {
self.world
.interferences_with_point(point, &pipeline::CollisionGroups::new())
.map(|(_, collision_object)| collision_object.data().clone())
.map(|(_, collision_object)| *collision_object.data())
.collect()
}
}
......
......@@ -95,7 +95,7 @@ pub fn draw_nodes(
if let Some(ping_time) = node.ping_time {
let radius = (time - ping_time) * 180.0 + 18.0;
let alpha = (1.0 - (time - ping_time) * 2.0).max(0.0).powi(2);
let mut ring_color = node_color.clone();
let mut ring_color = node_color;
ring_color.alpha = alpha;
rendering.begin_path();
......
......@@ -22,7 +22,7 @@ impl ObstacleBarrier {
ObstacleBarrier {
w: 200.0,
h: 20.0,
orientation: orientation,
orientation,
}
}
......
......@@ -71,13 +71,10 @@ pub enum Event<'a> {
Cheat(crate::cheats::CheatCommand),
}
pub type HandlerClosure = closure::Closure<dyn FnMut(wasm_bindgen::JsValue)>;
struct EventHandlers {
pub mouse_handlers:
std::collections::HashMap<String, closure::Closure<dyn FnMut(wasm_bindgen::JsValue)>>,
pub key_handlers: Option<(
closure::Closure<dyn FnMut(wasm_bindgen::JsValue)>,
closure::Closure<dyn FnMut(wasm_bindgen::JsValue)>,
)>,
pub mouse_handlers: std::collections::HashMap<String, HandlerClosure>,
pub key_handlers: Option<(HandlerClosure, HandlerClosure)>,
}
impl EventHandlers {
......@@ -147,7 +144,7 @@ impl EventHandlers {
}
pub fn deregister_all(&mut self) {
if let Some(_) = self.key_handlers {
if self.key_handlers.is_some() {
let body = utils::document().body().unwrap();
body.set_onkeydown(None);
body.set_onkeyup(None);
......
......@@ -39,11 +39,10 @@ impl InGameState {
resources.insert(resources::Camera::new(1920.0, 1080.0));
resources.insert(colliders::CollisionWorld::new());
let obstacles = entities::create_stationary_obstacles(&mut world, &level, &player);
entities::create_stationary_obstacles(&mut world, &level, &player);
let player = entities::create_player(&mut world, &level, player);
resources.insert(resources::Player(player));
resources.insert(obstacles);
resources.insert(resources::GameManager::new());
level.apply_colliders(&mut world);
......@@ -111,7 +110,7 @@ impl gamestate::State for InGameState {
fn event(&mut self, event: gamestate::Event) -> gamestate::Transition {
use legion::IntoQuery;
let player_id = self.resources.get::<resources::Player>().unwrap().0.clone();
let player_id = self.resources.get::<resources::Player>().unwrap().0;
let (player_movable, player) =
<(&mut components::Movable, &mut components::Player)>::query()
.get_mut(&mut self.world, player_id)
......@@ -175,7 +174,7 @@ impl gamestate::State for InGameState {
let game_manager = self.resources.get::<resources::GameManager>().unwrap();
if game_manager.wants_return_to_heaven() {
let player_ent = self.resources.get::<resources::Player>().unwrap().0.clone();
let player_ent = self.resources.get::<resources::Player>().unwrap().0;
let player: &components::Player = <&components::Player>::query()
.get(&self.world, player_ent)
.unwrap();
......
......@@ -23,7 +23,7 @@ pub fn move_movable(
#[resource] clock: &resources::Clock,
#[resource] collision_world: &colliders::CollisionWorld,
) {
let mut actual_velocity = movable.velocity.clone();
let mut actual_velocity = movable.velocity;
if actual_velocity == nalgebra::Vector2::new(0.0, 0.0) {
return;
......@@ -38,7 +38,7 @@ pub fn move_movable(
.contacts_with(collider.handle.unwrap(), false)
.unwrap()
.filter_map(|pair| pair.3.deepest_contact())
.map(|contact| contact.contact.normal.clone())
.map(|contact| contact.contact.normal)
.collect();
for normal in normals.iter() {
......
......@@ -28,7 +28,7 @@ fn contain(
) -> (nalgebra::Vector2<f64>, nalgebra::Vector2<f64>) {
let client_ratio = child.x / child.y;
let parent_ratio = parent.x / parent.y;
let mut child_resized = parent.clone();
let mut child_resized = parent;
if client_ratio > parent_ratio {
child_resized.y = child_resized.x / client_ratio;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment