2025-03-08 17:16:02 -05:00
|
|
|
use polariton::{operation::{Arr, Typed}, serdes::TypePrefix};
|
2025-02-23 16:10:21 -05:00
|
|
|
|
2025-03-01 16:22:57 -05:00
|
|
|
use super::weapon_list::ItemCategory;
|
2025-02-23 16:10:21 -05:00
|
|
|
|
|
|
|
|
pub struct GarageSlotInfo {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub cubes: u32,
|
|
|
|
|
pub crf_id: u32, // 0 means not uploaded
|
|
|
|
|
pub was_rated: bool, // ignored when not on CRF
|
2025-03-01 16:22:57 -05:00
|
|
|
pub movement_categories: Vec<ItemCategory>,
|
2025-02-23 16:10:21 -05:00
|
|
|
pub uuid: (u32, u32),
|
|
|
|
|
pub thumbnail_version: u32,
|
|
|
|
|
pub total_robot_cpu: u32,
|
|
|
|
|
pub total_cosmetic_cpu: u32,
|
|
|
|
|
pub total_robot_ranking: u32,
|
|
|
|
|
pub bay_cpu: u32,
|
|
|
|
|
pub tutorial_robot: bool, // assumed to be false (when omitted)
|
|
|
|
|
pub starter_robot_index: i32, // assumed to be -1 (whem omitted)
|
2025-02-23 20:17:46 -05:00
|
|
|
pub control_type: ControlType,
|
|
|
|
|
pub control_options: ControlOptions,
|
2025-02-23 16:10:21 -05:00
|
|
|
pub mastery_level: i32,
|
|
|
|
|
pub bay_skin_id: String,
|
|
|
|
|
pub weapon_order: Vec<i32>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl GarageSlotInfo {
|
2025-03-15 11:03:35 -04:00
|
|
|
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
2025-02-23 16:10:21 -05:00
|
|
|
Typed::HashMap(vec![
|
|
|
|
|
(Typed::Str("name".into()), Typed::Str(self.name.clone().into())),
|
|
|
|
|
(Typed::Str("numberCubes".into()), Typed::Int(self.cubes as i32)),
|
|
|
|
|
(Typed::Str("crfId".into()), Typed::Int(self.crf_id as i32)),
|
2025-09-03 22:33:26 -04:00
|
|
|
(Typed::Str("wasRated".into()), Typed::Bool(self.was_rated)),
|
2025-02-23 16:10:21 -05:00
|
|
|
(Typed::Str("movementCategories".into()), Typed::Arr(Arr {
|
2025-03-08 17:16:02 -05:00
|
|
|
ty: TypePrefix::Int, // int
|
2025-09-03 22:33:26 -04:00
|
|
|
items: self.movement_categories.iter().map(|x| Typed::Int(x.but_bigger())).collect(),
|
2025-02-23 16:10:21 -05:00
|
|
|
})),
|
|
|
|
|
(Typed::Str("uniqueId1".into()), Typed::Int(self.uuid.0 as i32)),
|
|
|
|
|
(Typed::Str("uniqueId2".into()), Typed::Int(self.uuid.1 as i32)),
|
|
|
|
|
(Typed::Str("thumbnailVersion".into()), Typed::Int(self.thumbnail_version as i32)),
|
|
|
|
|
(Typed::Str("totalRobotCPU".into()), Typed::Int(self.total_robot_cpu as i32)),
|
|
|
|
|
(Typed::Str("totalCosmeticCPU".into()), Typed::Int(self.total_cosmetic_cpu as i32)),
|
|
|
|
|
(Typed::Str("totalRobotRanking".into()), Typed::Int(self.total_robot_ranking as i32)),
|
|
|
|
|
(Typed::Str("bayCpu".into()), Typed::Int(self.bay_cpu as i32)),
|
2025-09-03 22:33:26 -04:00
|
|
|
(Typed::Str("tutorialRobot".into()), Typed::Bool(self.tutorial_robot)),
|
2025-02-23 16:10:21 -05:00
|
|
|
(Typed::Str("starterRobotIndex".into()), Typed::Int(self.starter_robot_index)),
|
2025-02-23 20:17:46 -05:00
|
|
|
(Typed::Str("controlType".into()), Typed::Int(self.control_type as i32)),
|
2025-03-01 16:22:57 -05:00
|
|
|
(Typed::Str("controlOptions".into()), self.control_options.as_transmissible()),
|
2025-02-23 16:10:21 -05:00
|
|
|
(Typed::Str("masteryLevel".into()), Typed::Int(self.mastery_level)),
|
|
|
|
|
(Typed::Str("baySkinId".into()), Typed::Str(self.bay_skin_id.clone().into())),
|
|
|
|
|
(Typed::Str("weaponOrder".into()), Typed::Arr(Arr {
|
2025-03-08 17:16:02 -05:00
|
|
|
ty: TypePrefix::Int, // int
|
2025-02-23 16:10:21 -05:00
|
|
|
items: self.weapon_order.iter().map(|x| Typed::Int(*x)).collect(),
|
|
|
|
|
})),
|
|
|
|
|
].into())
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-23 20:17:46 -05:00
|
|
|
#[allow(dead_code)]
|
|
|
|
|
#[repr(i32)]
|
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
|
pub enum ControlType {
|
|
|
|
|
Camera = 0,
|
|
|
|
|
Keyboard = 1,
|
|
|
|
|
Count = 2,
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-26 21:30:28 -04:00
|
|
|
impl std::convert::From<crate::persist::user::ControlType> for ControlType {
|
|
|
|
|
#[inline]
|
|
|
|
|
fn from(value: crate::persist::user::ControlType) -> Self {
|
|
|
|
|
match value {
|
|
|
|
|
crate::persist::user::ControlType::Camera => Self::Camera,
|
|
|
|
|
crate::persist::user::ControlType::Keyboard => Self::Keyboard,
|
|
|
|
|
crate::persist::user::ControlType::Count => Self::Count,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-23 20:17:46 -05:00
|
|
|
pub struct ControlOptions {
|
|
|
|
|
pub vertical_strafing: bool,
|
|
|
|
|
pub sideways_driving: bool,
|
|
|
|
|
pub tracks_turn_on_spot: bool,
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-01 16:22:57 -05:00
|
|
|
impl ControlOptions {
|
2025-03-15 11:03:35 -04:00
|
|
|
pub fn as_transmissible<C>(&self) -> Typed<C> {
|
2025-03-01 16:22:57 -05:00
|
|
|
Typed::Arr(Arr {
|
2025-03-08 17:16:02 -05:00
|
|
|
ty: TypePrefix::Bool, // bool
|
2025-03-01 16:22:57 -05:00
|
|
|
items: vec![
|
2025-09-03 22:33:26 -04:00
|
|
|
Typed::Bool(self.vertical_strafing),
|
|
|
|
|
Typed::Bool(self.sideways_driving),
|
|
|
|
|
Typed::Bool(self.tracks_turn_on_spot),
|
2025-03-01 16:22:57 -05:00
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-23 16:10:21 -05:00
|
|
|
|