use glam::Vec3;
use kurbo::CubicBez;

#[derive(Clone)]
pub struct MovementComponent
{
    pub walking_acceleration: f32,
    pub walking_acceleration_duration: f32,
    pub walking_acceleration_curve: CubicBez,
    pub walking_damping: f32,
    pub max_walking_speed: f32,
    pub idle_damping: f32,
    pub movement_context: MovementContext,
}

impl MovementComponent
{
    pub fn new() -> Self
    {
        Self {
            walking_acceleration: 250.0,
            walking_acceleration_duration: 0.1,
            walking_acceleration_curve: CubicBez::new(
                (0.0, 0.0),
                (0.5, 0.3),
                (0.75, 0.9),
                (1.0, 1.0),
            ),
            walking_damping: 0.8,
            max_walking_speed: 12.0,
            idle_damping: 0.1,
            movement_context: MovementContext::new(),
        }
    }
}

#[derive(Clone, Copy)]
pub struct MovementContext
{
    pub forward_direction: Vec3,
    pub is_floored: bool,
    pub last_floored_time: u64,
    pub surface_normal: Vec3,
}

impl MovementContext
{
    pub fn new() -> Self
    {
        Self {
            forward_direction: Vec3::Z,
            is_floored: false,
            last_floored_time: 0,
            surface_normal: Vec3::Y,
        }
    }
}
