add inventory struct

This commit is contained in:
bgkillas 2025-07-21 15:45:46 -04:00
parent 474422fe28
commit 84ac39abf6
2 changed files with 35 additions and 2 deletions

View file

@ -2,8 +2,8 @@ use std::{os::raw::c_void, ptr};
use crate::lua::LuaState;
use crate::noita::types::{
ComponentTypeManager, EntityManager, GameGlobal, GlobalStats, Platform, StdString, StdVec,
TagManager, TranslationManager,
ComponentTypeManager, EntityManager, GameGlobal, GlobalStats, Inventory, Platform, StdString,
StdVec, TagManager, TranslationManager,
};
use iced_x86::{Decoder, DecoderOptions, Mnemonic};
@ -49,6 +49,7 @@ pub struct GlobalsRef {
pub platform: &'static Platform,
pub global_stats: &'static GlobalStats,
pub filenames: &'static StdVec<StdString>,
pub wand_pickup: &'static Inventory,
}
#[derive(Debug)]
pub struct GlobalsMut {
@ -63,6 +64,7 @@ pub struct GlobalsMut {
pub platform: &'static mut Platform,
pub global_stats: &'static mut GlobalStats,
pub filenames: &'static mut StdVec<StdString>,
pub wand_pickup: &'static mut Inventory,
}
#[derive(Debug, Default)]
@ -78,6 +80,7 @@ pub struct Globals {
pub platform: *mut Platform,
pub global_stats: *mut GlobalStats,
pub filenames: *mut StdVec<StdString>,
pub wand_pickup: *mut Inventory,
}
#[allow(clippy::mut_from_ref)]
impl Globals {
@ -114,6 +117,9 @@ impl Globals {
pub fn filenames(&self) -> Option<&'static StdVec<StdString>> {
unsafe { self.filenames.as_ref() }
}
pub fn wand_pickup(&self) -> Option<&'static Inventory> {
unsafe { self.wand_pickup.as_ref() }
}
pub fn world_seed_mut(&self) -> Option<&'static mut usize> {
unsafe { self.world_seed.as_mut() }
}
@ -147,6 +153,9 @@ impl Globals {
pub fn filenames_mut(&self) -> Option<&'static mut StdVec<StdString>> {
unsafe { self.filenames.as_mut() }
}
pub fn wand_pickup_mut(&self) -> Option<&'static mut Inventory> {
unsafe { self.wand_pickup.as_mut() }
}
pub fn as_ref(&self) -> Option<GlobalsRef> {
Some(GlobalsRef {
world_seed: self.world_seed()?,
@ -160,6 +169,7 @@ impl Globals {
platform: self.platform()?,
global_stats: self.global_stats()?,
filenames: self.filenames()?,
wand_pickup: self.wand_pickup()?,
})
}
pub fn as_mut(&self) -> Option<GlobalsMut> {
@ -175,6 +185,7 @@ impl Globals {
platform: self.platform_mut()?,
global_stats: self.global_stats_mut()?,
filenames: self.filenames_mut()?,
wand_pickup: self.wand_pickup_mut()?,
})
}
pub fn new(lua: LuaState) -> Self {
@ -194,6 +205,7 @@ impl Globals {
let translation_manager = 0x1207c28 as *mut TranslationManager;
let platform = 0x1221bc0 as *mut Platform;
let filenames = 0x1207bd4 as *mut StdVec<StdString>;
let wand_pickup = 0x12224f0 as *mut Inventory;
Self {
world_seed,
new_game_count,
@ -206,6 +218,7 @@ impl Globals {
platform,
global_stats,
filenames,
wand_pickup,
}
}
}

View file

@ -403,3 +403,23 @@ pub struct SpriteStainSystem {}
pub enum GameEffect {
None = 0,
}
#[repr(C)]
#[derive(Debug)]
pub struct Inventory {
unk1: isize,
unk2: isize,
unk3: isize,
held_item: isize,
unk5: isize,
unk6: isize,
unk7: isize,
item_near: isize,
unk9: isize,
unk10: isize,
unk11: isize,
unk12: isize,
unk13: isize,
wand_pickup: *mut Entity,
unk15: isize,
unk16: isize,
}