mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
make clone chunks give proper chunk coords
This commit is contained in:
parent
efdb38fcbe
commit
c14da4b23a
2 changed files with 12 additions and 18 deletions
|
@ -213,14 +213,14 @@ impl ParticleWorldState {
|
|||
}
|
||||
///# Safety
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub unsafe fn clone_chunks(&self) -> Vec<((usize, usize), Vec<ntypes::FullCell>)> {
|
||||
pub unsafe fn clone_chunks(&self) -> Vec<((isize, isize), Vec<ntypes::FullCell>)> {
|
||||
self.chunk_map
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, c)| {
|
||||
unsafe { c.0.as_ref() }.map(|c| {
|
||||
let x = i % 512;
|
||||
let y = i / 512;
|
||||
let x = i as isize % 512 - 216;
|
||||
let y = i as isize / 512 - 216;
|
||||
(
|
||||
(x, y),
|
||||
c.iter()
|
||||
|
@ -234,7 +234,7 @@ impl ParticleWorldState {
|
|||
)
|
||||
})
|
||||
})
|
||||
.collect::<Vec<((usize, usize), Vec<ntypes::FullCell>)>>()
|
||||
.collect::<Vec<((isize, isize), Vec<ntypes::FullCell>)>>()
|
||||
}
|
||||
///# Safety
|
||||
pub unsafe fn debug_mouse_pos(&self) -> eyre::Result<()> {
|
||||
|
@ -250,12 +250,8 @@ impl ParticleWorldState {
|
|||
(y.floor() as isize).rem_euclid(512),
|
||||
unsafe { pixel_array.as_mut() }.unwrap(),
|
||||
) {
|
||||
let cell_type = self.get_cell_type(cell);
|
||||
if cell_type == Some(ntypes::CellType::Liquid) {
|
||||
noita_api::print!("{:?}", unsafe { cell.get_liquid() });
|
||||
} else {
|
||||
noita_api::print!("{cell:?}");
|
||||
}
|
||||
let full = ntypes::FullCell::from(*cell);
|
||||
noita_api::print!("{full:?}");
|
||||
noita_api::print!("{:?}", unsafe { cell.material_ptr.as_ref() });
|
||||
} else {
|
||||
noita_api::print!("mat nil");
|
||||
|
|
|
@ -492,7 +492,7 @@ pub struct Cell {
|
|||
unsafe impl Sync for Cell {}
|
||||
unsafe impl Send for Cell {}
|
||||
|
||||
#[derive(Default, Clone, Copy)]
|
||||
#[derive(Default, Clone, Debug, Copy)]
|
||||
pub enum FullCell {
|
||||
Cell(Cell),
|
||||
LiquidCell(LiquidCell),
|
||||
|
@ -501,14 +501,12 @@ pub enum FullCell {
|
|||
}
|
||||
impl From<Cell> for FullCell {
|
||||
fn from(value: Cell) -> Self {
|
||||
if let Some(mat) = unsafe { value.material_ptr.as_ref() } {
|
||||
if mat.cell_type == CellType::Liquid {
|
||||
FullCell::LiquidCell(*unsafe { value.get_liquid() })
|
||||
} else {
|
||||
FullCell::Cell(value)
|
||||
}
|
||||
if let Some(mat) = unsafe { value.material_ptr.as_ref() }
|
||||
&& mat.cell_type == CellType::Liquid
|
||||
{
|
||||
FullCell::LiquidCell(*unsafe { value.get_liquid() })
|
||||
} else {
|
||||
FullCell::None
|
||||
FullCell::Cell(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue