use std::ops::{Deref, DerefMut};
use glam::{Mat3A, Vec3A};
use crate::{PhysState, consts, consts::heatseeker};
#[derive(Clone, Copy, Debug)]
pub struct HeatseekerInfo {
pub y_target_dir: i8,
pub cur_target_speed: f32,
pub time_since_hit: f32,
}
impl Default for HeatseekerInfo {
fn default() -> Self {
Self::DEFAULT
}
}
impl HeatseekerInfo {
pub const DEFAULT: Self = Self {
y_target_dir: 0,
cur_target_speed: heatseeker::INITIAL_TARGET_SPEED,
time_since_hit: 0.,
};
}
#[derive(Clone, Copy, Debug)]
pub struct DropshotInfo {
pub charge_level: u8,
pub accumulated_hit_force: f32,
pub y_target_dir: i8,
pub last_damage_tick: Option<u64>,
}
impl Default for DropshotInfo {
fn default() -> Self {
Self::DEFAULT
}
}
impl DropshotInfo {
pub const DEFAULT: Self = Self {
charge_level: 1,
accumulated_hit_force: 0.,
y_target_dir: 0,
last_damage_tick: None,
};
}
#[derive(Clone, Copy, Debug)]
pub struct BallState {
pub phys: PhysState,
pub hs_info: HeatseekerInfo,
pub ds_info: DropshotInfo,
pub tick_count_since_kickoff: u64,
}
impl Default for BallState {
fn default() -> Self {
Self::DEFAULT
}
}
impl BallState {
pub const DEFAULT: Self = Self {
phys: PhysState {
pos: Vec3A::new(0.0, 0.0, consts::ball::REST_Z),
rot_mat: Mat3A::IDENTITY,
vel: Vec3A::ZERO,
ang_vel: Vec3A::ZERO,
},
hs_info: HeatseekerInfo::DEFAULT,
ds_info: DropshotInfo::DEFAULT,
tick_count_since_kickoff: 0,
};
}
impl Deref for BallState {
type Target = PhysState;
fn deref(&self) -> &Self::Target {
&self.phys
}
}
impl DerefMut for BallState {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.phys
}
}