update DR_rs and post_build script

This commit is contained in:
shenjack 2023-05-14 01:40:34 +08:00
parent 08e2ae9ae2
commit 77e02fa3ca
5 changed files with 324 additions and 220 deletions

View File

@ -7,9 +7,10 @@ import os
import shutil
import warnings
import traceback
from pathlib import Path
package_path = 'Difficult_Rocket_rs'
lib_path = '../lib'
lib_path = Path('../lib').resolve()
build_path = 'build'
if not os.path.exists(lib_path):
@ -28,7 +29,6 @@ for build_dir in builds:
warnings.warn(f'package not found at {build_path}/{build_dir}')
continue
for file in os.listdir(os.path.join(build_path, build_dir, package_path)):
# file_name = os.path.join(lib_path, file.replace(package_path, f'{package_path}.{DR_runtime.DR_Rust_version}'))
file_name = os.path.join(lib_path, file)
shutil.rmtree(file_name, ignore_errors=True)
try:

View File

@ -39,7 +39,7 @@ pub mod data {
#[pyo3(name = "SR1PartList_rs")]
#[pyo3(text_signature = "(file_path = './configs/PartList.xml', list_name = 'NewPartList')")]
pub struct PySR1PartList {
pub part_list: SR1PartList,
pub data: SR1PartList,
}
#[pymethods]
@ -47,16 +47,16 @@ pub mod data {
#[new]
fn new(file_path: String, list_name: String) -> Self {
let raw_part_list: RawPartList = RawPartList::from_file(file_path).unwrap();
let part_list = raw_part_list.to_sr_part_list(Some(list_name));
Self { part_list }
let data = raw_part_list.to_sr_part_list(Some(list_name));
Self { data }
}
fn as_dict(&self) -> HashMap<String, PySR1PartType> {
self.part_list.cache.iter().map(|(k, v)| (k.clone(), PySR1PartType::new(v.clone()))).collect()
self.data.get_cache().iter().map(|(k, v)| (k.clone(), PySR1PartType::new(v.clone()))).collect()
}
fn get_part_type(&mut self, name: String) -> Option<PySR1PartType> {
let part_type = self.part_list.cache.get(&name);
fn get_part_type(&self, name: String) -> Option<PySR1PartType> {
let part_type = self.data.get_part_type(name.clone());
if let Some(part_type) = part_type {
Some(PySR1PartType::new(part_type.clone()))
} else {
@ -94,7 +94,7 @@ pub mod data {
// 左下角,右上角
let mut max_box = get_max_box(&self.ship.parts, &self.part_list);
todo!();
img_pos
// img_pos
}
fn get_name(&self) -> String { self.ship.name.clone() }
@ -111,12 +111,6 @@ pub mod translate {
use pyo3::prelude::*;
use pyo3::types::PyDict;
#[derive(Clone)]
pub enum BoolString {
Bool(bool),
String(String),
}
#[pyclass]
#[pyo3(name = "TranslateConfig_rs")]
#[pyo3(text_signature = "(language, raise_error = False, replace_normal = False, add_error = False, is_result = False, keep_get = False)")]

View File

@ -124,7 +124,7 @@ pub mod part_list {
#[inline]
pub fn to_damage(&self) -> crate::types::sr1::Damage {
crate::types::sr1::Damage {
disconnect: self.disconnect,
disconnect: self.disconnect.to_owned(),
explode: self.explode.to_owned(),
explosion_power: self.explosion_power.unwrap_or(100),
explosion_size: self.explosion_size.unwrap_or(100),
@ -299,9 +299,9 @@ pub mod part_list {
description: self.description.clone(),
sprite: self.sprite.clone(),
p_type: self.r#type,
mass: self.mass,
width: self.width,
height: self.height,
mass: self.mass.to_owned(),
width: self.width.to_owned(),
height: self.height.to_owned(),
friction: self.friction.unwrap_or(0.0),
category: self.category.clone().unwrap_or("".to_string()),
ignore_editor_intersections: self.ignore_editor_intersections.unwrap_or(false),
@ -419,9 +419,8 @@ pub mod ship {
pub engine: Option<Engine>,
#[serde(rename = "Pod")]
pub pod: Option<Pod>,
#[serde(rename = "partType")]
pub part_type: SR1PartTypeEnum,
pub part_type_id: String,
pub id: i64,
pub x: f64,
pub y: f64,
@ -519,58 +518,28 @@ pub mod ship {
pub child_part: i64,
}
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 = match self.part_type {
SR1PartTypeEnum::tank => SR1PartDataAttr::Tank {
fuel: if let Some(tank) = &self.tank { tank.fuel } else { 0_f64 },
},
SR1PartTypeEnum::engine => SR1PartDataAttr::Engine {
fuel: if let Some(engine) = &self.engine { engine.fuel } else { 0_f64 },
},
SR1PartTypeEnum::solar => SR1PartDataAttr::Solar {
extension: self.extension.unwrap_or(0_f64),
},
SR1PartTypeEnum::parachute => SR1PartDataAttr::Parachute {
chute_x: self.chute_x.unwrap_or(0_f64),
chute_y: self.chute_y.unwrap_or(0_f64),
chute_angle: self.chute_angle.unwrap_or(0_f64),
chute_height: self.chute_height.unwrap_or(0_f64),
inflate: i8_to_bool(self.inflate.unwrap_or(0_i8)),
inflation: i8_to_bool(self.inflation.unwrap_or(0_i8)),
deployed: i8_to_bool(self.deployed.unwrap_or(0_i8)),
rope: i8_to_bool(self.rope.unwrap_or(0_i8)),
},
SR1PartTypeEnum::pod => {
let pod = self.pod.as_ref().unwrap(); // 一定是有的,别问我为什么
let mut steps = Vec::new();
for step in &pod.stages.steps {
let mut activates = Vec::new();
for active in &step.activates {
activates.push((active.id, i8_to_bool(active.moved)))
}
steps.push(activates)
}
SR1PartDataAttr::Pod {
name: pod.name.clone(),
throttle: pod.throttle,
current_stage: pod.stages.current_stage,
steps,
}
}
_ => SR1PartDataAttr::None,
};
let attr = SR1PartDataAttr::from_raw(&self, None, true);
let part_type = attr.get_part_type();
SR1PartData {
attr,
x: self.x,
y: self.y,
id: self.id,
angle: self.angle,
angle_v: self.angle_v,
x: self.x.to_owned(),
y: self.y.to_owned(),
id: self.id.to_owned(),
angle: self.angle.to_owned(),
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,
part_type: self.part_type,
editor_angle: self.editor_angle.to_owned(),
part_type,
part_type_id: self.part_type_id.clone(),
active: i8_to_bool(self.activated.unwrap_or(0_i8)),
explode: i8_to_bool(self.exploded.unwrap_or(0_i8)),
}
@ -588,8 +557,6 @@ pub mod ship {
}
let disconnected = match &self.disconnected {
Some(disconnect) => {
// let mut disconnect_parts = Vec::new();
let mut disconnect_parts = Vec::new();
for disconnected_part in &disconnect.parts {
let mut parts_vec = Vec::new();
@ -611,8 +578,8 @@ pub mod ship {
description: "".to_string(),
parts,
connections,
lift_off: i8_to_bool(self.lift_off),
touch_ground: i8_to_bool(self.touch_ground),
lift_off: i8_to_bool(self.lift_off.to_owned()),
touch_ground: i8_to_bool(self.touch_ground.to_owned()),
disconnected,
}
}

View File

@ -7,8 +7,8 @@
*/
pub mod sr1 {
use std::cell::{Cell, RefCell};
use std::collections::HashMap;
use std::fs;
use super::math::{Edge, Shape};
use crate::sr1_data::part_list::Damage as RawDamage;
@ -70,6 +70,22 @@ pub mod sr1 {
}
}
#[inline]
pub fn option_i8_to_option_bool(i: Option<i8>) -> Option<bool> {
match i {
Some(i) => Some(i8_to_bool(i)),
None => None,
}
}
#[inline]
pub fn option_bool_to_option_i8(b: Option<bool>) -> Option<i8> {
match b {
Some(b) => Some(bool_to_i8(b)),
None => None,
}
}
#[derive(Debug, Copy, Clone)]
pub enum SR1PartTypeAttr {
Tank {
@ -122,10 +138,10 @@ pub mod sr1 {
impl Damage {
pub fn to_raw_damage(&self) -> RawDamage {
RawDamage {
disconnect: self.disconnect,
explode: self.explode,
explosion_power: Some(self.explosion_power),
explosion_size: Some(self.explosion_size),
disconnect: self.disconnect.to_owned(),
explode: self.explode.to_owned(),
explosion_power: Some(self.explosion_power.to_owned()),
explosion_size: Some(self.explosion_size.to_owned()),
}
}
}
@ -181,38 +197,49 @@ pub mod sr1 {
#[derive(Debug, Clone)]
pub struct SR1PartList {
pub types: Vec<SR1PartType>,
pub cache: HashMap<String, SR1PartType>,
pub cache: RefCell<Option<HashMap<String, SR1PartType>>>,
pub name: String,
}
impl SR1PartList {
#[inline]
pub fn new(name: String, types: Vec<SR1PartType>) -> SR1PartList {
let mut map = HashMap::new();
for part in types.iter() {
map.insert(part.id.clone(), part.clone());
SR1PartList {
types,
cache: RefCell::new(None),
name,
}
SR1PartList { types, cache: map, name }
}
#[inline]
pub fn from_file(file_name: String) -> Option<SR1PartList> {
if let Some(raw_list) = RawPartList::from_file(file_name) {
let sr_list = raw_list.to_sr_part_list(None);
let mut map = HashMap::new();
for part in sr_list.types.iter() {
map.insert(part.id.clone(), part.clone());
}
return Some(sr_list);
}
None
}
#[inline]
pub fn get_part_type(self, type_name: String) -> Option<SR1PartType> {
if let Some(part) = self.cache.get(&type_name) {
return Some(part.clone());
pub fn get_cache(&self) -> HashMap<String, SR1PartType> {
let mut cache = self.cache.borrow_mut();
if cache.is_none() {
let mut map = HashMap::new();
for part in self.types.iter() {
map.insert(part.id.to_owned(), part.to_owned());
}
*cache = Some(map);
self.cache.replace(cache.to_owned());
}
cache.to_owned().unwrap()
}
#[inline]
pub fn get_part_type(&self, type_name: String) -> Option<SR1PartType> {
let cache = self.get_cache();
match cache.get(&type_name) {
Some(part) => Some(part.to_owned()),
None => None,
}
None
}
pub fn part_types_new(part_types: Vec<SR1PartType>, name: Option<String>) -> Self {
@ -269,9 +296,9 @@ pub mod sr1 {
let tank: Option<Tank> = match &self.attr {
Some(attr) => match attr {
SR1PartTypeAttr::Tank { fuel, dry_mass, fuel_type } => Some(Tank {
fuel: *fuel,
dry_mass: *dry_mass,
fuel_type: Some(*fuel_type),
fuel: fuel.to_owned(),
dry_mass: dry_mass.to_owned(),
fuel_type: Some(fuel_type.to_owned()),
}),
_ => None,
},
@ -287,12 +314,12 @@ pub mod sr1 {
fuel_type,
throttle_exponential,
} => Some(Engine {
power: *power,
consumption: *consumption,
throttle_exponential: Some(*throttle_exponential),
size: *size,
turn: *turn,
fuel_type: Some(*fuel_type),
power: power.to_owned(),
consumption: consumption.to_owned(),
throttle_exponential: Some(throttle_exponential.to_owned()),
size: size.to_owned(),
turn: turn.to_owned(),
fuel_type: Some(fuel_type.to_owned()),
}),
_ => None,
},
@ -301,9 +328,9 @@ pub mod sr1 {
let rcs: Option<Rcs> = match &self.attr {
Some(attr) => match attr {
SR1PartTypeAttr::Rcs { power, consumption, size } => Some(Rcs {
power: *power,
consumption: *consumption,
size: *size,
power: power.to_owned(),
consumption: consumption.to_owned(),
size: size.to_owned(),
}),
_ => None,
},
@ -311,7 +338,9 @@ pub mod sr1 {
};
let solar: Option<Solar> = match &self.attr {
Some(attr) => match attr {
SR1PartTypeAttr::Solar { charge_rate } => Some(Solar { charge_rate: *charge_rate }),
SR1PartTypeAttr::Solar { charge_rate } => Some(Solar {
charge_rate: charge_rate.to_owned(),
}),
_ => None,
},
_ => None,
@ -326,12 +355,12 @@ pub mod sr1 {
length_speed,
width,
} => Some(Lander {
max_angle: *max_angle,
min_length: *min_length,
max_length: *max_length,
angle_speed: Some(*angle_speed),
length_speed: Some(*length_speed),
width: *width,
max_angle: max_angle.to_owned(),
min_length: min_length.to_owned(),
max_length: max_length.to_owned(),
angle_speed: Some(angle_speed.to_owned()),
length_speed: Some(length_speed.to_owned()),
width: width.to_owned(),
}),
_ => None,
},
@ -353,19 +382,19 @@ pub mod sr1 {
description: self.description.clone(),
sprite: self.sprite.clone(),
r#type: self.p_type.clone(),
mass: self.mass,
width: self.width,
height: self.height,
friction: Some(self.friction),
mass: self.mass.to_owned(),
width: self.width.to_owned(),
height: self.height.to_owned(),
friction: Some(self.friction.to_owned()),
category: Some(self.category.clone()),
ignore_editor_intersections: Some(self.ignore_editor_intersections),
disable_editor_rotation: Some(self.disable_editor_rotation),
can_explode: Some(self.can_explode),
cover_height: Some(self.cover_height),
sandbox_only: Some(self.sandbox_only),
drag: Some(self.drag),
hidden: Some(self.hidden),
buoyancy: Some(self.buoyancy),
ignore_editor_intersections: Some(self.ignore_editor_intersections.to_owned()),
disable_editor_rotation: Some(self.disable_editor_rotation.to_owned()),
can_explode: Some(self.can_explode.to_owned()),
cover_height: Some(self.cover_height.to_owned()),
sandbox_only: Some(self.sandbox_only.to_owned()),
drag: Some(self.drag.to_owned()),
hidden: Some(self.hidden.to_owned()),
buoyancy: Some(self.buoyancy.to_owned()),
damage: Some(self.damage.to_raw_damage()),
tank,
engine,
@ -384,94 +413,94 @@ pub mod sr1 {
#[inline]
fn to_raw_part_data(&self) -> RawPartData {
let tank = match &self.attr {
SR1PartDataAttr::Tank { fuel } => Some(RawTank { fuel: *fuel }),
_ => None,
let (tank, engine) = if let Some(fuel) = &self.attr.fuel {
match self.part_type {
SR1PartTypeEnum::tank => (Some(RawTank { fuel: fuel.to_owned() }), None),
SR1PartTypeEnum::engine => (None, Some(RawEngine { fuel: fuel.to_owned() })),
_ => (None, None),
}
} else {
(None, None)
};
let engine = match &self.attr {
SR1PartDataAttr::Engine { fuel } => Some(RawEngine { fuel: *fuel }),
_ => None,
};
let pod = match &self.attr {
SR1PartDataAttr::Pod {
name,
throttle,
current_stage,
steps,
} => Some({
// let pod = match &self.attr {
// SR1PartDataAttr::Pod {
// name,
// throttle,
// current_stage,
// steps,
// } => Some({
// let mut actives = Vec::new();
// for step in steps {
// let mut steps_ = Vec::new();
// for active in step {
// steps_.push(RawActivate {
// id: active.0,
// moved: bool_to_i8(active.1),
// });
// }
// actives.push(RawStep { activates: steps_ });
// }
// let stages = RawStaging {
// current_stage: *current_stage,
// steps: actives,
// };
// RawPod {
// name: name.clone(),
// throttle: *throttle,
// stages,
// }
// }),
// _ => None,
// };
let pod = match (&self.attr.name, &self.attr.throttle, &self.attr.current_stage, &self.attr.steps) {
(Some(name), Some(throttle), Some(current_stage), Some(steps)) => Some({
let mut actives = Vec::new();
for step in steps {
let mut steps_ = Vec::new();
for active in step {
steps_.push(RawActivate {
id: active.0,
moved: bool_to_i8(active.1),
id: active.0.to_owned(),
moved: bool_to_i8(active.1.to_owned()),
});
}
actives.push(RawStep { activates: steps_ });
}
let stages = RawStaging {
current_stage: *current_stage,
current_stage: current_stage.to_owned(),
steps: actives,
};
RawPod {
name: name.clone(),
throttle: *throttle,
throttle: throttle.to_owned(),
stages,
}
}),
_ => None,
};
let (chute_x, chute_y, chute_angle, chute_height, inflate, inflation, deployed, rope) = match &self.attr {
SR1PartDataAttr::Parachute {
chute_x,
chute_y,
chute_angle,
chute_height,
inflate,
inflation,
deployed,
rope,
} => (
Some(*chute_x),
Some(*chute_y),
Some(*chute_angle),
Some(*chute_height),
Some(bool_to_i8(*inflate)),
Some(bool_to_i8(*inflation)),
Some(bool_to_i8(*deployed)),
Some(bool_to_i8(*rope)),
),
_ => (None, None, None, None, None, None, None, None),
};
let extension = match &self.attr {
SR1PartDataAttr::Solar { extension } => Some(*extension),
_ => None,
};
RawPartData {
tank,
engine,
pod,
part_type: self.part_type,
id: self.id,
x: self.x,
y: self.y,
editor_angle: self.editor_angle,
angle: self.angle,
angle_v: self.angle_v,
flip_x: Some(bool_to_i8(self.flip_x)),
flip_y: Some(bool_to_i8(self.flip_y)),
chute_x,
chute_y,
chute_height,
extension,
inflate,
inflation,
exploded: Some(bool_to_i8(self.explode)),
rope,
chute_angle,
activated: Some(bool_to_i8(self.active)),
deployed,
part_type_id: self.part_type_id.clone(),
id: self.id.to_owned(),
x: self.x.to_owned(),
y: self.y.to_owned(),
editor_angle: self.editor_angle.to_owned(),
angle: self.angle.to_owned(),
angle_v: self.angle_v.to_owned(),
flip_x: Some(bool_to_i8(self.flip_x.to_owned())),
flip_y: Some(bool_to_i8(self.flip_y.to_owned())),
chute_x: self.attr.chute_x.to_owned(),
chute_y: self.attr.chute_y.to_owned(),
chute_height: self.attr.chute_height.to_owned(),
extension: self.attr.extension.to_owned(),
inflate: option_bool_to_option_i8(self.attr.inflate.to_owned()),
inflation: option_bool_to_option_i8(self.attr.inflation.to_owned()),
exploded: Some(bool_to_i8(self.explode.to_owned())),
rope: option_bool_to_option_i8(self.attr.rope.to_owned()),
chute_angle: self.attr.chute_angle.to_owned(),
activated: Some(bool_to_i8(self.active.to_owned())),
deployed: option_bool_to_option_i8(self.attr.deployed.to_owned()),
}
}
}
@ -488,6 +517,7 @@ pub mod sr1 {
pub angle_v: f64,
// 状态属性
pub part_type: SR1PartTypeEnum,
pub part_type_id: String,
pub editor_angle: i32,
pub flip_x: bool,
pub flip_y: bool,
@ -498,11 +528,11 @@ pub mod sr1 {
impl SR1PartData {
pub fn get_box(&self, part_type: &SR1PartType) -> (f64, f64, f64, f64) {
let width = part_type.width;
let height = part_type.height;
let radius = self.angle;
let width = part_type.width.to_owned();
let height = part_type.height.to_owned();
let radius = self.angle.to_owned();
let mut shape = Shape::new_width_height(width as f64, height as f64, Some(radius));
shape.move_xy(Some(self.x), Some(self.y));
shape.move_xy(Some(self.x.to_owned()), Some(self.y.to_owned()));
let mut pos_box = (0_f64, 0_f64, 0_f64, 0_f64);
match shape.bounds[0] {
Edge::OneTimeLine(line) => {
@ -523,33 +553,145 @@ pub mod sr1 {
}
#[derive(Debug, Clone)]
pub enum SR1PartDataAttr {
Tank {
fuel: f64,
},
Engine {
fuel: f64,
},
Pod {
name: String,
throttle: f64,
current_stage: u32,
steps: Vec<Vec<(i64, bool)>>,
},
Solar {
extension: f64,
},
Parachute {
chute_x: f64,
chute_y: f64,
chute_angle: f64,
chute_height: f64,
inflate: bool,
inflation: bool,
deployed: bool,
rope: bool,
},
None,
pub struct SR1PartDataAttr {
// Tank | Engine
pub fuel: Option<f64>,
// Pod
pub name: Option<String>,
pub throttle: Option<f64>,
pub current_stage: Option<u32>,
pub steps: Option<Vec<Vec<(i64, bool)>>>,
// Solar
pub extension: Option<f64>,
// Parachute
pub chute_x: Option<f64>,
pub chute_y: Option<f64>,
pub chute_height: Option<f64>,
pub chute_angle: Option<f64>,
pub inflate: Option<bool>,
pub inflation: Option<bool>,
pub deployed: Option<bool>,
pub rope: Option<bool>,
// part_type
pub part_type: Cell<Option<SR1PartTypeEnum>>,
}
impl SR1PartDataAttr {
pub fn guess_type(&self) -> SR1PartTypeEnum {
if let Some(part_type) = self.part_type.get() {
return part_type;
}
if self.fuel.is_some() {
self.part_type.set(Some(SR1PartTypeEnum::tank));
return self.part_type.get().unwrap();
}
if self.name.is_some() {
self.part_type.set(Some(SR1PartTypeEnum::pod));
return self.part_type.get().unwrap();
}
if self.extension.is_some() {
self.part_type.set(Some(SR1PartTypeEnum::solar));
return self.part_type.get().unwrap();
}
if self.chute_x.is_some() {
self.part_type.set(Some(SR1PartTypeEnum::parachute));
return self.part_type.get().unwrap();
}
SR1PartTypeEnum::strut // 默认为 Strut 开摆
}
pub fn get_part_type(&self) -> SR1PartTypeEnum {
if let Some(part_type) = self.part_type.get() {
return part_type;
}
self.guess_type()
}
pub fn new(
fuel: Option<f64>,
name: Option<String>,
throttle: Option<f64>,
current_stage: Option<u32>,
steps: Option<Vec<Vec<(i64, bool)>>>,
extension: Option<f64>,
chute_x: Option<f64>,
chute_y: Option<f64>,
chute_height: Option<f64>,
chute_angle: Option<f64>,
inflate: Option<bool>,
inflation: Option<bool>,
deployed: Option<bool>,
rope: Option<bool>,
part_type: Option<SR1PartTypeEnum>,
) -> Self {
SR1PartDataAttr {
fuel,
name,
throttle,
current_stage,
steps,
extension,
chute_x,
chute_y,
chute_height,
chute_angle,
inflate,
inflation,
deployed,
rope,
part_type: Cell::new(part_type),
}
}
pub fn from_raw(raw_data: &RawPartData, part_type: Option<SR1PartTypeEnum>, guess: bool) -> Self {
let fuel = if let Some(tank) = &raw_data.tank {
Some(tank.fuel.to_owned())
} else if let Some(engine) = &raw_data.engine {
Some(engine.fuel.to_owned())
} else {
None
};
let (name, throttle, current_stage, steps) = if let Some(pod) = &raw_data.pod {
(
Some(pod.name.to_owned()),
Some(pod.throttle.to_owned()),
Some(pod.stages.current_stage.to_owned()),
Some({
let mut steps = Vec::new();
for step in &pod.stages.steps {
let mut step_vec = Vec::new();
for act in &step.activates {
step_vec.push((act.id.to_owned(), i8_to_bool(act.moved.to_owned())));
}
steps.push(step_vec);
}
steps
}),
)
} else {
(None, None, None, None)
};
let results = SR1PartDataAttr {
fuel,
name,
throttle,
current_stage,
steps,
extension: raw_data.extension.to_owned(),
chute_x: raw_data.chute_x.to_owned(),
chute_y: raw_data.chute_y.to_owned(),
chute_height: raw_data.chute_height.to_owned(),
chute_angle: raw_data.chute_angle.to_owned(),
inflate: option_i8_to_option_bool(raw_data.inflate.to_owned()),
inflation: option_i8_to_option_bool(raw_data.inflation.to_owned()),
deployed: option_i8_to_option_bool(raw_data.deployed.to_owned()),
rope: option_i8_to_option_bool(raw_data.rope.to_owned()),
part_type: Cell::new(part_type),
};
if guess & results.part_type.get().is_none() {
results.guess_type();
}
results
}
}
#[derive(Debug, Clone)]
@ -619,8 +761,8 @@ pub mod sr1 {
parts: RawParts { parts },
connects: connections,
version: 1,
lift_off: bool_to_i8(self.lift_off),
touch_ground: bool_to_i8(self.touch_ground),
lift_off: bool_to_i8(self.lift_off.to_owned()),
touch_ground: bool_to_i8(self.touch_ground.to_owned()),
disconnected,
}
}
@ -658,8 +800,8 @@ pub mod math {
#[inline]
pub fn distance(&self, other: &Point2D) -> f64 {
let dx = (other.x - self.x).powf(2.0);
let dy = (other.y - self.y).powf(2.0);
let dx = (other.x.to_owned() - self.x.to_owned()).powf(2.0);
let dy = (other.y.to_owned() - self.y.to_owned()).powf(2.0);
(dx + dy).powf(0.5)
}

View File

@ -20,6 +20,7 @@ DR_rust_version = Version("0.2.7.0") # DR_mod 的 Rust 编写部分的兼容版
class _DR_mod_runtime(Options):
name = 'DR mod runtime'
use_DR_rust: bool = True
DR_rust_available: bool = False