Compare commits

..

No commits in common. "9bbece1da4e497790dd2d5ba6bffaf8d7eb8d243" and "bd151bd4d9b153f47d34911e1142afd4cff85527" have entirely different histories.

2 changed files with 1 additions and 81 deletions

View File

@ -206,45 +206,6 @@ impl PySR1PartData {
} }
} }
#[pyclass]
#[derive(Clone, Debug)]
#[pyo3(name = "SR1PartTypeArrayIterator_rs")]
pub struct PySR1PartDataIterator {
pub datas: Vec<(PySR1PartType, PySR1PartData)>,
pub index: usize,
}
#[pymethods]
impl PySR1PartDataIterator {
fn __next__(mut slf: PyRefMut<'_, Self>) -> Option<(PySR1PartType, PySR1PartData)> {
if slf.index < slf.datas.len() {
slf.index += 1;
Some(slf.datas[slf.index - 1].clone())
} else {
None
}
}
}
/// 用来存一堆 PartData 的数组
#[pyclass]
#[derive(Clone, Debug)]
#[pyo3(name = "SR1PartArray_rs")]
pub struct PySR1PartArray {
pub datas: Vec<(PySR1PartType, PySR1PartData)>,
pub part_list: SR1PartList,
}
#[pymethods]
impl PySR1PartArray {
fn __iter__(&self) -> PySR1PartDataIterator {
PySR1PartDataIterator {
datas: self.datas.clone(),
index: 0,
}
}
}
#[pyclass] #[pyclass]
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[pyo3(name = "SR1Ship_rs")] #[pyo3(name = "SR1Ship_rs")]
@ -272,48 +233,6 @@ impl PySR1Ship {
} }
} }
fn parts(&self) -> PySR1PartArray {
let mut parts: Vec<(PySR1PartType, PySR1PartData)> = Vec::new();
for part_data in self.ship.parts.iter() {
if let Some(part_type) = self.part_list.get_part_type(&part_data.part_type_id) {
let part_type = PySR1PartType::new(part_type.clone());
let py_part_data = PySR1PartData::new(part_data.clone());
parts.push((part_type, py_part_data));
}
}
PySR1PartArray {
datas: parts,
part_list: self.part_list.clone(),
}
}
fn disconnected_parts(&self) -> Vec<PySR1PartArray> {
match self.ship.disconnected.as_ref() {
Some(parts) => {
if parts.is_empty() {
return Vec::new();
}
let mut result = Vec::with_capacity(parts.len());
for (part_group, _) in parts.iter() {
let mut part_list = Vec::with_capacity(part_group.len());
for part_data in part_group.iter() {
if let Some(part_type) = self.part_list.get_part_type(&part_data.part_type_id) {
let part_type = PySR1PartType::new(part_type.clone());
let py_part_data = PySR1PartData::new(part_data.clone());
part_list.push((part_type, py_part_data));
}
}
result.push(PySR1PartArray {
datas: part_list,
part_list: self.part_list.clone(),
});
}
result
}
None => Vec::new(),
}
}
#[getter] #[getter]
fn get_img_pos(&self) -> (i64, i64, i64, i64) { fn get_img_pos(&self) -> (i64, i64, i64, i64) {
// -x, -y, +x, +y // -x, -y, +x, +y

View File

@ -881,6 +881,7 @@ impl SR1Ship {
fn write_data(data: &SR1Ship, save_status: &SaveStatus) -> String { fn write_data(data: &SR1Ship, save_status: &SaveStatus) -> String {
let mut writer: Writer<Cursor<Vec<u8>>> = Writer::new(Cursor::new(Vec::new())); let mut writer: Writer<Cursor<Vec<u8>>> = Writer::new(Cursor::new(Vec::new()));
{ {
// ship attr // ship attr
let mut ship_elem = BytesStart::new("Ship"); let mut ship_elem = BytesStart::new("Ship");