prob bad idea but turn liquid into blob, differentiate liquid from sand

This commit is contained in:
bgkillas 2025-07-10 00:18:56 -04:00
parent 0fc362695f
commit ab306c6d4a
4 changed files with 14 additions and 8 deletions

View file

@ -66,7 +66,7 @@ impl State {
Ok(())
}
}
pub const SIZE: usize = 64;
pub const SIZE: usize = 24;
pub struct Blob {
pub pos: Pos,
pub pixels: FxHashMap<(isize, isize), Pixel>,
@ -184,7 +184,7 @@ impl Blob {
}
map[k][(x, y)] = match map[k][(x, y)] {
CellType::Unknown => {
CellType::Unknown | CellType::Liquid => {
map[k].modified = true;
CellType::Blob
}
@ -300,9 +300,13 @@ impl Blob {
CellType::Other => false,
CellType::Solid => true,
CellType::Liquid => true,
CellType::Sand => true,
CellType::Physics => true,
}
{
if matches!(chunk[n], CellType::Liquid) {
self.pixels.insert(n, p);
}
p.pos.x = c.0 as f32 + 0.5;
p.pos.y = c.1 as f32 + 0.5;
if p.stop.is_none() {

View file

@ -13,6 +13,7 @@ pub enum CellType {
Unknown,
Solid,
Liquid,
Sand,
Blob,
Remove,
Ignore,

View file

@ -117,7 +117,7 @@ impl ParticleWorldState {
}
pub fn get_cell_material_id(&self, cell: &ntypes::Cell) -> u16 {
let offset = unsafe {
(cell.material_ptr as *const ntypes::CellData).offset_from(self.material_list.as_ptr())
(cell.material as *const ntypes::CellData).offset_from(self.material_list.as_ptr())
};
offset as u16
}
@ -132,15 +132,17 @@ impl ParticleWorldState {
.zip(chunk.iter_mut())
{
*pixel = if let Some(cell) = self.get_cell_raw(shift_x + i, shift_y + j, pixel_array) {
match cell.material_ptr.cell_type {
match cell.material.cell_type {
ntypes::CellType::Liquid => {
if std::ptr::eq(cell.material_ptr, self.blob_ptr) {
if std::ptr::eq(cell.material, self.blob_ptr) {
modified = true;
CellType::Remove
} else {
let cell: &ntypes::LiquidCell = unsafe { cell.get_liquid() };
if cell.is_static {
CellType::Solid
} else if cell.cell.material.liquid_sand {
CellType::Sand
} else {
CellType::Liquid
}
@ -247,7 +249,6 @@ impl ParticleWorldState {
) {
let full = ntypes::FullCell::from(*cell);
noita_api::print!("{full:?}");
noita_api::print!("{:?}", cell.material_ptr);
} else {
noita_api::print!("mat nil");
}

View file

@ -692,7 +692,7 @@ pub struct Cell {
unknown1: [isize; 2],
pub is_burning: bool,
unknown2: [u8; 3],
pub material_ptr: &'static CellData,
pub material: &'static CellData,
}
unsafe impl Sync for Cell {}
unsafe impl Send for Cell {}
@ -706,7 +706,7 @@ pub enum FullCell {
}
impl From<Cell> for FullCell {
fn from(value: Cell) -> Self {
if value.material_ptr.cell_type == CellType::Liquid {
if value.material.cell_type == CellType::Liquid {
FullCell::LiquidCell(*unsafe { value.get_liquid() })
} else {
FullCell::Cell(value)