DR 0.7.1.4 + DR_rs 0.2.5.4
This commit is contained in:
parent
9aaa1a1a23
commit
53c4731593
@ -22,9 +22,9 @@ from Difficult_Rocket.api.types import Options
|
|||||||
|
|
||||||
from libs.MCDR.version import Version
|
from libs.MCDR.version import Version
|
||||||
|
|
||||||
game_version = Version("0.7.1.2") # 游戏版本
|
game_version = Version("0.7.1.4") # 游戏版本
|
||||||
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
build_version = Version("1.1.0.0") # 编译文件版本(与游戏本体无关)
|
||||||
DR_rust_version = Version("0.2.5.3") # DR 的 Rust 编写部分的版本
|
DR_rust_version = Version("0.2.5.4") # DR 的 Rust 编写部分的版本
|
||||||
Api_version = Version("0.0.0.1") # API 版本
|
Api_version = Version("0.0.0.1") # API 版本
|
||||||
__version__ = game_version
|
__version__ = game_version
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ use pyo3::prelude::*;
|
|||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
fn get_version_str() -> String {
|
fn get_version_str() -> String {
|
||||||
return String::from("0.2.5.3");
|
return "0.2.5.4".to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[pyfunction]
|
#[pyfunction]
|
||||||
|
@ -98,6 +98,20 @@ pub mod part_list {
|
|||||||
pub points: Vec<AttachPoint>,
|
pub points: Vec<AttachPoint>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AttachPoints {
|
||||||
|
pub fn new(attachs: Vec<AttachPoint>) -> Self {
|
||||||
|
AttachPoints { points: attachs }
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert(&mut self, attach: AttachPoint) {
|
||||||
|
self.points.push(attach);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn unzip(&self) -> Vec<AttachPoint> {
|
||||||
|
self.points.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
|
||||||
pub struct Damage {
|
pub struct Damage {
|
||||||
pub disconnect: i32,
|
pub disconnect: i32,
|
||||||
@ -253,6 +267,8 @@ pub mod part_list {
|
|||||||
};
|
};
|
||||||
let damage = self.damage.unwrap_or(Damage {disconnect: 0, explode: 0,
|
let damage = self.damage.unwrap_or(Damage {disconnect: 0, explode: 0,
|
||||||
explosion_power: Some(0u32), explosion_size: Some(0u32) });
|
explosion_power: Some(0u32), explosion_size: Some(0u32) });
|
||||||
|
let attach_points = if let Some(attach_points) = &self.attach_points {
|
||||||
|
Some(attach_points.unzip()) } else { None };
|
||||||
SR1PartType {
|
SR1PartType {
|
||||||
id: self.id.clone(),
|
id: self.id.clone(),
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
@ -272,9 +288,9 @@ pub mod part_list {
|
|||||||
drag: self.drag.unwrap_or(0.0),
|
drag: self.drag.unwrap_or(0.0),
|
||||||
hidden: self.hidden.unwrap_or(false),
|
hidden: self.hidden.unwrap_or(false),
|
||||||
buoyancy: self.buoyancy.unwrap_or(0.0),
|
buoyancy: self.buoyancy.unwrap_or(0.0),
|
||||||
// shape: self.shape.clone().unwrap_or(vec![]),
|
|
||||||
shape: None,
|
shape: None,
|
||||||
damage: damage.to_damage(),
|
damage: damage.to_damage(),
|
||||||
|
attach_points,
|
||||||
attr: part_attr,
|
attr: part_attr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,10 @@
|
|||||||
|
|
||||||
|
|
||||||
pub mod sr1 {
|
pub mod sr1 {
|
||||||
use super::math::{Shape, Point2D};
|
// use super::math::{Shape, Point2D};
|
||||||
use crate::sr1_data::part_list::{RawPartList, RawPartType, SR1PartTypeEnum, Location};
|
use crate::sr1_data::part_list::{RawPartList, RawPartType, SR1PartTypeEnum};
|
||||||
use crate::sr1_data::part_list::Damage as RawDamage;
|
use crate::sr1_data::part_list::Damage as RawDamage;
|
||||||
|
use crate::sr1_data::part_list::{Tank, Engine, Solar, Rcs, Lander, AttachPoint, AttachPoints, Shape as RawShape};
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn map_ptype_textures(ptype: String) -> String {
|
pub fn map_ptype_textures(ptype: String) -> String {
|
||||||
@ -63,7 +64,7 @@ pub mod sr1 {
|
|||||||
pub connections: Option<Vec<((usize, usize), (isize, isize))>>
|
pub connections: Option<Vec<((usize, usize), (isize, isize))>>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub enum SR1PartAttr {
|
pub enum SR1PartAttr {
|
||||||
Tank {
|
Tank {
|
||||||
fuel: f64,
|
fuel: f64,
|
||||||
@ -87,7 +88,7 @@ pub mod sr1 {
|
|||||||
consumption: f64,
|
consumption: f64,
|
||||||
size: f64,
|
size: f64,
|
||||||
},
|
},
|
||||||
Solar { charge_rate: f64, },
|
Solar { charge_rate: f64 },
|
||||||
Lander {
|
Lander {
|
||||||
max_angle: f64,
|
max_angle: f64,
|
||||||
min_length: f64,
|
min_length: f64,
|
||||||
@ -162,18 +163,30 @@ pub mod sr1 {
|
|||||||
// 综合属性
|
// 综合属性
|
||||||
pub damage: Damage,
|
pub damage: Damage,
|
||||||
// 部件受损相关属性
|
// 部件受损相关属性
|
||||||
pub shape: Option<Shape>,
|
pub shape: Option<Vec<RawShape>>,
|
||||||
// 部件碰撞箱
|
// 部件碰撞箱
|
||||||
|
pub attach_points: Option<Vec<AttachPoint>>,
|
||||||
|
// 部件连接点
|
||||||
pub attr: Option<SR1PartAttr>
|
pub attr: Option<SR1PartAttr>
|
||||||
// 部件特殊属性
|
// 部件特殊属性
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SR1PartList {
|
pub struct SR1PartList {
|
||||||
pub types: Vec<SR1PartType>,
|
pub types: Vec<SR1PartType>,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SR1PartList {
|
||||||
|
pub fn to_raw_part_list(&self) -> RawPartList {
|
||||||
|
let mut types: Vec<RawPartType> = Vec::new();
|
||||||
|
for part_type in &self.types {
|
||||||
|
types.insert(0, part_type.to_raw_part_type());
|
||||||
|
}
|
||||||
|
RawPartList{part_types: types}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait SR1PartTypeData {
|
pub trait SR1PartTypeData {
|
||||||
fn to_sr_part_type(&self) -> SR1PartType;
|
fn to_sr_part_type(&self) -> SR1PartType;
|
||||||
fn to_raw_part_type(&self) -> RawPartType;
|
fn to_raw_part_type(&self) -> RawPartType;
|
||||||
@ -197,10 +210,6 @@ pub mod sr1 {
|
|||||||
SR1PartList::new(name, types)
|
SR1PartList::new(name, types)
|
||||||
}
|
}
|
||||||
|
|
||||||
// pub fn part_type_new(part_type: RawPartType) -> Self {
|
|
||||||
// let mut types: Vec<SR1PartType> = Vec::new();
|
|
||||||
// }
|
|
||||||
|
|
||||||
pub fn insert_part(&mut self, part: SR1PartType) -> () {
|
pub fn insert_part(&mut self, part: SR1PartType) -> () {
|
||||||
self.types.insert(0, part);
|
self.types.insert(0, part);
|
||||||
}
|
}
|
||||||
@ -212,7 +221,43 @@ pub mod sr1 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn to_raw_part_type(&self) -> RawPartType {
|
fn to_raw_part_type(&self) -> RawPartType {
|
||||||
// let shape = crate::sr1_data::part_list::Shape;
|
let tank: Option<Tank> = match &self.attr {
|
||||||
|
Some(attr) => {
|
||||||
|
match attr {
|
||||||
|
SR1PartAttr::Tank {fuel, dry_mass, fuel_type} => {
|
||||||
|
Some(Tank {fuel: *fuel, dry_mass: *dry_mass, fuel_type: Some(*fuel_type)})
|
||||||
|
} _ => None } } _ => None };
|
||||||
|
let engine: Option<Engine> = match &self.attr {
|
||||||
|
Some(attr) => {
|
||||||
|
match attr {
|
||||||
|
SR1PartAttr::Engine {power, consumption, size, turn, fuel_type, throttle_exponential } => {
|
||||||
|
Some(Engine {power: *power, consumption: *consumption, throttle_exponential: Some(*throttle_exponential),
|
||||||
|
size: *size, turn: *turn, fuel_type: Some(*fuel_type)})
|
||||||
|
} _ => None } } _ => None };
|
||||||
|
let rcs: Option<Rcs> = match &self.attr {
|
||||||
|
Some(attr) => {
|
||||||
|
match attr {
|
||||||
|
SR1PartAttr::Rcs {power, consumption, size } => {
|
||||||
|
Some(Rcs {power: *power, consumption: *consumption, size: *size })
|
||||||
|
} _ => None } } _ => None };
|
||||||
|
let solar: Option<Solar> = match &self.attr {
|
||||||
|
Some(attr) => {
|
||||||
|
match attr {
|
||||||
|
SR1PartAttr::Solar {charge_rate } => {
|
||||||
|
Some(Solar {charge_rate: *charge_rate })
|
||||||
|
} _ => None } } _ => None };
|
||||||
|
let lander: Option<Lander> = match &self.attr {
|
||||||
|
Some(attr) => {
|
||||||
|
match attr {
|
||||||
|
SR1PartAttr::Lander {max_angle, min_length, max_length, angle_speed, 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 })
|
||||||
|
} _ => None } } _ => None };
|
||||||
|
let attach_point: Option<AttachPoints> = match &self.attach_points {
|
||||||
|
Some(attach_points) => {
|
||||||
|
if attach_points.len() > 0 {
|
||||||
|
Some(AttachPoints::new(attach_points.clone()))
|
||||||
|
} else { None } } _ => None };
|
||||||
RawPartType {
|
RawPartType {
|
||||||
id: self.id.clone(),
|
id: self.id.clone(),
|
||||||
name: self.name.clone(),
|
name: self.name.clone(),
|
||||||
@ -233,14 +278,13 @@ pub mod sr1 {
|
|||||||
hidden: Some(self.hidden),
|
hidden: Some(self.hidden),
|
||||||
buoyancy: Some(self.buoyancy),
|
buoyancy: Some(self.buoyancy),
|
||||||
damage: Some(self.damage.to_raw_damage()),
|
damage: Some(self.damage.to_raw_damage()),
|
||||||
tank: None,
|
tank,
|
||||||
engine: None,
|
engine,
|
||||||
rcs: None,
|
rcs,
|
||||||
solar: None,
|
solar,
|
||||||
// shape: Some(self.shape.clone()),
|
shape: self.shape.clone(),
|
||||||
shape: None,
|
|
||||||
attach_points: None,
|
attach_points: None,
|
||||||
lander: None,
|
lander,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -250,6 +294,14 @@ pub mod sr1 {
|
|||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub mod math {
|
pub mod math {
|
||||||
|
|
||||||
|
pub trait Rotatable {
|
||||||
|
// 懒了,直接实现一个协议得了
|
||||||
|
#[inline]
|
||||||
|
fn rotate(&self, angle: f64) -> Self;
|
||||||
|
#[inline]
|
||||||
|
fn rotate_radius(&self, radius: f64) -> Self;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct Point2D {
|
pub struct Point2D {
|
||||||
pub x: f64,
|
pub x: f64,
|
||||||
@ -258,11 +310,11 @@ pub mod math {
|
|||||||
|
|
||||||
impl Point2D {
|
impl Point2D {
|
||||||
pub fn new(x: f64, y: f64) -> Self {
|
pub fn new(x: f64, y: f64) -> Self {
|
||||||
Point2D{x, y}
|
Point2D { x, y }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_00() -> Self { Point2D { x: 0.0, y :0.0 } }
|
pub fn new_00() -> Self { Point2D { x: 0.0, y: 0.0 } }
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn distance(&self, other: &Point2D) -> f64 {
|
pub fn distance(&self, other: &Point2D) -> f64 {
|
||||||
@ -275,10 +327,16 @@ pub mod math {
|
|||||||
pub fn distance_00(&self) -> f64 {
|
pub fn distance_00(&self) -> f64 {
|
||||||
self.distance(&Point2D::new(0.0, 0.0))
|
self.distance(&Point2D::new(0.0, 0.0))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Rotatable for Point2D {
|
||||||
|
#[inline]
|
||||||
|
fn rotate(&self, angle: f64) -> Self {
|
||||||
|
self.rotate_radius(angle.to_radians())
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn rotate_angle(&self, angle: f64) -> Self {
|
fn rotate_radius(&self, radius: f64) -> Self {
|
||||||
let radius = angle.to_radians();
|
|
||||||
let sin = radius.sin();
|
let sin = radius.sin();
|
||||||
let cos = radius.cos();
|
let cos = radius.cos();
|
||||||
let x = self.x * cos - self.y * sin;
|
let x = self.x * cos - self.y * sin;
|
||||||
@ -287,6 +345,7 @@ pub mod math {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct CircularArc {
|
pub struct CircularArc {
|
||||||
pub r: f64,
|
pub r: f64,
|
||||||
@ -311,6 +370,16 @@ pub mod math {
|
|||||||
// end point
|
// end point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Rotatable for OneTimeLine {
|
||||||
|
fn rotate(&self, angle: f64) -> Self {
|
||||||
|
self.rotate_radius(angle.to_radians())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rotate_radius(&self, radius: f64) -> Self {
|
||||||
|
OneTimeLine::point_new(&self.start.rotate_radius(radius), &self.end.rotate_radius(radius))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub enum Edge {
|
pub enum Edge {
|
||||||
OneTimeLine(OneTimeLine),
|
OneTimeLine(OneTimeLine),
|
||||||
@ -322,7 +391,7 @@ pub mod math {
|
|||||||
pub pos: Point2D,
|
pub pos: Point2D,
|
||||||
pub angle: f64,
|
pub angle: f64,
|
||||||
// 旋转角度 角度值
|
// 旋转角度 角度值
|
||||||
pub bounds: Vec<Edge>
|
pub bounds: Vec<Edge>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Shape {
|
impl Shape {
|
||||||
@ -346,12 +415,12 @@ pub mod math {
|
|||||||
edges = edges.iter().map(|edge| {
|
edges = edges.iter().map(|edge| {
|
||||||
match edge {
|
match edge {
|
||||||
Edge::OneTimeLine(line) => {
|
Edge::OneTimeLine(line) => {
|
||||||
let start = line.start.rotate_angle(angle);
|
let start = line.start.rotate(angle);
|
||||||
let end = line.end.rotate_angle(angle);
|
let end = line.end.rotate(angle);
|
||||||
Edge::OneTimeLine(OneTimeLine::point_new(&start, &end))
|
Edge::OneTimeLine(OneTimeLine::point_new(&start, &end))
|
||||||
},
|
},
|
||||||
Edge::CircularArc(arc) => {
|
Edge::CircularArc(arc) => {
|
||||||
let pos = arc.pos.rotate_angle(angle);
|
let pos = arc.pos.rotate(angle);
|
||||||
Edge::CircularArc(CircularArc{ r: arc.r, pos, start_angle: arc.start_angle, end_angle: arc.end_angle })
|
Edge::CircularArc(CircularArc{ r: arc.r, pos, start_angle: arc.start_angle, end_angle: arc.end_angle })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -404,10 +473,6 @@ pub mod math {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rotate(&self, angle: f64) -> Self {
|
|
||||||
OneTimeLine::point_new(&self.start.rotate_angle(angle), &self.end.rotate_angle(angle))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn point_d() -> f64 {
|
pub fn point_d() -> f64 {
|
||||||
1.0
|
1.0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user