From ea76747998bc576a4808c6af667dc457fb64428d Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Wed, 15 May 2024 23:54:32 +0800 Subject: [PATCH] DR rs 0.3.2 --- .../src/src/python/data.rs | 1 - .../Difficult_Rocket_rs/src/src/sr1_parse.rs | 8 ++++--- .../src/sr1_parse/data_structure/part_list.rs | 22 ++++++++++++------- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/python/data.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/python/data.rs index 88fad42..3a1609b 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/python/data.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/python/data.rs @@ -11,7 +11,6 @@ use crate::sr1_parse::{get_max_box, SR1PartData, SR1PartListTrait}; use crate::sr1_parse::{SR1PartList, SR1PartType, SR1Ship}; use crate::IdType; -// use serde_xml_rs::to_string; use quick_xml::se::to_string; #[pyclass] diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs index 76bcd79..2112021 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse.rs @@ -6,7 +6,7 @@ use crate::dr_physics::math::{Edge, Shape}; use crate::dr_physics::math::{Point2D, Rotate}; use crate::sr1_parse::part_list::Damage as RawDamage; use crate::sr1_parse::part_list::{AttachPoint, AttachPoints, Engine, Lander, Rcs, Shape as RawShape, Solar, Tank}; -use crate::sr1_parse::part_list::{RawPartList, RawPartType, SR1PartTypeEnum}; +use crate::sr1_parse::part_list::{RawPartList, RawPartType, SR1PartTypeEnum, FuelType}; use crate::sr1_parse::ship::{ Activate as RawActivate, Connection, Connections, DisconnectedPart as RawDisconnectedPart, DisconnectedParts as RawDisconnectedParts, Engine as RawEngine, Part as RawPartData, Parts as RawParts, @@ -41,7 +41,7 @@ pub enum SR1PartTypeAttr { Tank { fuel: f64, dry_mass: f64, - fuel_type: i32, + fuel_type: FuelType, }, Engine { power: f64, @@ -53,7 +53,7 @@ pub enum SR1PartTypeAttr { /// 1 -> Rcs /// 2 -> 电量 /// 3 -> 固推 - fuel_type: i32, + fuel_type: FuelType, throttle_exponential: bool, }, Rcs { @@ -219,11 +219,13 @@ pub trait SR1PartDataTrait { pub trait SR1PartListTrait { fn to_sr_part_list(&self, name: Option) -> SR1PartList; + #[allow(unused)] fn to_raw_part_list(&self) -> RawPartList; } pub trait SR1ShipTrait { fn to_sr_ship(&self, name: Option) -> SR1Ship; + #[allow(unused)] fn to_raw_ship(&self) -> RawShip; } diff --git a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse/data_structure/part_list.rs b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse/data_structure/part_list.rs index 3c94bc9..2e6ef46 100644 --- a/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse/data_structure/part_list.rs +++ b/mods/dr_game/Difficult_Rocket_rs/src/src/sr1_parse/data_structure/part_list.rs @@ -149,11 +149,17 @@ impl Damage { } // This enumeration can be considered to replace the integer-represented "fuel type". +#[derive(Debug, Serialize, Deserialize, Copy, Clone, Default)] pub enum FuelType { - Common, - Rcs, - Battery, - Soild, + /// 就是液体燃料 + #[default] + Common = 0, + /// RCS 推进剂 + Rcs = 1, + /// 电!!!!! + Battery = 2, + /// 固推神教! + Soild = 3, } #[derive(Debug, Serialize, Deserialize, Copy, Clone)] @@ -167,7 +173,7 @@ pub struct Tank { // 2 -> 电量 // 3 -> 固推 #[serde(rename = "@fuelType")] - pub fuel_type: Option, + pub fuel_type: Option, } #[derive(Debug, Serialize, Deserialize, Copy, Clone)] @@ -181,7 +187,7 @@ pub struct Engine { #[serde(rename = "@turn")] pub turn: f64, #[serde(rename = "@fuelType")] - pub fuel_type: Option, + pub fuel_type: Option, #[serde(rename = "@throttleExponential")] pub throttle_exponential: Option, } @@ -286,7 +292,7 @@ impl SR1PartTypeData for RawPartType { Some(SR1PartTypeAttr::Tank { fuel: tank.fuel, dry_mass: tank.dry_mass, - fuel_type: tank.fuel_type.unwrap_or(0), + fuel_type: tank.fuel_type.unwrap_or_default(), }) } SR1PartTypeEnum::engine => { @@ -296,7 +302,7 @@ impl SR1PartTypeData for RawPartType { consumption: engine.consumption, size: engine.size, turn: engine.turn, - fuel_type: engine.fuel_type.unwrap_or(0), + fuel_type: engine.fuel_type.unwrap_or_default(), throttle_exponential: engine.throttle_exponential.unwrap_or(false), }) }