use boxcars::{HeaderProp, RemoteId};
use serde::Serialize;
pub type PlayerId = boxcars::RemoteId;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DemolishFormat {
Fx,
Extended,
}
#[derive(Debug, Clone, PartialEq)]
pub enum DemolishAttribute {
Fx(boxcars::DemolishFx),
Extended(boxcars::DemolishExtended),
}
impl DemolishAttribute {
pub fn attacker_actor_id(&self) -> boxcars::ActorId {
match self {
DemolishAttribute::Fx(fx) => fx.attacker,
DemolishAttribute::Extended(ext) => ext.attacker.actor,
}
}
pub fn victim_actor_id(&self) -> boxcars::ActorId {
match self {
DemolishAttribute::Fx(fx) => fx.victim,
DemolishAttribute::Extended(ext) => ext.victim.actor,
}
}
pub fn attacker_velocity(&self) -> boxcars::Vector3f {
match self {
DemolishAttribute::Fx(fx) => fx.attack_velocity,
DemolishAttribute::Extended(ext) => ext.attacker_velocity,
}
}
pub fn victim_velocity(&self) -> boxcars::Vector3f {
match self {
DemolishAttribute::Fx(fx) => fx.victim_velocity,
DemolishAttribute::Extended(ext) => ext.victim_velocity,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct DemolishInfo {
pub time: f32,
pub seconds_remaining: i32,
pub frame: usize,
#[ts(as = "crate::ts_bindings::RemoteIdTs")]
pub attacker: PlayerId,
#[ts(as = "crate::ts_bindings::RemoteIdTs")]
pub victim: PlayerId,
#[ts(as = "crate::ts_bindings::Vector3fTs")]
pub attacker_velocity: boxcars::Vector3f,
#[ts(as = "crate::ts_bindings::Vector3fTs")]
pub victim_velocity: boxcars::Vector3f,
#[ts(as = "crate::ts_bindings::Vector3fTs")]
pub victim_location: boxcars::Vector3f,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, ts_rs::TS)]
#[ts(export)]
pub enum BoostPadEventKind {
PickedUp { sequence: u8 },
Available,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, ts_rs::TS)]
#[ts(export)]
pub enum BoostPadSize {
Big,
Small,
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct BoostPadEvent {
pub time: f32,
pub frame: usize,
pub pad_id: String,
#[ts(as = "Option<crate::ts_bindings::RemoteIdTs>")]
pub player: Option<PlayerId>,
pub kind: BoostPadEventKind,
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct ResolvedBoostPad {
pub index: usize,
pub pad_id: Option<String>,
pub size: BoostPadSize,
#[ts(as = "crate::ts_bindings::Vector3fTs")]
pub position: boxcars::Vector3f,
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct GoalEvent {
pub time: f32,
pub frame: usize,
pub scoring_team_is_team_0: bool,
#[ts(as = "Option<crate::ts_bindings::RemoteIdTs>")]
pub player: Option<PlayerId>,
pub team_zero_score: Option<i32>,
pub team_one_score: Option<i32>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, ts_rs::TS)]
#[ts(export)]
pub enum PlayerStatEventKind {
Shot,
Save,
Assist,
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct PlayerStatEvent {
pub time: f32,
pub frame: usize,
#[ts(as = "crate::ts_bindings::RemoteIdTs")]
pub player: PlayerId,
pub is_team_0: bool,
pub kind: PlayerStatEventKind,
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct TouchEvent {
pub time: f32,
pub frame: usize,
pub team_is_team_0: bool,
#[ts(as = "Option<crate::ts_bindings::RemoteIdTs>")]
pub player: Option<PlayerId>,
pub closest_approach_distance: Option<f32>,
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct ReplayMeta {
pub team_zero: Vec<PlayerInfo>,
pub team_one: Vec<PlayerInfo>,
#[ts(as = "Vec<(String, crate::ts_bindings::HeaderPropTs)>")]
pub all_headers: Vec<(String, HeaderProp)>,
}
impl ReplayMeta {
pub fn player_count(&self) -> usize {
self.team_one.len() + self.team_zero.len()
}
pub fn player_order(&self) -> impl Iterator<Item = &PlayerInfo> {
self.team_zero.iter().chain(self.team_one.iter())
}
}
#[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
pub struct PlayerInfo {
#[ts(as = "crate::ts_bindings::RemoteIdTs")]
pub remote_id: RemoteId,
#[ts(as = "Option<std::collections::HashMap<String, crate::ts_bindings::HeaderPropTs>>")]
pub stats: Option<std::collections::HashMap<String, HeaderProp>>,
pub name: String,
}