From cf45c5b472efcb09e85cfc839833b9d54f4f6a2a Mon Sep 17 00:00:00 2001 From: Clinton Selke Date: Sat, 23 Mar 2024 21:40:07 +1000 Subject: [PATCH] cargo clippy --- src/action.rs | 4 +--- src/behavior.rs | 2 +- src/components.rs | 2 +- src/systems.rs | 18 +++++++++--------- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/action.rs b/src/action.rs index 02f406b..d918c5c 100644 --- a/src/action.rs +++ b/src/action.rs @@ -1,6 +1,4 @@ -use std::marker::PhantomData; - -use bevy::ecs::{all_tuples, entity::Entity, world::World}; +use bevy::ecs::{entity::Entity, world::World}; use crate::VirtualJoystickState; diff --git a/src/behavior.rs b/src/behavior.rs index 7af4dcb..a27b0d0 100644 --- a/src/behavior.rs +++ b/src/behavior.rs @@ -111,7 +111,7 @@ impl VirtualJoystickBehavior for JoystickVerticalOnly { impl VirtualJoystickBehavior for JoystickInvisible { fn update(&self, world: &mut World, entity: Entity) { - let joystick_state = world.get::(entity).map(|x| x.clone()); + let joystick_state = world.get::(entity).cloned(); let Some(joystick_state) = joystick_state else { return; }; diff --git a/src/components.rs b/src/components.rs index 874c8c7..cda77e7 100644 --- a/src/components.rs +++ b/src/components.rs @@ -42,7 +42,7 @@ impl Default for VirtualJoystickNode { Self { id: Default::default(), behavior: Arc::new(JoystickFloating), - action: Arc::new(NoAction::default()), + action: Arc::new(NoAction), } } } diff --git a/src/systems.rs b/src/systems.rs index 30093d0..4a285b3 100644 --- a/src/systems.rs +++ b/src/systems.rs @@ -175,9 +175,9 @@ pub fn update_action(world: &mut World) { joystick_entities.push(joystick_entity); } enum DragAction { - OnStartDrag, - OnDrag, - OnEndDrag, + StartDrag, + Drag, + EndDrag, } for joystick_entity in joystick_entities { let drag_action: Option; @@ -186,12 +186,12 @@ pub fn update_action(world: &mut World) { continue; }; if joystick_state.just_released { - drag_action = Some(DragAction::OnEndDrag); + drag_action = Some(DragAction::EndDrag); } else if let Some(touch_state) = &joystick_state.touch_state { if touch_state.just_pressed { - drag_action = Some(DragAction::OnStartDrag); + drag_action = Some(DragAction::StartDrag); } else { - drag_action = Some(DragAction::OnDrag); + drag_action = Some(DragAction::Drag); } } else { drag_action = None; @@ -214,13 +214,13 @@ pub fn update_action(world: &mut World) { joystick_state = joystick_state_2.clone(); } match drag_action { - DragAction::OnStartDrag => { + DragAction::StartDrag => { action.on_start_drag(id, joystick_state, world, joystick_entity); } - DragAction::OnDrag => { + DragAction::Drag => { action.on_drag(id, joystick_state, world, joystick_entity); } - DragAction::OnEndDrag => { + DragAction::EndDrag => { action.on_end_drag(id, joystick_state, world, joystick_entity); } }