Implement loading of cube data from JSON file

This commit is contained in:
NGnius (Graham) committed 2025-03-09 16:28:03 -04:00
1 parent 303f72f010
commit 9b87b25131
20 files changed
+9541 -64

No files matched your search

@@ -0,0 +1,347 @@
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use polariton::operation::{Typed, Dict};
use polariton::serdes::TypePrefix;
use super::{MovementCategoryData, MovementData, WeaponData};
const CUBE_CONFIG_FILENAME: &str = "cubes.json";
#[derive(Serialize, Deserialize, Debug)]
pub struct CubeConfig {
cubes: HashMap<String, Cube>,
movement: HashMap<ItemCategory, MovementCategoryData>,
lerp_value: f32,
}
impl CubeConfig {
pub fn load(root: impl AsRef<std::path::Path>) -> std::io::Result<Self> {
let file = std::fs::File::open(root.as_ref().join(CUBE_CONFIG_FILENAME))?;
let buffered = std::io::BufReader::new(file);
let result = serde_json::from_reader(buffered)?;
Ok(result)
}
pub fn cube_list<C: Clone>(&self) -> Typed<C> {
Typed::Dict(Dict {
key_ty: TypePrefix::Str,
val_ty: TypePrefix::HashMap,
items: self.cubes.values().map(|cube| {
let cube_d: crate::data::cube_list::CubeInfo<C> = cube.info.clone().into();
cube_d.as_transmissible_key_val(cube.id)
}).collect(),
})
}
pub fn movement_list<C: Clone>(&self) -> Typed<C> {
let mut movements_stats = HashMap::<ItemCategory, HashMap<ItemTier, MovementData>>::new();
for cube in self.cubes.values() {
if let Some(movement_data) = &cube.movement {
let category_map = if let Some(x) = movements_stats.get_mut(&cube.info.category) {
x
} else {
movements_stats.insert(cube.info.category, HashMap::new());
movements_stats.get_mut(&cube.info.category).unwrap()
};
category_map.insert(cube.info.size, movement_data.to_owned());
}
}
let mut movement_cat_stats = Vec::with_capacity(self.movement.len());
for (k, v) in self.movement.iter() {
let stats: Vec<_> = if let Some(stats) = movements_stats.get(&k) {
stats.iter().map(|(k, v)| (k.to_owned(), v.to_owned())).collect()
} else {
Vec::default()
};
let key: crate::data::weapon_list::ItemCategory = k.to_owned().into();
let key_typed = Typed::<C>::Str(key.as_str().into());
let value_data = v.to_owned().into_data(stats);
movement_cat_stats.push((key_typed, value_data.as_transmissible()));
}
Typed::Dict(Dict {
key_ty: TypePrefix::Str,
val_ty: TypePrefix::HashMap,
items: vec![
(Typed::Str("Global".into()), Typed::HashMap(vec![
(Typed::Str("lerpValue".into()), Typed::Float(self.lerp_value)),
].into())),
(Typed::Str("Movements".into()), Typed::HashMap(movement_cat_stats.into())),
],
})
}
pub fn weapon_list<C: Clone>(&self) -> Typed<C> {
let mut weapon_stats = HashMap::new();
for cube in self.cubes.values() {
if let Some(weapon_data) = &cube.weapon {
let category_map = if let Some(x) = weapon_stats.get_mut(&cube.info.category) {
x
} else {
weapon_stats.insert(cube.info.category, HashMap::new());
weapon_stats.get_mut(&cube.info.category).unwrap()
};
category_map.insert(cube.info.size, weapon_data.to_owned());
}
}
let mut weapons_vec: Vec<(Typed<C>, Typed<C>)> = Vec::with_capacity(weapon_stats.len());
for (k, v) in weapon_stats {
let cat_data: crate::data::weapon_list::ItemCategory = k.into();
let mut tiers_vec = Vec::with_capacity(v.len());
for (k, v) in v {
let tier_data: crate::data::cube_list::ItemTier = k.into();
let val_data: crate::data::weapon_list::WeaponData = v.into();
tiers_vec.push((Typed::Str(tier_data.as_str().into()), val_data.as_transmissible()));
}
weapons_vec.push((Typed::Str(cat_data.as_str().into()), Typed::HashMap(tiers_vec.into())));
}
Typed::Dict(Dict {
key_ty: TypePrefix::Str,
val_ty: TypePrefix::HashMap,
items: weapons_vec,
})
}
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct Cube {
pub id: u32,
pub info: CubeInfo,
pub weapon: Option<WeaponData>,
pub movement: Option<MovementData>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct CubeInfo {
#[serde(default = "default_1")]
pub cpu: u32,
#[serde(default = "default_1")]
pub health: u32,
#[serde(default = "default_1_0")]
pub health_boost: f32,
#[serde(default)]
pub grey_out_in_tutorial: bool,
#[serde(default)]
pub visibility: VisibilityMode,
#[serde(default)]
pub indestructible: bool,
#[serde(default)]
pub category: ItemCategory,
#[serde(default = "default_63")]
pub placements: u32,
#[serde(default)]
pub protonium: bool,
#[serde(default)]
pub unlocked_by_league: bool,
#[serde(default)]
pub league_unlock_index: i32,
pub stats: HashMap<String, serde_json::Value>,
pub description: String,
pub size: ItemTier,
#[serde(rename = "type", alias = "type_")]
pub type_: ItemType,
#[serde(default)]
pub ranking: i32,
#[serde(default)]
pub cosmetic: bool,
#[serde(default)]
pub variant_of: u32, // cube id (in hex)
#[serde(default = "default_true")]
pub ignore_in_weapon_list: bool,
}
fn default_1() -> u32 {
1
}
fn default_1_0() -> f32 {
1.0
}
fn default_63() -> u32 {
63
}
fn default_true() -> bool {
true
}
impl <C: Clone> std::convert::Into<crate::data::cube_list::CubeInfo<C>> for CubeInfo {
fn into(self) -> crate::data::cube_list::CubeInfo<C> {
crate::data::cube_list::CubeInfo {
cpu: self.cpu,
health: self.health,
health_boost: self.health_boost,
grey_out_in_tutorial: self.grey_out_in_tutorial,
visibility: self.visibility.into(),
indestructible: self.indestructible,
category: self.category.into(),
placements: self.placements, // default 63
protonium: self.protonium,
unlocked_by_league: self.unlocked_by_league,
league_unlock_index: self.league_unlock_index,
stats: self.stats.into_iter().map(|(k, v)| {
let new_v = match v {
serde_json::Value::Bool(b) => Typed::Bool(b),
serde_json::Value::Number(n) => if let Some(n_i64) = n.as_i64() {
Typed::Long(n_i64)
} else if let Some(n_f64) = n.as_f64() {
Typed::Double(n_f64)
} else {
panic!("Invalid json number")
},
serde_json::Value::String(s) => Typed::Str(s.into()),
_ => Typed::Null, // TODO is support for Object/Array/Null necessary?
};
(k, new_v)
}).collect(),
description: self.description,
size: self.size.into(),
type_: self.type_.into(),
ranking: self.ranking,
cosmetic: self.cosmetic,
variant_of: hex::encode(self.variant_of.to_be_bytes()).into(),
ignore_in_weapon_list: self.ignore_in_weapon_list,
}
}
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default)]
pub enum VisibilityMode {
Mothership,
#[default]
All,
Tutorial,
None,
}
impl std::convert::Into<crate::data::cube_list::VisibilityMode> for VisibilityMode {
fn into(self) -> crate::data::cube_list::VisibilityMode {
match self {
Self::Mothership => crate::data::cube_list::VisibilityMode::Mothership,
Self::All => crate::data::cube_list::VisibilityMode::All,
Self::Tutorial => crate::data::cube_list::VisibilityMode::Tutorial,
Self::None => crate::data::cube_list::VisibilityMode::None,
}
}
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default, Hash, PartialEq, Eq)]
pub enum ItemTier {
#[default]
NoTier = 0,
T0 = 100,
T1 = 200,
T2 = 300,
T3 = 400,
T4 = 500,
T5 = 600,
}
impl std::convert::Into<crate::data::cube_list::ItemTier> for ItemTier {
fn into(self) -> crate::data::cube_list::ItemTier {
match self {
Self::NoTier => crate::data::cube_list::ItemTier::NoTier,
Self::T0 => crate::data::cube_list::ItemTier::T0,
Self::T1 => crate::data::cube_list::ItemTier::T1,
Self::T2 => crate::data::cube_list::ItemTier::T2,
Self::T3 => crate::data::cube_list::ItemTier::T3,
Self::T4 => crate::data::cube_list::ItemTier::T4,
Self::T5 => crate::data::cube_list::ItemTier::T5,
}
}
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default)]
pub enum ItemType {
#[default]
NotAFunctionalItem,
Weapon,
Module,
Movement,
Cosmetic,
}
impl std::convert::Into<crate::data::cube_list::ItemType> for ItemType {
fn into(self) -> crate::data::cube_list::ItemType {
match self {
Self::NotAFunctionalItem => crate::data::cube_list::ItemType::NoFunction,
Self::Weapon => crate::data::cube_list::ItemType::Weapon,
Self::Module => crate::data::cube_list::ItemType::Module,
Self::Movement => crate::data::cube_list::ItemType::Movement,
Self::Cosmetic => crate::data::cube_list::ItemType::Cosmetic,
}
}
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Default, Hash, PartialEq, Eq)]
pub enum ItemCategory {
#[default]
NotAFunctionalItem = 0,
Wheel = 1,
Hover = 2,
Wing = 3,
Rudder = 4,
Thruster = 5,
InsectLeg = 6,
MechLeg = 7,
Ski = 8,
TankTrack = 9,
Rotor = 10,
SprinterLeg = 11,
Propeller = 12,
Laser = 100,
Plasma = 200,
Mortar = 250,
Rail = 300,
Nano = 400,
Tesla = 500,
Aeroflak = 600,
Ion = 650,
Seeker = 701,
Chaingun = 750,
ShieldModule = 800,
GhostModule = 801,
BlinkModule = 802,
EmpModule = 803,
WindowmakerModule = 804,
EnergyModule = 900,
}
impl std::convert::Into<crate::data::weapon_list::ItemCategory> for ItemCategory {
fn into(self) -> crate::data::weapon_list::ItemCategory {
match self {
Self::NotAFunctionalItem => crate::data::weapon_list::ItemCategory::NoFunction,
Self::Wheel => crate::data::weapon_list::ItemCategory::Wheel,
Self::Hover => crate::data::weapon_list::ItemCategory::Hover,
Self::Wing => crate::data::weapon_list::ItemCategory::Wing,
Self::Rudder => crate::data::weapon_list::ItemCategory::Rudder,
Self::Thruster => crate::data::weapon_list::ItemCategory::Thruster,
Self::InsectLeg => crate::data::weapon_list::ItemCategory::InsectLeg,
Self::MechLeg => crate::data::weapon_list::ItemCategory::MechLeg,
Self::Ski => crate::data::weapon_list::ItemCategory::Ski,
Self::TankTrack => crate::data::weapon_list::ItemCategory::TankTrack,
Self::Rotor => crate::data::weapon_list::ItemCategory::Rotor,
Self::SprinterLeg => crate::data::weapon_list::ItemCategory::SprinterLeg,
Self::Propeller => crate::data::weapon_list::ItemCategory::Propeller,
Self::Laser => crate::data::weapon_list::ItemCategory::Laser,
Self::Plasma => crate::data::weapon_list::ItemCategory::Plasma,
Self::Mortar => crate::data::weapon_list::ItemCategory::Mortar,
Self::Rail => crate::data::weapon_list::ItemCategory::Rail,
Self::Nano => crate::data::weapon_list::ItemCategory::Nano,
Self::Tesla => crate::data::weapon_list::ItemCategory::Tesla,
Self::Aeroflak => crate::data::weapon_list::ItemCategory::Aeroflak,
Self::Ion => crate::data::weapon_list::ItemCategory::Ion,
Self::Seeker => crate::data::weapon_list::ItemCategory::Seeker,
Self::Chaingun => crate::data::weapon_list::ItemCategory::Chaingun,
Self::ShieldModule => crate::data::weapon_list::ItemCategory::ShieldModule,
Self::GhostModule => crate::data::weapon_list::ItemCategory::GhostModule,
Self::BlinkModule => crate::data::weapon_list::ItemCategory::BlinkModule,
Self::EmpModule => crate::data::weapon_list::ItemCategory::EmpModule,
Self::WindowmakerModule => crate::data::weapon_list::ItemCategory::WindowmakerModule,
Self::EnergyModule => crate::data::weapon_list::ItemCategory::EnergyModule,
}
}
}
@@ -0,0 +1,9 @@
mod cubes;
pub use cubes::{CubeConfig, ItemTier};
//pub use cubes::{Cube, ItemCategory, VisibilityMode, ItemType};
mod movement;
pub use movement::{MovementCategoryData, MovementData};
mod weapon;
pub use weapon::WeaponData;
@@ -0,0 +1,448 @@
use serde::{Serialize, Deserialize};
use super::ItemTier;
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct MovementCategoryData {
pub horizontal_top_speed: Option<f32>,
pub vertical_top_speed: Option<f32>,
pub min_required_items: Option<i32>,
pub min_item_modifier: Option<f32>,
pub max_hover_height: Option<f32>,
pub light_machine_mass: Option<f32>,
pub heavy_machine_mass: Option<f32>,
pub specifics: MovementCategorySpecificData,
}
impl MovementCategoryData {
pub fn into_data(self, stats: Vec<(ItemTier, MovementData)>) -> crate::data::movement_list::MovementCategoryData {
crate::data::movement_list::MovementCategoryData {
horizontal_top_speed: self.horizontal_top_speed,
vertical_top_speed: self.vertical_top_speed,
min_required_items: self.min_required_items,
min_item_modifier: self.min_item_modifier,
max_hover_height: self.max_hover_height,
light_machine_mass: self.light_machine_mass,
heavy_machine_mass: self.heavy_machine_mass,
specifics: self.specifics.into(),
stats: stats.into_iter().map(|(t, m)| (t.into(), m.into())).collect(),
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub enum MovementCategorySpecificData {
#[default]
Wheel,
Hover(HoverCategoryData),
Wing,
Rudder, // same as wing
Thruster,
Propeller, // same as thruster
InsectLeg,
MechLeg(MechLegCategoryData),
SprinterLeg(MechLegCategoryData), // same as mech leg
TankTrack,
Rotor(RotorCategoryData),
}
impl std::convert::Into<crate::data::movement_list::MovementCategorySpecificData> for MovementCategorySpecificData {
fn into(self) -> crate::data::movement_list::MovementCategorySpecificData {
match self {
Self::Wheel => crate::data::movement_list::MovementCategorySpecificData::Wheel,
Self::Hover(x) => crate::data::movement_list::MovementCategorySpecificData::Hover(x.into()),
Self::Wing => crate::data::movement_list::MovementCategorySpecificData::Wing,
Self::Rudder => crate::data::movement_list::MovementCategorySpecificData::Rudder,
Self::Thruster => crate::data::movement_list::MovementCategorySpecificData::Thruster,
Self::Propeller => crate::data::movement_list::MovementCategorySpecificData::Propeller,
Self::InsectLeg => crate::data::movement_list::MovementCategorySpecificData::InsectLeg,
Self::MechLeg(x) => crate::data::movement_list::MovementCategorySpecificData::MechLeg(x.into()),
Self::SprinterLeg(x) => crate::data::movement_list::MovementCategorySpecificData::SprinterLeg(x.into()),
Self::TankTrack => crate::data::movement_list::MovementCategorySpecificData::TankTrack,
Self::Rotor(x) => crate::data::movement_list::MovementCategorySpecificData::Rotor(x.into()),
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct HoverCategoryData {
pub height_tolerance: f32,
pub force_y_offset: f32,
pub turning_scale: f32,
pub small_angle_turning_scale: f32,
pub max_vertical_velocity: f32,
pub hover_damping: f32,
pub angular_damping: f32,
pub deceleration_multiplier: f32,
}
impl std::convert::Into<crate::data::movement_list::HoverCategoryData> for HoverCategoryData {
fn into(self) -> crate::data::movement_list::HoverCategoryData {
crate::data::movement_list::HoverCategoryData {
height_tolerance: self.height_tolerance,
force_y_offset: self.force_y_offset,
turning_scale: self.turning_scale,
small_angle_turning_scale: self.small_angle_turning_scale,
max_vertical_velocity: self.max_vertical_velocity,
hover_damping: self.hover_damping,
angular_damping: self.angular_damping,
deceleration_multiplier: self.deceleration_multiplier,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct MechLegCategoryData {
pub deceleration_multiplier: f32,
}
impl std::convert::Into<crate::data::movement_list::MechLegCategoryData> for MechLegCategoryData {
fn into(self) -> crate::data::movement_list::MechLegCategoryData {
crate::data::movement_list::MechLegCategoryData {
deceleration_multiplier: self.deceleration_multiplier,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct RotorCategoryData {
pub max_turn_rate: f32,
}
impl std::convert::Into<crate::data::movement_list::RotorCategoryData> for RotorCategoryData {
fn into(self) -> crate::data::movement_list::RotorCategoryData {
crate::data::movement_list::RotorCategoryData {
max_turn_rate: self.max_turn_rate,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct MovementData {
pub speed_boost: Option<f32>,
pub max_carry_mass: Option<f32>,
pub horizontal_top_speed: Option<f32>,
pub vertical_top_speed: Option<f32>,
pub specifics: MovementSpecificData,
}
impl std::convert::Into<crate::data::movement_list::MovementData> for MovementData {
fn into(self) -> crate::data::movement_list::MovementData {
crate::data::movement_list::MovementData {
speed_boost: self.speed_boost,
max_carry_mass: self.max_carry_mass,
horizontal_top_speed: self.horizontal_top_speed,
vertical_top_speed: self.vertical_top_speed,
specifics: self.specifics.into(),
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum MovementSpecificData {
Wheel(WheelData),
Hover(HoverData),
Wing(AerofoilData),
Rudder(AerofoilData), // same as wing
Thruster(ThrusterData),
Propeller(ThrusterData), // same as thruster
InsectLeg(InsectLegData),
MechLeg(MechLegData),
SprinterLeg(MechLegData), // same as mech leg
TankTrack(TankTrackData),
Rotor(RotorData),
}
impl std::convert::Into<crate::data::movement_list::MovementSpecificData> for MovementSpecificData {
fn into(self) -> crate::data::movement_list::MovementSpecificData {
match self {
Self::Wheel(x) => crate::data::movement_list::MovementSpecificData::Wheel(x.into()),
Self::Hover(x) => crate::data::movement_list::MovementSpecificData::Hover(x.into()),
Self::Wing(x) => crate::data::movement_list::MovementSpecificData::Wing(x.into()),
Self::Rudder(x) => crate::data::movement_list::MovementSpecificData::Rudder(x.into()),
Self::Thruster(x) => crate::data::movement_list::MovementSpecificData::Thruster(x.into()),
Self::Propeller(x) => crate::data::movement_list::MovementSpecificData::Propeller(x.into()),
Self::InsectLeg(x) => crate::data::movement_list::MovementSpecificData::InsectLeg(x.into()),
Self::MechLeg(x) => crate::data::movement_list::MovementSpecificData::MechLeg(x.into()),
Self::SprinterLeg(x) => crate::data::movement_list::MovementSpecificData::SprinterLeg(x.into()),
Self::TankTrack(x) => crate::data::movement_list::MovementSpecificData::TankTrack(x.into()),
Self::Rotor(x) => crate::data::movement_list::MovementSpecificData::Rotor(x.into()),
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct WheelData {
pub steering_speed_light: f32,
pub steering_speed_heavy: f32,
pub steering_force_multiplier_light: f32,
pub steering_force_multiplier_heavy: f32,
pub lateral_acceleration_light: f32,
pub lateral_acceleration_heavy: f32,
pub time_to_max_acceleration_light: f32,
pub time_to_max_acceleration_heavy: f32,
pub brake_force_light: f32,
pub brake_force_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::WheelData> for WheelData {
fn into(self) -> crate::data::movement_list::WheelData {
crate::data::movement_list::WheelData {
steering_speed_light: self.steering_speed_light,
steering_speed_heavy: self.steering_speed_heavy,
steering_force_multiplier_light: self.steering_force_multiplier_light,
steering_force_multiplier_heavy: self.steering_force_multiplier_heavy,
lateral_acceleration_light: self.lateral_acceleration_light,
lateral_acceleration_heavy: self.lateral_acceleration_heavy,
time_to_max_acceleration_light: self.time_to_max_acceleration_light,
time_to_max_acceleration_heavy: self.time_to_max_acceleration_heavy,
brake_force_light: self.brake_force_light,
brake_force_heavy: self.brake_force_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct HoverData {
pub max_hover_height_light: f32,
pub max_hover_height_heaver: f32,
pub height_change_speed_light: f32,
pub height_change_speed_heavy: f32,
pub turn_torque_light: f32,
pub turn_torque_heavy: f32,
pub acceleration_light: f32,
pub acceleration_heavy: f32,
pub max_angular_velocity_light: f32,
pub max_angular_velocity_heavy: f32,
pub lateral_damping_light: f32,
pub lateral_damping_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::HoverData> for HoverData {
fn into(self) -> crate::data::movement_list::HoverData {
crate::data::movement_list::HoverData {
max_hover_height_light: self.max_hover_height_light,
max_hover_height_heaver: self.max_hover_height_heaver,
height_change_speed_light: self.height_change_speed_light,
height_change_speed_heavy: self.height_change_speed_heavy,
turn_torque_light: self.turn_torque_light,
turn_torque_heavy: self.turn_torque_heavy,
acceleration_light: self.acceleration_light,
acceleration_heavy: self.acceleration_heavy,
max_angular_velocity_light: self.max_angular_velocity_light,
max_angular_velocity_heavy: self.max_angular_velocity_heavy,
lateral_damping_light: self.lateral_damping_light,
lateral_damping_heavy: self.lateral_damping_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct AerofoilData {
pub barrel_speed_light: f32,
pub barrel_speed_heavy: f32,
pub bank_speed_light: f32,
pub bank_speed_heavy: f32,
pub elevation_speed_light: f32,
pub elevation_speed_heavy: f32,
pub rudder_speed_light: f32,
pub rudder_speed_heavy: f32,
pub thrust_light: f32,
pub thrust_heavy: f32,
pub vtol_velocity_light: f32,
pub vtol_velocity_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::AerofoilData> for AerofoilData {
fn into(self) -> crate::data::movement_list::AerofoilData {
crate::data::movement_list::AerofoilData {
barrel_speed_light: self.barrel_speed_light,
barrel_speed_heavy: self.barrel_speed_heavy,
bank_speed_light: self.bank_speed_light,
bank_speed_heavy: self.bank_speed_heavy,
elevation_speed_light: self.elevation_speed_light,
elevation_speed_heavy: self.elevation_speed_heavy,
rudder_speed_light: self.rudder_speed_light,
rudder_speed_heavy: self.rudder_speed_heavy,
thrust_light: self.thrust_light,
thrust_heavy: self.thrust_heavy,
vtol_velocity_light: self.vtol_velocity_light,
vtol_velocity_heavy: self.vtol_velocity_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct ThrusterData {
pub acceleration_delay_light: f32,
pub acceleration_delay_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::ThrusterData> for ThrusterData {
fn into(self) -> crate::data::movement_list::ThrusterData {
crate::data::movement_list::ThrusterData {
acceleration_delay_light: self.acceleration_delay_light,
acceleration_delay_heavy: self.acceleration_delay_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct InsectLegData {
pub ideal_height_light: f32,
pub ideal_height_heavy: f32,
pub ideal_crouching_height_light: f32,
pub ideal_crouching_height_heavy: f32,
pub ideal_height_range_light: f32,
pub ideal_height_range_heavy: f32,
pub jump_height_light: f32,
pub jump_height_heavy: f32,
pub max_upwards_force_light: f32,
pub max_upwards_force_heavy: f32,
pub max_lateral_force_light: f32,
pub max_lateral_force_heavy: f32,
pub max_turning_force_light: f32,
pub max_turning_force_heavy: f32,
pub max_damping_force_light: f32,
pub max_damping_force_heavy: f32,
pub max_stopped_force_light: f32,
pub max_stopped_force_heavy: f32,
pub max_new_stopped_force_light: f32,
pub max_new_stopped_force_heavy: f32,
pub upwards_damping_force_light: f32,
pub upwards_damping_force_heavy: f32,
pub lateral_damp_force_light: f32,
pub lateral_damp_force_heavy: f32,
pub swagger_force_light: f32,
pub swagger_force_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::InsectLegData> for InsectLegData {
fn into(self) -> crate::data::movement_list::InsectLegData {
crate::data::movement_list::InsectLegData {
ideal_height_light: self.ideal_height_light,
ideal_height_heavy: self.ideal_height_heavy,
ideal_crouching_height_light: self.ideal_crouching_height_light,
ideal_crouching_height_heavy: self.ideal_crouching_height_heavy,
ideal_height_range_light: self.ideal_height_range_light,
ideal_height_range_heavy: self.ideal_height_range_heavy,
jump_height_light: self.jump_height_light,
jump_height_heavy: self.jump_height_heavy,
max_upwards_force_light: self.max_upwards_force_light,
max_upwards_force_heavy: self.max_upwards_force_heavy,
max_lateral_force_light: self.max_lateral_force_light,
max_lateral_force_heavy: self.max_lateral_force_heavy,
max_turning_force_light: self.max_turning_force_light,
max_turning_force_heavy: self.max_turning_force_heavy,
max_damping_force_light: self.max_damping_force_light,
max_damping_force_heavy: self.max_damping_force_heavy,
max_stopped_force_light: self.max_stopped_force_light,
max_stopped_force_heavy: self.max_stopped_force_heavy,
max_new_stopped_force_light: self.max_new_stopped_force_light,
max_new_stopped_force_heavy: self.max_new_stopped_force_heavy,
upwards_damping_force_light: self.upwards_damping_force_light,
upwards_damping_force_heavy: self.upwards_damping_force_heavy,
lateral_damp_force_light: self.lateral_damp_force_light,
lateral_damp_force_heavy: self.lateral_damp_force_heavy,
swagger_force_light: self.swagger_force_light,
swagger_force_heavy: self.swagger_force_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct MechLegData {
pub time_grounded_after_jump_light: f32,
pub time_grounded_after_jump_heavy: f32,
pub jump_height_light: f32,
pub jump_height_heavy: f32,
pub turn_acceleration_light: f32,
pub turn_acceleration_heavy: f32,
pub legacy_turn_acceleration_light: f32,
pub legacy_turn_acceleration_heavy: f32,
pub long_jump_speec_scale_light: f32,
pub long_jump_speec_scale_heavy: f32,
pub max_lateral_force_light: f32,
pub max_lateral_force_heavy: f32,
pub max_damping_force_light: f32,
pub max_damping_force_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::MechLegData> for MechLegData {
fn into(self) -> crate::data::movement_list::MechLegData {
crate::data::movement_list::MechLegData {
time_grounded_after_jump_light: self.time_grounded_after_jump_light,
time_grounded_after_jump_heavy: self.time_grounded_after_jump_heavy,
jump_height_light: self.jump_height_light,
jump_height_heavy: self.jump_height_heavy,
turn_acceleration_light: self.turn_acceleration_light,
turn_acceleration_heavy: self.turn_acceleration_heavy,
legacy_turn_acceleration_light: self.legacy_turn_acceleration_light,
legacy_turn_acceleration_heavy: self.legacy_turn_acceleration_heavy,
long_jump_speec_scale_light: self.long_jump_speec_scale_light,
long_jump_speec_scale_heavy: self.long_jump_speec_scale_heavy,
max_lateral_force_light: self.max_lateral_force_light,
max_lateral_force_heavy: self.max_lateral_force_heavy,
max_damping_force_light: self.max_damping_force_light,
max_damping_force_heavy: self.max_damping_force_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct TankTrackData {
pub max_turn_rate_moving_light: f32,
pub max_turn_rate_moving_heavy: f32,
pub max_turn_rate_stopped_light: f32,
pub max_turn_rate_stopped_heavy: f32,
pub turn_acceleration_light: f32,
pub turn_acceleration_heavy: f32,
pub lateral_acceleration_light: f32,
pub lateral_acceleration_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::TankTrackData> for TankTrackData {
fn into(self) -> crate::data::movement_list::TankTrackData {
crate::data::movement_list::TankTrackData {
max_turn_rate_moving_light: self.max_turn_rate_moving_light,
max_turn_rate_moving_heavy: self.max_turn_rate_moving_heavy,
max_turn_rate_stopped_light: self.max_turn_rate_stopped_light,
max_turn_rate_stopped_heavy: self.max_turn_rate_stopped_heavy,
turn_acceleration_light: self.turn_acceleration_light,
turn_acceleration_heavy: self.turn_acceleration_heavy,
lateral_acceleration_light: self.lateral_acceleration_light,
lateral_acceleration_heavy: self.lateral_acceleration_heavy,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct RotorData {
pub height_acceleration_light: f32,
pub height_acceleration_heavy: f32,
pub strafe_acceleration_light: f32,
pub strafe_acceleration_heavy: f32,
pub turn_acceleration_light: f32,
pub turn_acceleration_heavy: f32,
pub height_max_change_speed_light: f32,
pub height_max_change_speed_heavy: f32,
pub level_acceleration_light: f32,
pub level_acceleration_heavy: f32,
}
impl std::convert::Into<crate::data::movement_list::RotorData> for RotorData {
fn into(self) -> crate::data::movement_list::RotorData {
crate::data::movement_list::RotorData {
height_acceleration_light: self.height_acceleration_light,
height_acceleration_heavy: self.height_acceleration_heavy,
strafe_acceleration_light: self.strafe_acceleration_light,
strafe_acceleration_heavy: self.strafe_acceleration_heavy,
turn_acceleration_light: self.turn_acceleration_light,
turn_acceleration_heavy: self.turn_acceleration_heavy,
height_max_change_speed_light: self.height_max_change_speed_light,
height_max_change_speed_heavy: self.height_max_change_speed_heavy,
level_acceleration_light: self.level_acceleration_light,
level_acceleration_heavy: self.level_acceleration_heavy,
}
}
}
@@ -0,0 +1,137 @@
use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
#[serde(default)]
pub struct WeaponData {
pub damage_inflicted: Option<i32>,
pub protonium_damage_scale: Option<f32>,
pub projectile_speed: Option<f32>,
pub projectile_range: Option<f32>,
pub base_inaccuracy: Option<f32>,
pub base_air_inaccuracy: Option<f32>,
pub movement_inaccuracy: Option<f32>,
pub movement_max_speed: Option<f32>,
pub movement_min_speed: Option<f32>,
pub gun_rotation_slow: Option<f32>,
pub movement_inaccuracy_decay: Option<f32>,
pub slow_rotation_decay: Option<f32>,
pub quick_rotation_decay: Option<f32>,
pub movement_inaccuracy_recovery: Option<f32>,
pub repeat_fire_inaccuracy_total_degrees: Option<f32>,
pub repeat_fire_inaccuracy_decay: Option<f32>,
pub repeat_fire_innaccuracy_recovery: Option<f32>,
pub fire_instant_accuracy_decay: Option<f32>, // degrees
pub accuracy_non_recover_time: Option<f32>,
pub accuracy_decay: Option<f32>,
pub damage_radius: Option<f32>,
pub plasma_time_to_full_damage: Option<f32>,
pub plasma_starting_radius_scale: Option<f32>,
pub nano_dps: Option<f32>,
pub nano_hps: Option<f32>,
pub tesla_damage: Option<f32>,
pub tesla_charges: Option<f32>,
pub aeroflak_proximity_damage: Option<f32>,
pub aeroflak_damage_radius: Option<f32>,
pub aeroflak_explosion_radius: Option<f32>,
pub aeroflak_ground_clearance: Option<f32>,
pub aeroflak_max_stacks: Option<i32>,
pub aeroflak_damage_per_stack: Option<i32>,
pub aeroflak_stack_expire: Option<f32>,
pub shot_cooldown: Option<f32>,
pub smart_rotation_cooldown: Option<f32>,
pub smart_rotation_cooldown_extra: Option<f32>,
pub smart_rotation_max_stacks: Option<f32>,
pub spin_up_time: Option<f32>,
pub spin_down_time: Option<f32>,
pub spin_initial_cooldown: Option<f32>,
pub group_fire_scales: Vec<f32>,
pub mana_cost: Option<f32>,
pub lock_time: Option<f32>,
pub full_lock_release: Option<f32>,
pub change_lock_time: Option<f32>,
pub max_rotation_speed: Option<f32>,
pub initial_rotation_speed: Option<f32>,
pub rotation_acceleration: Option<f32>,
pub nano_healing_priority_time: Option<f32>,
pub module_range: Option<f32>,
pub shield_lifetime: Option<f32>,
pub teleport_time: Option<f32>,
pub camera_time: Option<f32>,
pub camera_delay: Option<f32>,
pub to_invisible_speed: Option<f32>,
pub to_invisible_duration: Option<f32>,
pub to_visible_duration: Option<f32>,
pub countdown_time: Option<f32>,
pub stun_time: Option<f32>,
pub stun_radius: Option<f32>,
pub effect_duration: Option<f32>,
}
impl std::convert::Into<crate::data::weapon_list::WeaponData> for WeaponData {
fn into(self) -> crate::data::weapon_list::WeaponData {
crate::data::weapon_list::WeaponData {
damage_inflicted: self.damage_inflicted,
protonium_damage_scale: self.protonium_damage_scale,
projectile_speed: self.projectile_speed,
projectile_range: self.projectile_range,
base_inaccuracy: self.base_inaccuracy,
base_air_inaccuracy: self.base_air_inaccuracy,
movement_inaccuracy: self.movement_inaccuracy,
movement_max_speed: self.movement_max_speed,
movement_min_speed: self.movement_min_speed,
gun_rotation_slow: self.gun_rotation_slow,
movement_inaccuracy_decay: self.movement_inaccuracy_decay,
slow_rotation_decay: self.slow_rotation_decay,
quick_rotation_decay: self.quick_rotation_decay,
movement_inaccuracy_recovery: self.movement_inaccuracy_recovery,
repeat_fire_inaccuracy_total_degrees: self.repeat_fire_inaccuracy_total_degrees,
repeat_fire_inaccuracy_decay: self.repeat_fire_inaccuracy_decay,
repeat_fire_innaccuracy_recovery: self.repeat_fire_innaccuracy_recovery,
fire_instant_accuracy_decay: self.fire_instant_accuracy_decay, // degrees
accuracy_non_recover_time: self.accuracy_non_recover_time,
accuracy_decay: self.accuracy_decay,
damage_radius: self.damage_radius,
plasma_time_to_full_damage: self.plasma_time_to_full_damage,
plasma_starting_radius_scale: self.plasma_starting_radius_scale,
nano_dps: self.nano_dps,
nano_hps: self.nano_hps,
tesla_damage: self.tesla_damage,
tesla_charges: self.tesla_charges,
aeroflak_proximity_damage: self.aeroflak_proximity_damage,
aeroflak_damage_radius: self.aeroflak_damage_radius,
aeroflak_explosion_radius: self.aeroflak_explosion_radius,
aeroflak_ground_clearance: self.aeroflak_ground_clearance,
aeroflak_max_stacks: self.aeroflak_max_stacks,
aeroflak_damage_per_stack: self.aeroflak_damage_per_stack,
aeroflak_stack_expire: self.aeroflak_stack_expire,
shot_cooldown: self.shot_cooldown,
smart_rotation_cooldown: self.smart_rotation_cooldown,
smart_rotation_cooldown_extra: self.smart_rotation_cooldown_extra,
smart_rotation_max_stacks: self.smart_rotation_max_stacks,
spin_up_time: self.spin_up_time,
spin_down_time: self.spin_down_time,
spin_initial_cooldown: self.spin_initial_cooldown,
group_fire_scales: self.group_fire_scales,
mana_cost: self.mana_cost,
lock_time: self.lock_time,
full_lock_release: self.full_lock_release,
change_lock_time: self.change_lock_time,
max_rotation_speed: self.max_rotation_speed,
initial_rotation_speed: self.initial_rotation_speed,
rotation_acceleration: self.rotation_acceleration,
nano_healing_priority_time: self.nano_healing_priority_time,
module_range: self.module_range,
shield_lifetime: self.shield_lifetime,
teleport_time: self.teleport_time,
camera_time: self.camera_time,
camera_delay: self.camera_delay,
to_invisible_speed: self.to_invisible_speed,
to_invisible_duration: self.to_invisible_duration,
to_visible_duration: self.to_visible_duration,
countdown_time: self.countdown_time,
stun_time: self.stun_time,
stun_radius: self.stun_radius,
effect_duration: self.effect_duration,
}
}
}