Adjust file structures and bump version to 0.3.1
.
This commit is contained in:
parent
57472028b7
commit
3224c8fc9f
47
mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock
generated
47
mods/dr_game/Difficult_Rocket_rs/src/Cargo.lock
generated
@ -67,9 +67,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam"
|
name = "crossbeam"
|
||||||
version = "0.8.2"
|
version = "0.8.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2801af0d36612ae591caa9568261fddce32ce6e08a7275ea334a06a4ad021a2c"
|
checksum = "6eb9105919ca8e40d437fc9cbb8f1975d916f1bd28afe795a48aae32a2cc8920"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-channel",
|
"crossbeam-channel",
|
||||||
@ -81,9 +81,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-channel"
|
name = "crossbeam-channel"
|
||||||
version = "0.5.9"
|
version = "0.5.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "14c3242926edf34aec4ac3a77108ad4854bffaa2e4ddc1824124ce59231302d5"
|
checksum = "82a9b73a36529d9c47029b9fb3a6f0ea3cc916a261195352ba19e770fc1748b2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
@ -102,21 +102,20 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-epoch"
|
name = "crossbeam-epoch"
|
||||||
version = "0.9.16"
|
version = "0.9.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2d2fe95351b870527a5d09bf563ed3c97c0cffb87cf1c78a591bf48bb218d9aa"
|
checksum = "0e3681d554572a651dda4186cd47240627c3d0114d45a95f6ad27f2f22e7548d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg",
|
"autocfg",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
"memoffset",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-queue"
|
name = "crossbeam-queue"
|
||||||
version = "0.3.9"
|
version = "0.3.10"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b9bcf5bdbfdd6030fb4a1c497b5d5fc5921aa2f60d359a17e249c0e6df3de153"
|
checksum = "adc6598521bb5a83d491e8c1fe51db7296019d2ca3cb93cc6c2a20369a4d78a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"crossbeam-utils",
|
"crossbeam-utils",
|
||||||
@ -124,9 +123,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.17"
|
version = "0.8.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c06d96137f14f244c37f989d9fff8f95e6c18b918e71f36638f8c49112e4c78f"
|
checksum = "c3a430a770ebd84726f584a90ee7f020d28db52c6d02138900f22341f866d39c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
@ -144,7 +143,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "difficult_rocket_rs"
|
name = "difficult_rocket_rs"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dict_derive",
|
"dict_derive",
|
||||||
"fs-err",
|
"fs-err",
|
||||||
@ -381,9 +380,9 @@ checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.70"
|
version = "1.0.71"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b"
|
checksum = "75cb1540fadbd5b8fbccc4dddad2734eba435053f725621c070711a14bb5f4b8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
@ -434,7 +433,7 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"pyo3-macros-backend",
|
"pyo3-macros-backend",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.41",
|
"syn 2.0.42",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -446,7 +445,7 @@ dependencies = [
|
|||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.41",
|
"syn 2.0.42",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -548,7 +547,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.41",
|
"syn 2.0.42",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -604,9 +603,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.41"
|
version = "2.0.42"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "44c8b28c477cc3bf0e7966561e3460130e1255f7a1cf71931075f1c5e7a7e269"
|
checksum = "5b7d0a2c048d661a1a59fcd7355baa232f7ed34e0ee4df2eef3c1c1c0d3852d8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -718,20 +717,20 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.7.31"
|
version = "0.7.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1c4061bedbb353041c12f413700357bec76df2c7e2ca8e4df8bac24c6bf68e3d"
|
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.7.31"
|
version = "0.7.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b3c129550b3e6de3fd0ba67ba5c81818f9805e58b8d7fee80a3a59d2c9fc601a"
|
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.41",
|
"syn 2.0.42",
|
||||||
]
|
]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "difficult_rocket_rs"
|
name = "difficult_rocket_rs"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license-file = '../../LICENSE'
|
license-file = '../../LICENSE'
|
||||||
authors = ["shenjackyuanjie <3695888@qq.com>"]
|
authors = ["shenjackyuanjie <3695888@qq.com>"]
|
||||||
@ -14,13 +14,10 @@ crate-type = ["cdylib"]
|
|||||||
#[profile.dev.package.rapier2d-f64]
|
#[profile.dev.package.rapier2d-f64]
|
||||||
#opt-level = 2
|
#opt-level = 2
|
||||||
|
|
||||||
[profile.dev]
|
|
||||||
opt-level = 0
|
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
# Abort panic info to rapidly terminate program instead of unwinding call stacks.
|
# 舍弃恐慌信息以快速终止程序,而非展开调用栈。
|
||||||
# To check panic info, compile the program in dev mode.
|
# 请以开发模式编译程序以检查恐慌信息。
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
opt-level = 2
|
opt-level = 2
|
||||||
|
|
||||||
@ -28,9 +25,7 @@ opt-level = 2
|
|||||||
fs-err = "2.11.0"
|
fs-err = "2.11.0"
|
||||||
quick-xml = { version = "0.31.0", features = ["serialize"] }
|
quick-xml = { version = "0.31.0", features = ["serialize"] }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
|
|
||||||
nalgebra = "0.32.3"
|
nalgebra = "0.32.3"
|
||||||
rapier2d-f64 = { version = "0.17.2", features = ["simd-stable"] }
|
rapier2d-f64 = { version = "0.17.2", features = ["simd-stable"] }
|
||||||
|
|
||||||
pyo3 = { version = "0.20.0", features = ["extension-module", "macros"] }
|
pyo3 = { version = "0.20.0", features = ["extension-module", "macros"] }
|
||||||
dict_derive = "0.5"
|
dict_derive = "0.5"
|
||||||
|
@ -12,7 +12,7 @@ package_path = "Difficult_Rocket_rs"
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="Difficult_Rocket_rs",
|
name="Difficult_Rocket_rs",
|
||||||
version="0.3.0",
|
version="0.3.1",
|
||||||
author="shenjackyuanjie",
|
author="shenjackyuanjie",
|
||||||
author_email="3695888@qq.com",
|
author_email="3695888@qq.com",
|
||||||
rust_extensions=[
|
rust_extensions=[
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
/*
|
|
||||||
* -------------------------------
|
|
||||||
* Difficult Rocket
|
|
||||||
* Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
|
||||||
* All rights reserved
|
|
||||||
* -------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
pub mod dr;
|
|
||||||
pub mod math;
|
|
||||||
pub mod sr1;
|
|
||||||
|
|
||||||
pub type IdType = i64;
|
|
3
mods/dr_game/Difficult_Rocket_rs/src/src/dr_physics.rs
Normal file
3
mods/dr_game/Difficult_Rocket_rs/src/src/dr_physics.rs
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
pub mod math;
|
||||||
|
pub mod rigid;
|
||||||
|
pub mod simulation;
|
@ -1,6 +1,6 @@
|
|||||||
pub const POINT_D: f64 = 1.0;
|
pub const POINT_D: f64 = 1.0;
|
||||||
|
|
||||||
pub trait Rotatable {
|
pub trait Rotate {
|
||||||
// 懒了,直接实现一个协议得了
|
// 懒了,直接实现一个协议得了
|
||||||
fn rotate(&self, angle: f64) -> Self;
|
fn rotate(&self, angle: f64) -> Self;
|
||||||
fn rotate_radius(&self, radius: f64) -> Self;
|
fn rotate_radius(&self, radius: f64) -> Self;
|
||||||
@ -44,7 +44,7 @@ impl Point2D {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rotatable for Point2D {
|
impl Rotate for Point2D {
|
||||||
fn rotate_radius(&self, radius: f64) -> Self {
|
fn rotate_radius(&self, radius: f64) -> Self {
|
||||||
let sin = radius.sin();
|
let sin = radius.sin();
|
||||||
let cos = radius.cos();
|
let cos = radius.cos();
|
||||||
@ -85,13 +85,14 @@ pub struct OneTimeLine {
|
|||||||
// pub b: f64,
|
// pub b: f64,
|
||||||
// y = kx + b
|
// y = kx + b
|
||||||
// kx + b - y = 0
|
// kx + b - y = 0
|
||||||
pub start: Point2D,
|
|
||||||
// start point
|
// start point
|
||||||
pub end: Point2D,
|
pub start: Point2D,
|
||||||
// end point
|
// end point
|
||||||
|
pub end: Point2D,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Rotatable for OneTimeLine {
|
impl Rotate for OneTimeLine {
|
||||||
fn rotate(&self, angle: f64) -> Self {
|
fn rotate(&self, angle: f64) -> Self {
|
||||||
self.rotate_radius(angle.to_radians())
|
self.rotate_radius(angle.to_radians())
|
||||||
}
|
}
|
@ -6,18 +6,18 @@
|
|||||||
* -------------------------------
|
* -------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mod data_type;
|
mod dr_physics;
|
||||||
mod plugin_loader;
|
|
||||||
mod python;
|
mod python;
|
||||||
mod simulator;
|
mod sr1_parse;
|
||||||
mod sr1_data;
|
|
||||||
mod xml_reader;
|
mod xml_reader;
|
||||||
|
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
|
pub type IdType = i64;
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
fn get_version_str() -> String {
|
fn get_version_str() -> String {
|
||||||
"0.3.0".to_string()
|
"0.3.1".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
@ -31,8 +31,8 @@ fn test_call(py_obj: &PyAny) -> PyResult<bool> {
|
|||||||
fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||||
m.add_function(wrap_pyfunction!(get_version_str, m)?)?;
|
m.add_function(wrap_pyfunction!(get_version_str, m)?)?;
|
||||||
m.add_function(wrap_pyfunction!(test_call, m)?)?;
|
m.add_function(wrap_pyfunction!(test_call, m)?)?;
|
||||||
m.add_function(wrap_pyfunction!(sr1_data::part_list::read_part_list_py, m)?)?;
|
m.add_function(wrap_pyfunction!(sr1_parse::part_list::read_part_list_py, m)?)?;
|
||||||
m.add_function(wrap_pyfunction!(sr1_data::ship::py_raw_ship_from_file, m)?)?;
|
m.add_function(wrap_pyfunction!(sr1_parse::ship::py_raw_ship_from_file, m)?)?;
|
||||||
m.add_function(wrap_pyfunction!(python::data::load_and_save_test, m)?)?;
|
m.add_function(wrap_pyfunction!(python::data::load_and_save_test, m)?)?;
|
||||||
m.add_class::<python::data::PySR1Ship>()?;
|
m.add_class::<python::data::PySR1Ship>()?;
|
||||||
m.add_class::<python::data::PySR1PartList>()?;
|
m.add_class::<python::data::PySR1PartList>()?;
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* -------------------------------
|
|
||||||
* Difficult Rocket
|
|
||||||
* Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com
|
|
||||||
* All rights reserved
|
|
||||||
* -------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO libloading
|
|
||||||
|
|
||||||
/// https://docs.rs/libloading/latest/libloading/
|
|
||||||
/// 插件加载
|
|
||||||
///
|
|
||||||
|
|
||||||
pub struct ModInfo {
|
|
||||||
pub name: String,
|
|
||||||
pub version: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait ModInfoTrait {
|
|
||||||
fn info() -> ModInfo;
|
|
||||||
}
|
|
@ -3,13 +3,13 @@ use std::collections::HashMap;
|
|||||||
use pyo3::exceptions::PyValueError;
|
use pyo3::exceptions::PyValueError;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
|
|
||||||
use crate::data_type::math::{Point2D, Rotatable};
|
use crate::dr_physics::math::{Point2D, Rotate};
|
||||||
use crate::data_type::sr1::SaveStatus;
|
use crate::sr1_parse::part_list::RawPartList;
|
||||||
use crate::data_type::sr1::{get_max_box, SR1PartData, SR1PartListTrait};
|
use crate::sr1_parse::ship::RawShip;
|
||||||
use crate::data_type::sr1::{SR1PartList, SR1PartType, SR1Ship};
|
use crate::sr1_parse::SaveStatus;
|
||||||
use crate::data_type::IdType;
|
use crate::sr1_parse::{get_max_box, SR1PartData, SR1PartListTrait};
|
||||||
use crate::sr1_data::part_list::RawPartList;
|
use crate::sr1_parse::{SR1PartList, SR1PartType, SR1Ship};
|
||||||
use crate::sr1_data::ship::RawShip;
|
use crate::IdType;
|
||||||
|
|
||||||
// use serde_xml_rs::to_string;
|
// use serde_xml_rs::to_string;
|
||||||
use quick_xml::se::to_string;
|
use quick_xml::se::to_string;
|
||||||
|
@ -10,7 +10,7 @@ use nalgebra::{Matrix2, Vector2};
|
|||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use rapier2d_f64::math::Real;
|
use rapier2d_f64::math::Real;
|
||||||
|
|
||||||
use crate::data_type::IdType;
|
use crate::IdType;
|
||||||
|
|
||||||
/// Id 位置 碰撞体
|
/// Id 位置 碰撞体
|
||||||
pub type BoundedShape = (IdType, Vector2<Real>, EditorShapeEnum);
|
pub type BoundedShape = (IdType, Vector2<Real>, EditorShapeEnum);
|
||||||
|
@ -1,22 +1,26 @@
|
|||||||
|
mod data_structure;
|
||||||
|
|
||||||
|
pub use self::data_structure::*;
|
||||||
|
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fs;
|
|
||||||
use std::io::Cursor;
|
use std::io::Cursor;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
use super::math::{Edge, Shape};
|
use crate::dr_physics::math::{Edge, Shape};
|
||||||
use crate::sr1_data::part_list::Damage as RawDamage;
|
use crate::sr1_parse::part_list::Damage as RawDamage;
|
||||||
use crate::sr1_data::part_list::{AttachPoint, AttachPoints, Engine, Lander, Rcs, Shape as RawShape, Solar, Tank};
|
use crate::sr1_parse::part_list::{AttachPoint, AttachPoints, Engine, Lander, Rcs, Shape as RawShape, Solar, Tank};
|
||||||
use crate::sr1_data::part_list::{RawPartList, RawPartType, SR1PartTypeEnum};
|
use crate::sr1_parse::part_list::{RawPartList, RawPartType, SR1PartTypeEnum};
|
||||||
use crate::sr1_data::ship::{
|
use crate::sr1_parse::ship::{
|
||||||
Activate as RawActivate, Connection, Connections, DisconnectedPart as RawDisconnectedPart,
|
Activate as RawActivate, Connection, Connections, DisconnectedPart as RawDisconnectedPart,
|
||||||
DisconnectedParts as RawDisconnectedParts, Engine as RawEngine, Part as RawPartData, Parts as RawParts,
|
DisconnectedParts as RawDisconnectedParts, Engine as RawEngine, Part as RawPartData, Parts as RawParts,
|
||||||
Pod as RawPod, RawShip, Staging as RawStaging, Step as RawStep, Tank as RawTank,
|
Pod as RawPod, RawShip, Staging as RawStaging, Step as RawStep, Tank as RawTank,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::data_type::math::{Point2D, Rotatable};
|
use crate::dr_physics::math::{Point2D, Rotate};
|
||||||
use crate::data_type::IdType;
|
use crate::IdType;
|
||||||
|
|
||||||
|
use fs_err as fs;
|
||||||
use quick_xml::events::{BytesEnd, BytesStart, Event};
|
use quick_xml::events::{BytesEnd, BytesStart, Event};
|
||||||
use quick_xml::writer::Writer;
|
use quick_xml::writer::Writer;
|
||||||
|
|
||||||
@ -45,11 +49,11 @@ pub enum SR1PartTypeAttr {
|
|||||||
consumption: f64,
|
consumption: f64,
|
||||||
size: f64,
|
size: f64,
|
||||||
turn: f64,
|
turn: f64,
|
||||||
fuel_type: i32,
|
|
||||||
/// 0 -> 普通燃料
|
/// 0 -> 普通燃料
|
||||||
/// 1 -> Rcs
|
/// 1 -> Rcs
|
||||||
/// 2 -> 电量
|
/// 2 -> 电量
|
||||||
/// 3 -> 固推
|
/// 3 -> 固推
|
||||||
|
fuel_type: i32,
|
||||||
throttle_exponential: bool,
|
throttle_exponential: bool,
|
||||||
},
|
},
|
||||||
Rcs {
|
Rcs {
|
||||||
@ -161,7 +165,6 @@ pub struct SR1PartList {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SR1PartList {
|
impl SR1PartList {
|
||||||
#[inline]
|
|
||||||
pub fn new(name: String, types: Vec<SR1PartType>) -> SR1PartList {
|
pub fn new(name: String, types: Vec<SR1PartType>) -> SR1PartList {
|
||||||
SR1PartList {
|
SR1PartList {
|
||||||
types,
|
types,
|
||||||
@ -170,7 +173,6 @@ impl SR1PartList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn from_file(file_name: String) -> Option<SR1PartList> {
|
pub fn from_file(file_name: String) -> Option<SR1PartList> {
|
||||||
if let Some(raw_list) = RawPartList::from_file(file_name) {
|
if let Some(raw_list) = RawPartList::from_file(file_name) {
|
||||||
let sr_list = raw_list.to_sr_part_list(None);
|
let sr_list = raw_list.to_sr_part_list(None);
|
||||||
@ -191,7 +193,6 @@ impl SR1PartList {
|
|||||||
self.cache.borrow().clone().unwrap()
|
self.cache.borrow().clone().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn get_part_type(&self, type_name: &String) -> Option<SR1PartType> {
|
pub fn get_part_type(&self, type_name: &String) -> Option<SR1PartType> {
|
||||||
let cache = self.get_cache();
|
let cache = self.get_cache();
|
||||||
cache.get(type_name).cloned()
|
cache.get(type_name).cloned()
|
||||||
@ -373,12 +374,10 @@ impl SR1PartTypeData for SR1PartType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SR1PartDataTrait for SR1PartData {
|
impl SR1PartDataTrait for SR1PartData {
|
||||||
#[inline]
|
|
||||||
fn to_sr_part_data(&self) -> SR1PartData {
|
fn to_sr_part_data(&self) -> SR1PartData {
|
||||||
self.clone()
|
self.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn to_raw_part_data(&self) -> RawPartData {
|
fn to_raw_part_data(&self) -> RawPartData {
|
||||||
let (tank, engine) = if let Some(fuel) = &self.attr.fuel {
|
let (tank, engine) = if let Some(fuel) = &self.attr.fuel {
|
||||||
match self.part_type {
|
match self.part_type {
|
||||||
@ -600,7 +599,6 @@ impl SR1PartDataAttr {
|
|||||||
Some(pod.throttle),
|
Some(pod.throttle),
|
||||||
Some(pod.stages.current_stage),
|
Some(pod.stages.current_stage),
|
||||||
Some({
|
Some({
|
||||||
// The mother-fucking nests come out again!
|
|
||||||
let mut steps = Vec::new();
|
let mut steps = Vec::new();
|
||||||
match &pod.stages.steps {
|
match &pod.stages.steps {
|
||||||
Some(step_vec) => {
|
Some(step_vec) => {
|
||||||
@ -697,7 +695,6 @@ impl SR1Ship {
|
|||||||
part.part_type = SR1PartTypeEnum::strut;
|
part.part_type = SR1PartTypeEnum::strut;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Why are you fucking nesting such this fucking loops?!
|
|
||||||
for disconnects in self.disconnected.iter_mut() {
|
for disconnects in self.disconnected.iter_mut() {
|
||||||
for (parts, _) in disconnects.iter_mut() {
|
for (parts, _) in disconnects.iter_mut() {
|
||||||
for part in parts.iter_mut() {
|
for part in parts.iter_mut() {
|
@ -1,10 +1,10 @@
|
|||||||
use crate::data_type::sr1::{SR1PartList, SR1PartType, SR1PartTypeAttr};
|
use crate::sr1_parse::{SR1PartList, SR1PartType, SR1PartTypeAttr};
|
||||||
use crate::data_type::sr1::{SR1PartListTrait, SR1PartTypeData};
|
use crate::sr1_parse::{SR1PartListTrait, SR1PartTypeData};
|
||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
use pyo3::prelude::*;
|
use pyo3::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use quick_xml::de::from_str;
|
use quick_xml::de::from_str;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
pub struct RawPartList {
|
pub struct RawPartList {
|
||||||
@ -138,8 +138,8 @@ pub struct Damage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Damage {
|
impl Damage {
|
||||||
pub fn take_damage(&self) -> crate::data_type::sr1::Damage {
|
pub fn take_damage(&self) -> crate::sr1_parse::Damage {
|
||||||
crate::data_type::sr1::Damage {
|
crate::sr1_parse::Damage {
|
||||||
disconnect: self.disconnect,
|
disconnect: self.disconnect,
|
||||||
explode: self.explode,
|
explode: self.explode,
|
||||||
explosion_power: self.explosion_power.unwrap_or(100_f64),
|
explosion_power: self.explosion_power.unwrap_or(100_f64),
|
@ -6,9 +6,9 @@ use quick_xml::se::to_string;
|
|||||||
// use quick_xml::Error as XmlError;
|
// use quick_xml::Error as XmlError;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::data_type::sr1::{SR1PartData, SR1PartDataAttr, SR1Ship};
|
use crate::sr1_parse::{SR1PartData, SR1PartDataAttr, SR1Ship};
|
||||||
use crate::data_type::sr1::{SR1PartDataTrait, SR1ShipTrait};
|
use crate::sr1_parse::{SR1PartDataTrait, SR1ShipTrait};
|
||||||
use crate::data_type::IdType;
|
use crate::IdType;
|
||||||
|
|
||||||
/// https://docs.rs/quick-xml/latest/quick_xml/de/index.html#basics
|
/// https://docs.rs/quick-xml/latest/quick_xml/de/index.html#basics
|
||||||
/// using quick xml
|
/// using quick xml
|
@ -2,14 +2,14 @@ use std::io;
|
|||||||
|
|
||||||
use fs_err as fs;
|
use fs_err as fs;
|
||||||
|
|
||||||
// Input the directory of the xml file.
|
// 输入XML文件的路径。
|
||||||
// If file does not exsit or not the XML file, return errors or return file handle.
|
// 若文件不存在或非XML文件,则返回错误,否则返回文件句柄。
|
||||||
// I think this fuction can be improved as its implementations are not as good as what I expected.
|
// 我认为该函数仍可改进,因为它的实现并未达到我所预期的那样。
|
||||||
pub fn read_xml(dir: &str) -> io::Result<fs::File> {
|
pub fn read_xml(path: &str) -> io::Result<fs::File> {
|
||||||
if dir.split_inclusive('.').collect::<Vec<&str>>()[1] != "xml" {
|
if path.split_inclusive('.').collect::<Vec<&str>>()[1] != "xml" {
|
||||||
Err(io::Error::new(io::ErrorKind::Other, "This file is not an XML file!"))
|
Err(io::Error::new(io::ErrorKind::Other, "This file is not an XML file!"))
|
||||||
} else {
|
} else {
|
||||||
fs::File::open(dir)
|
fs::File::open(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user