diff --git a/Cargo.toml b/Cargo.toml index f9efb42..6a1ac53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ coord_2d = "0.3" futures-lite = "1" gilrs = "0.10" here_be_dragons = "0.2" -leafwing-input-manager = "0.7" +leafwing-input-manager = "0.8" maze_generator = "2" once_cell = "1" pathfinding = "4" diff --git a/src/core.rs b/src/core.rs index 08f271a..29e4223 100644 --- a/src/core.rs +++ b/src/core.rs @@ -298,11 +298,11 @@ pub trait PointLike { fn y(&self) -> f32; fn x_i32(&self) -> i32 { - self.x().trunc() as i32 + self.x().round() as i32 } fn y_i32(&self) -> i32 { - self.y().trunc() as i32 + self.y().round() as i32 } fn x_usize(&self) -> usize { diff --git a/src/navigation.rs b/src/navigation.rs index 9bb7e80..e214918 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -11,13 +11,13 @@ use crate::{ error::error_handler, exploration::{ExplorationFocused, Exploring}, log::Log, - pathfinding::Destination, utils::target_and_other, }; #[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug)] pub enum NavigationAction { Move, + Translate, Rotate, SetLinearVelocity, SetAngularVelocity, @@ -29,11 +29,31 @@ pub enum NavigationAction { #[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)] #[reflect(Component)] -pub struct MaxSpeed(pub f32); +pub struct BackwardMovementFactor(pub f32); -impl Default for MaxSpeed { +impl Default for BackwardMovementFactor { fn default() -> Self { - MaxSpeed(2.) + Self(1.) + } +} + +#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)] +#[reflect(Component)] +pub struct ForwardMovementFactor(pub f32); + +impl Default for ForwardMovementFactor { + fn default() -> Self { + Self(1.) + } +} + +#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)] +#[reflect(Component)] +pub struct StrafeMovementFactor(pub f32); + +impl Default for StrafeMovementFactor { + fn default() -> Self { + Self(1.) } } @@ -41,10 +61,6 @@ impl Default for MaxSpeed { #[reflect(Component)] pub struct RotationSpeed(pub Angle); -#[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)] -#[reflect(Component)] -pub struct Speed(pub f32); - #[derive(Deref, DerefMut)] struct SnapTimer(Timer); @@ -57,25 +73,46 @@ impl Default for SnapTimer { #[derive(Resource, Default, Deref, DerefMut)] struct SnapTimers(HashMap); -fn movement_controls( +#[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)] +#[reflect(Component)] +pub struct Speed(pub f32); + +impl Default for Speed { + fn default() -> Self { + Self(1.) + } +} + +fn controls( mut commands: Commands, - config: Res>, + time: Res