This commit is contained in:
shenjack 2023-07-24 09:46:11 +08:00
parent e997633cc5
commit 24f17f6d4f
Signed by: shenjack
GPG Key ID: 7B1134A979775551
6 changed files with 16 additions and 15 deletions

View File

@ -116,7 +116,7 @@ dependencies = [
[[package]]
name = "difficult_rocket_rs"
version = "0.2.19"
version = "0.2.20"
dependencies = [
"pyo3",
"quick-xml",

View File

@ -1,6 +1,6 @@
[package]
name = "difficult_rocket_rs"
version = "0.2.19"
version = "0.2.20"
edition = "2021"
license-file = '../../LICENSE'
authors = [

View File

@ -24,7 +24,7 @@ enum LoadState {
}
#[pyfunction]
fn get_version_str() -> String { "0.2.19.0".to_string() }
fn get_version_str() -> String { "0.2.20.0".to_string() }
#[pyfunction]
fn test_call(py_obj: &PyAny) -> PyResult<bool> {

View File

@ -422,7 +422,7 @@ pub mod ship {
pub x: f64,
pub y: f64,
#[serde(rename = "editorAngle")]
pub editor_angle: i32,
pub editor_angle: Option<i32>, // Option for https://github.com/shenjackyuanjie/Difficult-Rocket/issues/47
pub angle: f64,
#[serde(rename = "angleV")]
pub angle_v: f64,
@ -515,12 +515,6 @@ pub mod ship {
pub child_part: IdType,
}
impl Part {
/// 根据 Part 的原始数据猜测 Part 的类型
/// jundroo 我日你先人
fn guess_part_type(&self) -> SR1PartTypeEnum { todo!() }
}
impl SR1PartDataTrait for Part {
fn to_sr_part_data(&self) -> SR1PartData {
let attr = SR1PartDataAttr::from_raw(&self, None, true);
@ -534,7 +528,7 @@ pub mod ship {
angle_v: self.angle_v.to_owned(),
flip_x: i8_to_bool(self.flip_x.unwrap_or(0_i8)),
flip_y: i8_to_bool(self.flip_y.unwrap_or(0_i8)),
editor_angle: self.editor_angle.to_owned(),
editor_angle: self.editor_angle.unwrap_or(0_i32),
part_type,
part_type_id: self.part_type_id.clone(),
active: i8_to_bool(self.activated.unwrap_or(0_i8)),

View File

@ -470,7 +470,7 @@ pub mod sr1 {
id: self.id,
x: self.x,
y: self.y,
editor_angle: self.editor_angle,
editor_angle: Some(self.editor_angle),
angle: self.angle,
angle_v: self.angle_v,
flip_x: Some(bool_to_i8(self.flip_x)),
@ -708,8 +708,15 @@ pub mod sr1 {
return None;
}
// 解析为 RawShip
let ship: RawShip = RawShip::from_file(file_name).unwrap();
Some(ship.to_sr_ship(ship_name))
let ship: Option<RawShip> = RawShip::from_file(file_name);
match ship {
Some(ship) => {
// 解析为 SR1Ship
let sr_ship = ship.to_sr_ship(ship_name);
Some(sr_ship)
}
None => None,
}
}
pub fn parse_part_list_to_part(&mut self, part_list: &SR1PartList) {

View File

@ -16,7 +16,7 @@ from Difficult_Rocket.api.mod import ModInfo
from Difficult_Rocket.client import ClientWindow
from Difficult_Rocket.api.types import Options, Version
DR_rust_version = Version("0.2.19.0") # DR_mod 的 Rust 编写部分的兼容版本
DR_rust_version = Version("0.2.20.0") # DR_mod 的 Rust 编写部分的兼容版本
logger = logging.getLogger('client.dr_game')