From 1b68335f0eaab73371c857b67d05803170bba866 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sun, 9 Apr 2023 13:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=99=A9=E6=A2=A6=E7=BA=A7=E5=88=AB=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E6=8E=A8=E5=AF=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/Difficult_Rocket_rs/src/src/sr1_data.rs | 33 +++++++++++++++----- libs/Difficult_Rocket_rs/src/src/types.rs | 2 +- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/libs/Difficult_Rocket_rs/src/src/sr1_data.rs b/libs/Difficult_Rocket_rs/src/src/sr1_data.rs index 398871e..8a4956d 100644 --- a/libs/Difficult_Rocket_rs/src/src/sr1_data.rs +++ b/libs/Difficult_Rocket_rs/src/src/sr1_data.rs @@ -529,6 +529,16 @@ pub mod ship { pub child_part: i64, } + impl SR1PartDataTrait for Part { + fn to_sr_part_data(&self) -> SR1PartData { + todo!() + } + + fn to_raw_part_data(&self) -> Part { + self.clone() + } + } + impl SR1ShipTrait for RawShip { #[inline] fn to_sr_ship(&self, name: Option) -> SR1Ship { @@ -536,26 +546,33 @@ pub mod ship { for part in &self.parts.parts { parts.push(part.to_sr_part_data()); } - let disconnected = match self.disconnected { + let disconnected = match &self.disconnected { Some(disconnect) => { // let mut disconnect_parts = Vec::new(); - let mut parts = Vec::new(); + + let mut disconnect_parts = Vec::new(); for disconnected_part in &disconnect.parts { - let parts = Vec::new(); - for part in disconnected_part.parts.parts { - parts.push(part.to_sr_part_data()); + + let mut parts_vec = Vec::new(); + for part in &disconnected_part.parts.parts { + + parts_vec.push(part.to_sr_part_data()); } - parts.push((parts, disconnected_part.connects.connects.clone())); + disconnect_parts.push((parts_vec, disconnected_part.connects.connects.clone())); } - parts + Some(disconnect_parts) } _ => None, }; + let connections = match &self.connects.connects { + Some(connections) => connections.clone(), + _ => Vec::new(), + }; SR1Ship { name: name.unwrap_or("NewShip".to_string()), description: "".to_string(), parts, - connections: self.connects.connects.unwrap_or(Vec::new()), + connections, lift_off: i8_to_bool(self.lift_off), touch_ground: i8_to_bool(self.touch_ground), disconnected, diff --git a/libs/Difficult_Rocket_rs/src/src/types.rs b/libs/Difficult_Rocket_rs/src/src/types.rs index efe8edd..9b98d19 100644 --- a/libs/Difficult_Rocket_rs/src/src/types.rs +++ b/libs/Difficult_Rocket_rs/src/src/types.rs @@ -577,7 +577,7 @@ pub mod sr1 { disconnected_vec.push(RawDisconnectedPart { parts: RawParts { parts: raw_parts }, connects: Connections { - connects: Some(connections.clone()), + connects: connections.clone(), }, }); }