继续更新

ChatGPT依然在胡言乱语
This commit is contained in:
shenjack 2023-02-26 08:46:04 +08:00
parent f6c958a85b
commit 577eb629e3
11 changed files with 238 additions and 69 deletions

View File

@ -20,7 +20,31 @@ errors = {
'error.happen': '游戏出现了一个报错!正在处理'
}
def print_path() -> None:
print(f'{__file__=}')
print(f'{sys.path=}')
print(f'{sys.path[0]=}')
print(f'{sys.argv[0]=}')
print(f'{os.getcwd()=}')
print(f'{os.path.abspath(__file__)=}')
print(f'{os.path.realpath(__file__)=}')
print(f'{os.path.split(os.path.split(os.path.realpath(__file__))[0])=}')
# 输出一遍大部分文件位置相关信息 以后可能会加到logs里
def modify_path() -> None:
file_path = os.path.split(os.path.realpath(__file__))[0]
os.chdir(file_path) # 将运行路径切换到文件位置 防止bug
sys.path.append(f'{file_path}/Difficult_Rocket') # 添加local path
sys.path.append(f'{file_path}/libs') # 添加 libs path
if __name__ == '__main__':
print(hi) # hi
# 记录启动信息
start_time_ns = time.time_ns()
start_time_perf_ns = time.perf_counter_ns()
print_path()
modify_path()

14
DR.py
View File

@ -23,10 +23,9 @@ error_format = {
}
def main() -> None:
start_time_ns = time.time_ns()
start_time_perf_ns = time.perf_counter_ns()
def print_path() -> None:
print(f'{__file__=}')
print(f'{sys.path=}')
print(f'{sys.path[0]=}')
print(f'{sys.argv[0]=}')
print(f'{os.getcwd()=}')
@ -34,12 +33,17 @@ def main() -> None:
print(f'{os.path.realpath(__file__)=}')
print(f'{os.path.split(os.path.split(os.path.realpath(__file__))[0])=}')
# 输出一遍大部分文件位置相关信息 以后可能会加到logs里
def main() -> None:
print(hi) # hi
start_time_ns = time.time_ns()
start_time_perf_ns = time.perf_counter_ns()
print_path()
file_path = os.path.split(os.path.realpath(__file__))[0]
os.chdir(file_path) # 将运行路径切换到文件位置 防止bug
sys.path.append(f'{file_path}/Difficult_Rocket') # 添加local path
sys.path.append(f'{file_path}/libs') # 添加 libs path
print(sys.path) # 输出路径
print(hi) # hi
from Difficult_Rocket.exception import TestError
from Difficult_Rocket import crash

View File

@ -70,12 +70,13 @@
- `xmltodict`: xml 与 dict 转换器
- `pyperclip`: 剪贴板!
- `rapier2d`: 物理模拟引擎
- `pyo3`: Rust Python 扩展
- 主要贡献者
- [@Rayawa](https://github.com/Rayawa) : 文档矫正 & 翻译部分 lang
- [@rouxiao-you](https://github.com/ruoxiao-you) : 翻译 lang
- [@Billchyi](https://github.com/Billchyi) : 文档矫正
- [@MSDNicrosoft]()
- [@MSDNicrosoft](https://github.com/MSDNicrosoft) : 优化代码
## 相关链接

View File

@ -21,6 +21,6 @@ if ($do -or "311" -in $args) {
python3.11 setup.py build
}
python3.10 post_build.py
python3 post_build.py
Set-Location ..\..\..\

View File

@ -70,11 +70,13 @@
- `xmltodict`: translate data between xml and dict
- `pyperclip`: paste board!
- `rapier2d`: Phy simulate engine
- `pyo3`: Rust Python Binding
- Main contributors
- [@Rayawa](https://github.com/Rayawa) : check mistake in docs & some translates
- [@rouxiao-you](https://github.com/ruoxiao-you) : translate chinese to English
- [@Billchyi](https://github.com/Billchyi) : check mistake in docs
- [@Rayawa](https://github.com/Rayawa) : Check mistake in docs & some translates
- [@rouxiao-you](https://github.com/ruoxiao-you) : Translate chinese to English
- [@Billchyi](https://github.com/Billchyi) : Check mistake in docs
- [@MSDNicrosoft](https://github.com/MSDNicrosoft) : Optimize code
## Other links

View File

@ -28,6 +28,8 @@ open-on-text = "Found a bug? [Edit this page on GitHub.]"
# Should we check links on the internet? Enabling this option adds a
# non-negligible performance impact
follow-web-links = false
warning-policy = "ignore"
exclude = [ "requirement-dev.txt" ]
# Are we allowed to link to files outside of the book's root directory? This
# may help prevent linking to sensitive files (e.g. "../../../../etc/shadow")

View File

@ -5,4 +5,16 @@
1. Powershell 7+
2. Python3.8 +
3. gcc / clang 编译器
4. git
4. rust 工具链
5. git
## 安装依赖
1. 确保 Path 下有以下内容
- `python`
- `python3.8`
- 可供 `setuptools-rust` 调用的 rust 工具链
2. 为 Python 安装 [requrements-dev.txt](../requirement-dev.txt) 的依赖
- `python -m pip install -r requre`
3. 使用 `build_rs.ps1` 尝试编译一次 `DR_rs`
- `./build_rs.ps1` 38/39/310/311

View File

@ -20,6 +20,24 @@
- [![Readme-gitee](https://img.shields.io/badge/Readme-中文(点我!)-blue.svg?style=flat-square)](../../README.md)
- Using [SemVer 2.0.0](https://semver.org/) to manage version
## 202303 V 0.7.1.2
### `DR_rs` V 0.2.5.2
- `0.2.5.0` -> `0.2.5.2`
- `sr1_data.rs`
- 现在可以完整解析 SR1 的 `PartList.xml`
- 解析后会生成一个 `PartList` 对象
- Now can parse `PartList.xml` completely
- Will generate a `PartList` object after parsing
### 重命名
- `.github/workflows/after_compile.py` -> `.github/workflows/post_compile.py`
- `libs/Difficult_Rocket_rs/src/after_build.py` -> `libs/Difficult_Rocket_rs/src/post_build.py`
## 20230219 V 0.7.1.1
### 删除了多余的 print

View File

@ -19,7 +19,7 @@ pub mod part_list {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PartList {
#[serde(rename = "PartType")]
part_types: Vec<PartType>
part_types: Vec<PartType>,
}
#[allow(non_camel_case_types)]
@ -38,13 +38,7 @@ pub mod part_list {
solar,
dockconnector,
dockport,
lander
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub enum Category {
Satellite,
None
lander,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
@ -62,14 +56,12 @@ pub mod part_list {
TopSide,
BottomSide,
LeftSide,
RightSide
RightSide,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Vertex {
#[serde(rename = "@x")]
pub x: Option<f64>,
#[serde(rename = "@y")]
pub y: Option<f64>,
}
@ -78,54 +70,93 @@ pub mod part_list {
#[serde(rename = "Vertex")]
pub vertex: Vec<Vertex>,
#[serde(rename = "sensor")]
pub sensor: Option<bool>
pub sensor: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct AttachPoint {
pub location: Option<Location>,
#[serde(rename = "@x")]
pub x: Option<f64>,
#[serde(rename = "@y")]
pub y: Option<f64>,
#[serde(rename = "@breakAngle")]
#[serde(rename = "flipX")]
pub flip_x: Option<bool>,
#[serde(rename = "flipY")]
pub flip_y: Option<bool>,
#[serde(rename = "breakAngle")]
pub break_angle: Option<i32>,
#[serde(rename = "@breakForce")]
#[serde(rename = "breakForce")]
pub break_force: Option<f64>,
#[serde(rename = "@fuelLine")]
#[serde(rename = "fuelLine")]
pub fuel_line: Option<bool>,
#[serde(rename = "@group")]
pub group: Option<i32>,
#[serde(rename = "@order")]
pub order: Option<i32>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct AttachPoints {
#[serde(rename = "AttachPoint")]
pub points: Vec<AttachPoint>
pub points: Vec<AttachPoint>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub enum PartAttr {
Damage,
Tank,
Engine,
Rcs,
Solar,
Lander
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Damage {
disconnect: u32,
explode: u32,
#[serde(rename = "explosionPower")]
explosion_power: u32,
#[serde(rename = "explosionSize")]
explosion_size: u32,
}
// #[derive(Debug, Serialize, Deserialize, Clone)]
// pub struct PartAttr {
// // 单独类型节点
// // pub part_attr: Option<Vec<PartAttr>>,
// }
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Tank {
fuel: f64,
#[serde(rename = "dryMass")]
dry_mass: f64,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Engine {
power: f64,
consumption: f64,
size: f64,
turn: f64,
#[serde(rename = "fuelType")]
fuel_type: Option<i32>,
#[serde(rename = "throttleExponential")]
throttle_exponential: Option<bool>,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Rcs {
power: f64,
consumption: f64,
size: f64,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Solar {
#[serde(rename = "chargeRate")]
charge_rate: f64,
}
#[derive(Debug, Serialize, Deserialize, Copy, Clone)]
pub struct Lander {
#[serde(rename = "maxAngle")]
max_angle: i32,
#[serde(rename = "minLength")]
min_length: f64,
#[serde(rename = "maxLength")]
max_length: f64,
#[serde(rename = "angleSpeed")]
angle_speed: Option<i32>,
#[serde(rename = "lengthSpeed")]
length_speed: Option<f64>,
width: f64,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct PartType {
// https://docs.rs/quick-xml/latest/quick_xml/de/index.html
// 基本属性
pub id: String,
pub name: String,
@ -137,16 +168,16 @@ pub mod part_list {
pub height: u32,
// 可选属性
pub friction: Option<f64>,
pub category: Option<Category>,
#[serde(rename = "@ignoreEditorIntersections")]
pub category: Option<String>,
#[serde(rename = "ignoreEditorIntersections")]
pub ignore_editor_intersections: Option<bool>,
#[serde(rename = "@disableEditorRotation")]
#[serde(rename = "disableEditorRotation")]
pub disable_editor_rotation: Option<bool>,
#[serde(rename = "@canExplode")]
#[serde(rename = "canExplode")]
pub can_explode: Option<bool>,
#[serde(rename = "@coverHeight")]
#[serde(rename = "coverHeight")]
pub cover_height: Option<u32>,
#[serde(rename = "@sandboxOnly")]
#[serde(rename = "sandboxOnly")]
pub sandbox_only: Option<bool>,
pub drag: Option<f64>,
pub hidden: Option<bool>,
@ -156,9 +187,27 @@ pub mod part_list {
pub shape: Option<Vec<Shape>>,
#[serde(rename = "AttachPoints")]
pub attach_points: Option<AttachPoints>,
#[serde(rename = "Damage")]
pub damage: Option<Damage>,
// 特殊属性子节点
#[serde(rename = "Tank")]
pub tank: Option<Tank>,
#[serde(rename = "Engine")]
pub engine: Option<Engine>,
#[serde(rename = "Tank")]
pub rcs: Option<Rcs>,
#[serde(rename = "Solar")]
pub solar: Option<Solar>,
#[serde(rename = "Lander")]
pub lander: Option<Lander>,
}
impl PartList {
pub fn list_print(&self) -> () {
for part_data in self.part_types.iter() {
println!("{:?}\n", part_data);
}
}
}
#[inline]
@ -169,7 +218,7 @@ pub mod part_list {
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
@ -183,10 +232,10 @@ pub mod part_list {
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)
// println!("{:?}", parts)
parts.list_print()
}
// read_part_list(file_name);
Ok(())
}
}

View File

@ -8,7 +8,9 @@
pub mod sr1 {
use super::math::{Shape, Point2D};
#[inline]
pub fn map_ptype_textures(ptype: String) -> String {
match ptype.as_str() {
"pod-1" => "Pod",
@ -42,6 +44,7 @@ pub mod sr1 {
}.to_string()
}
#[derive(Clone)]
pub struct SR1PartData {
pub x: f64,
pub y: f64,
@ -57,6 +60,62 @@ pub mod sr1 {
pub textures: String,
pub connections: Option<Vec<((usize, usize), (isize, isize))>>
}
#[allow(non_camel_case_types)]
#[derive(Copy, Clone)]
pub enum PartTypes {
pod,
detacher,
wheel,
fuselage,
strut,
tank,
engine,
parachute,
nosecone,
rcs,
solar,
dockconnector,
dockport,
lander,
}
#[derive(Copy, Clone)]
pub struct Damage {
disconnect: i32,
// 断裂受力大小
explode: i32,
// 爆炸受力大小
explosion_power: i32,
// 爆炸力量
explosion_size: i32,
// 爆炸大小
}
#[derive(Clone)]
pub struct SR1PartType {
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: f64,
pub category: String,
pub ignore_editor_intersections: bool,
pub disable_editor_rotation: bool,
pub can_explode: bool,
pub cover_height: u32,
pub sandbox_only: bool,
pub drag: f64,
pub hidden: bool,
pub buoyancy: f64,
pub damage: Damage,
pub shape: Shape,
}
}
#[allow(unused)]
@ -113,8 +172,8 @@ pub mod math {
#[derive(Clone, Copy)]
pub struct OneTimeLine {
pub k: f64,
pub b: f64,
// pub k: f64,
// pub b: f64,
// y = kx + b
// kx + b - y = 0
pub start: Point2D,
@ -125,8 +184,8 @@ pub mod math {
#[derive(Clone, Copy)]
pub enum Edge {
OneTimeLine{data: OneTimeLine},
CircularArc{data: CircularArc},
OneTimeLine(OneTimeLine),
CircularArc(CircularArc),
}
#[derive(Clone)]
@ -149,10 +208,10 @@ pub mod math {
let d_width = width / 2.0;
let d_height = height / 2.0;
let mut edges: Vec<Edge> = vec![
Edge::OneTimeLine{data: OneTimeLine::pos_new(-d_width, -d_height, d_width, -d_height)},
Edge::OneTimeLine{data: OneTimeLine::pos_new(d_width, -d_height, d_width, d_height)},
Edge::OneTimeLine{data: OneTimeLine::pos_new(d_width, d_height, -d_width, d_height)},
Edge::OneTimeLine{data: OneTimeLine::pos_new(-d_width, d_height, -d_width, -d_height)}
Edge::OneTimeLine{0: OneTimeLine::pos_new(-d_width, -d_height, d_width, -d_height)},
Edge::OneTimeLine{0: OneTimeLine::pos_new(d_width, -d_height, d_width, d_height)},
Edge::OneTimeLine{0: OneTimeLine::pos_new(d_width, d_height, -d_width, d_height)},
Edge::OneTimeLine{0: OneTimeLine::pos_new(-d_width, d_height, -d_width, -d_height)}
];
if let Some(angle) = angle {
@ -165,11 +224,11 @@ pub mod math {
impl OneTimeLine {
#[inline]
pub fn pos_new(x1: f64, y1: f64, x2: f64, y2: f64) -> Self {
let k = (x2 - x1) / (y2 - y1);
let b = y1 - (x1 * k);
// let k = (x2 - x1) / (y2 - y1);
// let b = y1 - (x1 * k);
let start = Point2D::new(x1, y1);
let end = Point2D::new(x2, y2);
OneTimeLine { k, b, start, end }
OneTimeLine { start, end }
}
#[inline]
@ -199,8 +258,6 @@ pub mod math {
}
}
OneTimeLine{
k: k_,
b: b_,
start: *point,
end: Point2D::new(0.0, b_)
}

View File

@ -1,7 +1,7 @@
$start_time = Get-Uptime
Write-Output $start_time
python3.9 .github/workflows/get_info.py -env
python3 .github/workflows/get_info.py -env
if (-Not (Test-Path -Path "./.github/workflows/env.ps1"))
{