我这都跳了好几次步进版本号push了 DR_rs 0.2.5.0
This commit is contained in:
parent
024e924438
commit
0a95312c12
@ -24,7 +24,7 @@ from libs.MCDR.version import Version
|
||||
|
||||
game_version = Version("0.7.0.3") # 游戏版本
|
||||
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
||||
DR_rust_version = Version("0.2.3.0") # DR 的 Rust 编写部分的版本
|
||||
DR_rust_version = Version("0.2.5.0") # DR 的 Rust 编写部分的版本
|
||||
__version__ = game_version
|
||||
|
||||
long_version: int = 12
|
||||
@ -78,7 +78,8 @@ class _DR_option(Options):
|
||||
if sys.platform != 'darwin': # MacOS 的测试只能在 Macos 上跑
|
||||
self.pyglet_macosx_dev_test = False
|
||||
try:
|
||||
from libs.Difficult_Rocket_rs import test_call, get_version_str
|
||||
from libs.Difficult_Rocket_rs import test_call, get_version_str, part_list_read_test
|
||||
part_list_read_test("./configs/PartList.xml")
|
||||
test_call(self)
|
||||
print(f'DR_rust available: {get_version_str()}')
|
||||
except ImportError:
|
||||
|
@ -1,4 +1,4 @@
|
||||
<PartTypes xmlns="http://jundroo.com/simplerockets/partlist.xsd">
|
||||
<PartTypes xmlns="http://jundroo.com/simplerockets/partlist.xsd">
|
||||
<PartType id="pod-1" name="Command Pod Mk1" description="This is your ship's brain. Be careful with it." sprite="Pod.png" type="pod" mass="1.0" width="4" height="3" hidden="true">
|
||||
<Damage disconnect="1500" explode="1500" explosionPower="5" explosionSize="10" />
|
||||
<Shape>
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
from .lib import *
|
||||
|
||||
from typing import TYPE_CHECKING, Dict, Tuple
|
||||
from typing import TYPE_CHECKING, Dict, Tuple, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from Difficult_Rocket.client.screen import BaseScreen
|
||||
@ -22,6 +22,8 @@ if TYPE_CHECKING:
|
||||
def simluation() -> None: ...
|
||||
""" 用来测试 rust 的物理模拟能不能用 """
|
||||
|
||||
def part_list_read_test(file_name: Optional[str] = "./configs/PartList.xml") -> None: ...
|
||||
|
||||
class PartDatas:
|
||||
""" 用于在 PyObj 里塞一个浓眉大眼的 HashMap<uszie, SR1PartData>"""
|
||||
def __new__(cls, py_part_data: Dict[int, SR1PartData]) -> "PartDatas": ...
|
||||
|
2
libs/Difficult_Rocket_rs/src/Cargo.lock
generated
2
libs/Difficult_Rocket_rs/src/Cargo.lock
generated
@ -116,7 +116,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "difficult_rocket_rs"
|
||||
version = "0.2.2"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"pyo3",
|
||||
"rapier2d-f64",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "difficult_rocket_rs"
|
||||
version = "0.2.2"
|
||||
version = "0.2.5"
|
||||
edition = "2021"
|
||||
license-file = '../../LICENSE'
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
@ -14,8 +14,8 @@ crate-type = ["cdylib"]
|
||||
[profile.dev.package.rapier2d-f64]
|
||||
opt-level = 3
|
||||
|
||||
[profile.release]
|
||||
codegen-units = 1
|
||||
#[profile.release]
|
||||
#codegen-units = 1
|
||||
|
||||
#[dependencies.quick-xml]
|
||||
#version = "0.27.1"
|
||||
|
@ -16,7 +16,7 @@ use pyo3::prelude::*;
|
||||
|
||||
#[pyfunction]
|
||||
fn get_version_str() -> String {
|
||||
return String::from("0.2.2.0");
|
||||
return String::from("0.2.5.0");
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
@ -35,6 +35,7 @@ fn module_init(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(test_call, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(sr1_render::better_update_parts, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(simulator::simluation, m)?)?;
|
||||
m.add_function(wrap_pyfunction!(sr1_data::part_list::read_part_list_py, m)?)?;
|
||||
m.add_class::<sr1_render::types::PartDatas>()?;
|
||||
m.add_class::<render::camera::CameraRs>()?;
|
||||
m.add_class::<render::screen::PartFrame>()?;
|
||||
|
@ -7,24 +7,26 @@
|
||||
*/
|
||||
|
||||
pub mod part_list {
|
||||
use std::fs;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
use serde::{Serialize, Deserialize};
|
||||
use serde_xml_rs::{to_string, from_reader};
|
||||
use serde_xml_rs::{from_str};
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PartList {
|
||||
#[serde(rename = "PartType")]
|
||||
part_types: Vec<PartType>
|
||||
}
|
||||
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(Serialize, Deserialize, Copy, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub enum PartTypes {
|
||||
pod,
|
||||
detacher,
|
||||
wheel,
|
||||
fuselage,
|
||||
r#struct,
|
||||
strut,
|
||||
tank,
|
||||
engine,
|
||||
parachute,
|
||||
@ -36,36 +38,62 @@ pub mod part_list {
|
||||
lander
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Copy, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
pub enum Category {
|
||||
Satellite
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct PartType {
|
||||
id: String,
|
||||
name: String,
|
||||
description: String,
|
||||
sprite: String,
|
||||
r#type: PartTypes,
|
||||
mass: f64,
|
||||
width: u32,
|
||||
height: u32,
|
||||
friction: Option<f64>,
|
||||
category: Option<Category>,
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub sprite: String,
|
||||
pub r#type: PartTypes,
|
||||
pub mass: f64,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub friction: Option<f64>,
|
||||
pub category: Option<Category>,
|
||||
#[serde(rename = "ignoreEditorIntersections")]
|
||||
ignore_editor_intersections: Option<bool>,
|
||||
pub ignore_editor_intersections: Option<bool>,
|
||||
#[serde(rename = "disableEditorRotation")]
|
||||
disable_editor_rotation: Option<bool>,
|
||||
pub disable_editor_rotation: Option<bool>,
|
||||
#[serde(rename = "canExplode")]
|
||||
can_explode: Option<bool>,
|
||||
pub can_explode: Option<bool>,
|
||||
#[serde(rename = "coverHeight")]
|
||||
cover_height: Option<u32>,
|
||||
pub cover_height: Option<u32>,
|
||||
#[serde(rename = "sandboxOnly")]
|
||||
sandbox_only: Option<bool>,
|
||||
drag: Option<f64>,
|
||||
hidden: Option<bool>,
|
||||
buoyancy: Option<f64>
|
||||
pub sandbox_only: Option<bool>,
|
||||
pub drag: Option<f64>,
|
||||
pub hidden: Option<bool>,
|
||||
pub buoyancy: Option<f64>
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn read_part_list(file_name: String) -> Option<PartList> {
|
||||
let part_list_file = fs::read_to_string(file_name.to_string());
|
||||
match part_list_file {
|
||||
Ok(part_list_file) => {
|
||||
let part_list: PartList = from_str(part_list_file.as_str()).unwrap();
|
||||
Some(part_list)
|
||||
},
|
||||
Err(_) => {
|
||||
println!("Error while reading File {}", file_name);
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[pyfunction]
|
||||
#[pyo3(name = "part_list_read_test", signature = (file_name = "./configs/PartList.xml".to_string()))]
|
||||
pub fn read_part_list_py(file_name: Option<String>) -> PyResult<()> {
|
||||
let file_name = file_name.unwrap_or("./configs/PartList.xml".to_string());
|
||||
let parts = read_part_list(file_name);
|
||||
if let Some(parts) = parts {
|
||||
println!("{:?}", parts);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user