use std::{ collections::HashMap, error::Error, f32::consts::PI, fmt::Debug, hash::Hash, marker::PhantomData, }; use bevy::prelude::*; use bevy_rapier2d::prelude::*; use bevy_tts::Tts; use leafwing_input_manager::prelude::*; use crate::{ commands::RunIfExistsExt, core::{Angle, Area, CardinalDirection, GlobalTransformExt, Player}, 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, Rotate, SnapLeft, SnapRight, SnapCardinal, SnapReverse, Sprint, } #[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)] #[reflect(Component)] pub struct MaxSpeed(pub f32); impl Default for MaxSpeed { fn default() -> Self { MaxSpeed(2.) } } #[derive(Component, Clone, Copy, Debug, Deref, DerefMut, Reflect)] #[reflect(Component)] pub struct RotationSpeed(pub Angle); impl Default for RotationSpeed { fn default() -> Self { Self(Angle::Radians(0.)) } } #[derive(Component, Clone, Copy, Debug, Default, Deref, DerefMut, Reflect)] #[reflect(Component)] pub struct Speed(pub f32); #[derive(Component, Deref, DerefMut)] struct SnapTimer(Timer); impl Default for SnapTimer { fn default() -> Self { Self(Timer::from_seconds(0.25, false)) } } fn movement_controls( mut commands: Commands, config: Res>, time: Res