DR rs 0.3.2
This commit is contained in:
parent
aeeb5e46c2
commit
ea76747998
@ -11,7 +11,6 @@ use crate::sr1_parse::{get_max_box, SR1PartData, SR1PartListTrait};
|
||||
use crate::sr1_parse::{SR1PartList, SR1PartType, SR1Ship};
|
||||
use crate::IdType;
|
||||
|
||||
// use serde_xml_rs::to_string;
|
||||
use quick_xml::se::to_string;
|
||||
|
||||
#[pyclass]
|
||||
|
@ -6,7 +6,7 @@ use crate::dr_physics::math::{Edge, Shape};
|
||||
use crate::dr_physics::math::{Point2D, Rotate};
|
||||
use crate::sr1_parse::part_list::Damage as RawDamage;
|
||||
use crate::sr1_parse::part_list::{AttachPoint, AttachPoints, Engine, Lander, Rcs, Shape as RawShape, Solar, Tank};
|
||||
use crate::sr1_parse::part_list::{RawPartList, RawPartType, SR1PartTypeEnum};
|
||||
use crate::sr1_parse::part_list::{RawPartList, RawPartType, SR1PartTypeEnum, FuelType};
|
||||
use crate::sr1_parse::ship::{
|
||||
Activate as RawActivate, Connection, Connections, DisconnectedPart as RawDisconnectedPart,
|
||||
DisconnectedParts as RawDisconnectedParts, Engine as RawEngine, Part as RawPartData, Parts as RawParts,
|
||||
@ -41,7 +41,7 @@ pub enum SR1PartTypeAttr {
|
||||
Tank {
|
||||
fuel: f64,
|
||||
dry_mass: f64,
|
||||
fuel_type: i32,
|
||||
fuel_type: FuelType,
|
||||
},
|
||||
Engine {
|
||||
power: f64,
|
||||
@ -53,7 +53,7 @@ pub enum SR1PartTypeAttr {
|
||||
/// 1 -> Rcs
|
||||
/// 2 -> 电量
|
||||
/// 3 -> 固推
|
||||
fuel_type: i32,
|
||||
fuel_type: FuelType,
|
||||
throttle_exponential: bool,
|
||||
},
|
||||
Rcs {
|
||||
@ -219,11 +219,13 @@ pub trait SR1PartDataTrait {
|
||||
|
||||
pub trait SR1PartListTrait {
|
||||
fn to_sr_part_list(&self, name: Option<String>) -> SR1PartList;
|
||||
#[allow(unused)]
|
||||
fn to_raw_part_list(&self) -> RawPartList;
|
||||
}
|
||||
|
||||
pub trait SR1ShipTrait {
|
||||
fn to_sr_ship(&self, name: Option<String>) -> SR1Ship;
|
||||
#[allow(unused)]
|
||||
fn to_raw_ship(&self) -> RawShip;
|
||||
}
|
||||
|
||||
|
@ -149,11 +149,17 @@ impl Damage {
|
||||
}
|
||||
|
||||
// This enumeration can be considered to replace the integer-represented "fuel type".
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone, Default)]
|
||||
pub enum FuelType {
|
||||
Common,
|
||||
Rcs,
|
||||
Battery,
|
||||
Soild,
|
||||
/// 就是液体燃料
|
||||
#[default]
|
||||
Common = 0,
|
||||
/// RCS 推进剂
|
||||
Rcs = 1,
|
||||
/// 电!!!!!
|
||||
Battery = 2,
|
||||
/// 固推神教!
|
||||
Soild = 3,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
@ -167,7 +173,7 @@ pub struct Tank {
|
||||
// 2 -> 电量
|
||||
// 3 -> 固推
|
||||
#[serde(rename = "@fuelType")]
|
||||
pub fuel_type: Option<i32>,
|
||||
pub fuel_type: Option<FuelType>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||
@ -181,7 +187,7 @@ pub struct Engine {
|
||||
#[serde(rename = "@turn")]
|
||||
pub turn: f64,
|
||||
#[serde(rename = "@fuelType")]
|
||||
pub fuel_type: Option<i32>,
|
||||
pub fuel_type: Option<FuelType>,
|
||||
#[serde(rename = "@throttleExponential")]
|
||||
pub throttle_exponential: Option<bool>,
|
||||
}
|
||||
@ -286,7 +292,7 @@ impl SR1PartTypeData for RawPartType {
|
||||
Some(SR1PartTypeAttr::Tank {
|
||||
fuel: tank.fuel,
|
||||
dry_mass: tank.dry_mass,
|
||||
fuel_type: tank.fuel_type.unwrap_or(0),
|
||||
fuel_type: tank.fuel_type.unwrap_or_default(),
|
||||
})
|
||||
}
|
||||
SR1PartTypeEnum::engine => {
|
||||
@ -296,7 +302,7 @@ impl SR1PartTypeData for RawPartType {
|
||||
consumption: engine.consumption,
|
||||
size: engine.size,
|
||||
turn: engine.turn,
|
||||
fuel_type: engine.fuel_type.unwrap_or(0),
|
||||
fuel_type: engine.fuel_type.unwrap_or_default(),
|
||||
throttle_exponential: engine.throttle_exponential.unwrap_or(false),
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user