mirror of
https://github.com/IntQuant/noita_entangled_worlds.git
synced 2025-10-19 07:03:16 +00:00
deduce a bit of fields
This commit is contained in:
parent
a238941595
commit
a1484eb171
3 changed files with 34 additions and 35 deletions
|
@ -81,7 +81,7 @@ impl From<&str> for StdString {
|
|||
}
|
||||
}
|
||||
impl StdString {
|
||||
const fn from_str(value: &'static str) -> Self {
|
||||
pub const fn from_str(value: &'static str) -> Self {
|
||||
let mut res = StdString {
|
||||
buffer: Buffer {
|
||||
sso_buffer: [0; 16],
|
||||
|
@ -202,6 +202,13 @@ impl<T: Debug> Debug for StdVec<T> {
|
|||
}
|
||||
}
|
||||
impl<T> StdVec<T> {
|
||||
pub fn null() -> Self {
|
||||
Self {
|
||||
start: ptr::null_mut(),
|
||||
end: ptr::null_mut(),
|
||||
cap: ptr::null_mut(),
|
||||
}
|
||||
}
|
||||
pub fn copy(&self) -> Self {
|
||||
Self {
|
||||
start: self.start,
|
||||
|
|
|
@ -5,14 +5,14 @@ use crate::noita::types::{
|
|||
#[derive(Debug)]
|
||||
pub struct ComponentData {
|
||||
pub vtable: &'static ComponentVTable,
|
||||
unk1: isize,
|
||||
pub local_id: usize,
|
||||
pub type_name: CString,
|
||||
pub type_id: isize,
|
||||
pub id: isize,
|
||||
pub type_id: usize,
|
||||
pub id: usize,
|
||||
pub enabled: bool,
|
||||
unk2: [u8; 3],
|
||||
pub tags: BitSet<8>,
|
||||
unk3: [isize; 4],
|
||||
unk3: [usize; 4],
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug)]
|
||||
|
@ -60,9 +60,9 @@ pub struct ComponentManager {
|
|||
pub end: usize,
|
||||
unk: [isize; 2],
|
||||
pub entity_entry: StdVec<usize>,
|
||||
unk2: [isize; 6],
|
||||
pub next: *mut usize,
|
||||
unk3: [isize; 2],
|
||||
unk2: StdVec<usize>,
|
||||
pub prev: StdVec<usize>,
|
||||
pub next: StdVec<usize>,
|
||||
pub component_list: StdVec<*mut ComponentData>,
|
||||
}
|
||||
impl ComponentManager {
|
||||
|
@ -71,18 +71,14 @@ impl ComponentManager {
|
|||
ComponentIter {
|
||||
component_list: self.component_list.copy(),
|
||||
off: *off,
|
||||
next: self.next,
|
||||
next: self.next.copy(),
|
||||
end: self.end,
|
||||
}
|
||||
} else {
|
||||
ComponentIter {
|
||||
component_list: StdVec {
|
||||
start: std::ptr::null_mut(),
|
||||
end: std::ptr::null_mut(),
|
||||
cap: std::ptr::null_mut(),
|
||||
},
|
||||
component_list: StdVec::null(),
|
||||
off: 0,
|
||||
next: std::ptr::null_mut(),
|
||||
next: StdVec::null(),
|
||||
end: 0,
|
||||
}
|
||||
}
|
||||
|
@ -92,18 +88,14 @@ impl ComponentManager {
|
|||
ComponentIterMut {
|
||||
component_list: self.component_list.copy(),
|
||||
off: *off,
|
||||
next: self.next,
|
||||
next: self.next.copy(),
|
||||
end: self.end,
|
||||
}
|
||||
} else {
|
||||
ComponentIterMut {
|
||||
component_list: StdVec {
|
||||
start: std::ptr::null_mut(),
|
||||
end: std::ptr::null_mut(),
|
||||
cap: std::ptr::null_mut(),
|
||||
},
|
||||
component_list: StdVec::null(),
|
||||
off: 0,
|
||||
next: std::ptr::null_mut(),
|
||||
next: StdVec::null(),
|
||||
end: 0,
|
||||
}
|
||||
}
|
||||
|
@ -175,7 +167,7 @@ pub struct ComponentIter {
|
|||
component_list: StdVec<*mut ComponentData>,
|
||||
off: usize,
|
||||
end: usize,
|
||||
next: *const usize,
|
||||
next: StdVec<usize>,
|
||||
}
|
||||
|
||||
impl Iterator for ComponentIter {
|
||||
|
@ -186,7 +178,7 @@ impl Iterator for ComponentIter {
|
|||
return None;
|
||||
}
|
||||
let com = self.component_list.get(self.off)?.as_ref();
|
||||
self.off = self.next.add(self.off).read();
|
||||
self.off = *self.next.get(self.off)?;
|
||||
com
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +188,7 @@ pub struct ComponentIterMut {
|
|||
component_list: StdVec<*mut ComponentData>,
|
||||
off: usize,
|
||||
end: usize,
|
||||
next: *const usize,
|
||||
next: StdVec<usize>,
|
||||
}
|
||||
|
||||
impl Iterator for ComponentIterMut {
|
||||
|
@ -207,7 +199,7 @@ impl Iterator for ComponentIterMut {
|
|||
return None;
|
||||
}
|
||||
let com = self.component_list.get(self.off)?.as_mut();
|
||||
self.off = self.next.add(self.off).read();
|
||||
self.off = *self.next.get(self.off)?;
|
||||
com
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ impl EntityManager {
|
|||
.filter(|c| c.tags.has_tag(tag_manager, tag))
|
||||
.for_each(|c| c.enabled = enabled)
|
||||
}
|
||||
pub fn get_entity_with_tag(
|
||||
pub fn get_entities_with_tag(
|
||||
&self,
|
||||
tag_manager: &TagManager<u16>,
|
||||
tag: &StdString,
|
||||
|
@ -59,7 +59,7 @@ impl EntityManager {
|
|||
.iter()
|
||||
.filter_map(|e| unsafe { e.as_ref() })
|
||||
}
|
||||
pub fn get_entity_with_tag_mut(
|
||||
pub fn get_entities_with_tag_mut(
|
||||
&mut self,
|
||||
tag_manager: &TagManager<u16>,
|
||||
tag: &StdString,
|
||||
|
@ -286,14 +286,14 @@ impl EntityManager {
|
|||
self.iter_component_managers_mut()
|
||||
.flat_map(move |c| c.iter_components_mut(entry))
|
||||
}
|
||||
pub fn get_in_radius(&self, pos: Vec2, radius: f32) -> impl Iterator<Item = &'static Entity> {
|
||||
pub fn iter_in_radius(&self, pos: Vec2, radius: f32) -> impl Iterator<Item = &'static Entity> {
|
||||
self.entities
|
||||
.as_ref()
|
||||
.iter()
|
||||
.filter_map(|e| unsafe { e.as_ref() })
|
||||
.filter(move |e| pos.abs2(&e.transform.pos) < radius * radius)
|
||||
}
|
||||
pub fn get_in_radius_with_tag(
|
||||
pub fn iter_in_radius_with_tag(
|
||||
&self,
|
||||
tag_manager: &TagManager<u16>,
|
||||
pos: Vec2,
|
||||
|
@ -311,7 +311,7 @@ impl EntityManager {
|
|||
.filter_map(|e| unsafe { e.as_ref() })
|
||||
.filter(move |e| pos.abs2(&e.transform.pos) < radius * radius)
|
||||
}
|
||||
pub fn get_in_radius_mut(
|
||||
pub fn iter_in_radius_mut(
|
||||
&mut self,
|
||||
pos: Vec2,
|
||||
radius: f32,
|
||||
|
@ -322,7 +322,7 @@ impl EntityManager {
|
|||
.filter_map(|e| unsafe { e.as_mut() })
|
||||
.filter(move |e| pos.abs2(&e.transform.pos) < radius * radius)
|
||||
}
|
||||
pub fn get_in_radius_with_tag_mut(
|
||||
pub fn iter_in_radius_with_tag_mut(
|
||||
&mut self,
|
||||
tag_manager: &TagManager<u16>,
|
||||
pos: Vec2,
|
||||
|
@ -447,7 +447,7 @@ pub struct Entity {
|
|||
pub id: usize,
|
||||
pub entry: usize,
|
||||
pub filename_index: usize,
|
||||
pub kill_flag: isize,
|
||||
pub kill_flag: usize,
|
||||
unknown1: isize,
|
||||
pub name: StdString,
|
||||
unknown2: isize,
|
||||
|
@ -695,13 +695,13 @@ pub struct Inventory {
|
|||
unk7b2: bool,
|
||||
unk7b3: bool,
|
||||
padding: u8,
|
||||
pub item_near: isize,
|
||||
pub item_near: usize,
|
||||
unk9b1: bool,
|
||||
unk9b2: bool,
|
||||
unk9b3: bool,
|
||||
padding2: u8,
|
||||
unk10: [*mut isize; 3],
|
||||
pub pickup_state: isize,
|
||||
pub pickup_state: usize,
|
||||
pub wand_pickup: *mut Entity,
|
||||
unk14: isize,
|
||||
unk15: [*mut [isize; 18]; 3],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue