mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-12-08 06:09:46 +00:00
Remove vegetation when removing pixels
This commit is contained in:
parent
65c8d1eab3
commit
81e497257a
5 changed files with 51 additions and 10 deletions
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
|
|
@ -15,5 +15,9 @@
|
|||
"spellright.documentTypes": [
|
||||
"markdown",
|
||||
"latex"
|
||||
],
|
||||
"rust-analyzer.linkedProjects": [
|
||||
"ewext/Cargo.toml",
|
||||
"noita-proxy/Cargo.toml",
|
||||
]
|
||||
}
|
||||
2
ewext/.cargo/config.toml
Normal file
2
ewext/.cargo/config.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
[build]
|
||||
target = "i686-pc-windows-gnu"
|
||||
|
|
@ -161,9 +161,9 @@ impl WorldData for ParticleWorldState {
|
|||
let xs = start_x + x;
|
||||
let ys = start_y + y;
|
||||
// Drop first
|
||||
unsafe {
|
||||
cell.delete();
|
||||
}
|
||||
pixel_array.remove_pixel(shift_x + x, shift_y + y);
|
||||
|
||||
let cell = pixel_array.get_mut_raw(shift_x + x, shift_y + y);
|
||||
if pixel.is_air() {
|
||||
*cell = Ptr::null();
|
||||
} else {
|
||||
|
|
@ -237,7 +237,8 @@ pub fn test_world() {
|
|||
unknown: [ptr::null(); 3],
|
||||
get_chunk_map: ptr::null(),
|
||||
unknownmagic: ptr::null(),
|
||||
unknown2: [ptr::null(); 29],
|
||||
unknown2: [ptr::null(); 30],
|
||||
remove_vegetation: None,
|
||||
},
|
||||
rng: 0,
|
||||
unk: [0; 292],
|
||||
|
|
|
|||
|
|
@ -602,6 +602,7 @@ impl<K: 'static + Ord, V: 'static> StdMap<K, V> {
|
|||
|
||||
#[repr(transparent)]
|
||||
pub struct ThiscallFn(c_void);
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
#[repr(C)]
|
||||
pub struct LensValueBool {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
use crate::addr_grabber::Globals;
|
||||
use crate::heap;
|
||||
use crate::heap::Ptr;
|
||||
use crate::noita::types::objects::{ConfigExplosion, ConfigGridCosmeticParticle};
|
||||
|
|
@ -5,6 +6,7 @@ use crate::noita::types::{StdMap, StdString, StdVec, ThiscallFn, Vec2, Vec2i};
|
|||
use shared::world_sync::{Pixel, PixelFlags};
|
||||
use std::ffi::c_void;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ptr::null_mut;
|
||||
use std::slice;
|
||||
#[repr(usize)]
|
||||
#[derive(Debug, PartialEq, Clone, Copy, Default)]
|
||||
|
|
@ -366,6 +368,9 @@ impl Cell {
|
|||
pub fn get_liquid(&self) -> &LiquidCell {
|
||||
unsafe { std::mem::transmute::<&Cell, &LiquidCell>(self) }
|
||||
}
|
||||
unsafe fn get_liquid_mut(&mut self) -> &mut LiquidCell {
|
||||
unsafe { std::mem::transmute::<&mut Cell, &mut LiquidCell>(self) }
|
||||
}
|
||||
pub fn get_fire(&self) -> &FireCell {
|
||||
unsafe { std::mem::transmute::<&Cell, &FireCell>(self) }
|
||||
}
|
||||
|
|
@ -483,7 +488,7 @@ pub struct LiquidCell {
|
|||
pub color: Color,
|
||||
pub original_color: Color,
|
||||
lifetime: isize,
|
||||
unknown8: isize,
|
||||
vegetation_sprite: *mut c_void,
|
||||
}
|
||||
|
||||
impl LiquidCell {
|
||||
|
|
@ -521,9 +526,23 @@ impl LiquidCell {
|
|||
color,
|
||||
original_color: color,
|
||||
lifetime,
|
||||
unknown8: 0,
|
||||
vegetation_sprite: null_mut(),
|
||||
}
|
||||
}
|
||||
|
||||
fn remove_vegetation_if_it_exists(&mut self) {
|
||||
if !self.vegetation_sprite.is_null() {
|
||||
unsafe {
|
||||
(Globals::default()
|
||||
.game_global_mut()
|
||||
.m_grid_world
|
||||
.vtable
|
||||
.remove_vegetation
|
||||
.unwrap())(self, self.vegetation_sprite)
|
||||
}
|
||||
}
|
||||
self.vegetation_sprite = null_mut();
|
||||
}
|
||||
}
|
||||
|
||||
impl Cell {
|
||||
|
|
@ -735,6 +754,19 @@ impl Chunk {
|
|||
Pixel::new(0, PixelFlags::Normal)
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn remove_pixel(&mut self, x: isize, y: isize) {
|
||||
let cell = self.get_mut_raw(x, y);
|
||||
if let Some(cell) = unsafe { cell.as_mut() } {
|
||||
if cell.material.cell_type == CellType::Liquid {
|
||||
let liquid_cell = unsafe { cell.get_liquid_mut() };
|
||||
liquid_cell.remove_vegetation_if_it_exists();
|
||||
}
|
||||
}
|
||||
unsafe {
|
||||
cell.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
|
@ -816,10 +848,11 @@ impl ChunkMap {
|
|||
#[derive(Debug)]
|
||||
pub struct GridWorldVTable {
|
||||
//ptr is 0x10013bc
|
||||
pub unknown: [*const ThiscallFn; 3],
|
||||
pub get_chunk_map: *const ThiscallFn,
|
||||
pub unknownmagic: *const ThiscallFn,
|
||||
pub unknown2: [*const ThiscallFn; 29],
|
||||
pub unknown: [*const ThiscallFn; 3], // 0
|
||||
pub get_chunk_map: *const ThiscallFn, // 3
|
||||
pub unknownmagic: *const ThiscallFn, // 4
|
||||
pub unknown2: [*const ThiscallFn; 30], // 5
|
||||
pub remove_vegetation: Option<unsafe extern "stdcall" fn(*mut LiquidCell, *mut c_void)>, // 35
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue