commonlibsse_ng\re\b/
bhkSerializable.rs

1//! # bhkSerializable
2//!
3//! This module defines the `bhkSerializable` struct, which inherits from `bhkRefObject`
4//! and represents a serializable object in the physics world. It includes virtual function pointers
5//! for C++ compatibility and maintains the original memory layout.
6
7use core::ffi::c_void;
8
9use crate::re::bhkRefObject::{bhkRefObject, bhkRefObjectVtbl};
10use crate::re::bhkWorld::bhkWorld;
11use crate::re::offsets_ni_rtti::NiRTTI_bhkSerializable;
12use crate::re::offsets_rtti::RTTI_bhkSerializable;
13use crate::re::offsets_vtable::VTABLE_bhkSerializable;
14use crate::re::{ahkpWorld, hkpWorld};
15use crate::rel::id::VariantID;
16
17/// Represents a serializable object in the physics world.
18/// Inherits from `bhkRefObject`.
19///
20/// # Memory Layout:
21/// - `__base`: Base class `bhkRefObject`
22/// - `serializable`: Pointer to another `bhkSerializable`
23///
24#[repr(C)]
25#[derive(Debug)]
26pub struct bhkSerializable {
27    /// Base class `bhkRefObject`.
28    pub __base: bhkRefObject,
29
30    /// Pointer to another `bhkSerializable`.
31    pub serializable: *mut bhkSerializable,
32}
33
34const _: () = {
35    assert!(core::mem::offset_of!(bhkSerializable, __base) == 0x0);
36    assert!(core::mem::offset_of!(bhkSerializable, serializable) == 0x18);
37    assert!(core::mem::size_of::<bhkSerializable>() == 0x20);
38};
39
40impl bhkSerializable {
41    /// Address & Offset of the runtime type information (RTTI) identifier.
42    pub const RTTI: VariantID = RTTI_bhkSerializable;
43    /// Address & Offset of the runtime type information (Ni RTTI) identifier.
44    pub const NI_RTTI: VariantID = NiRTTI_bhkSerializable;
45
46    /// Address & Offset of the virtual function table.
47    pub const VTABLE: [VariantID; 1] = VTABLE_bhkSerializable;
48}
49
50/// The virtual function table for `bhkSerializable`.
51///
52/// This struct defines function pointers to simulate the C++ virtual functions.
53#[repr(C)]
54pub struct bhkSerializableVtbl {
55    pub __base: bhkRefObjectVtbl,
56
57    /// - bhkSerializable: return 0
58    GetWorld1: fn(this: *mut c_void) -> *mut hkpWorld,
59    GetWorld2: fn(this: *mut c_void) -> *mut ahkpWorld,
60    MoveToWorld: fn(*mut c_void, world: *mut bhkWorld),
61    RemoveFromCurrentWorld: unsafe fn(this: *mut c_void),
62    Unk_2B: fn(this: *mut c_void, *mut c_void),
63    Unk_2C: fn(this: *mut c_void, *mut c_void), // return 1
64    Unk_2D: fn(this: *mut c_void, *mut c_void),
65    Unk_2E: fn(this: *mut c_void, *mut c_void), // pure virtual
66    Unk_2F: fn(this: *mut c_void, *mut c_void), // pure virtual
67    Unk_30: fn(this: *mut c_void, *mut c_void),
68    Unk_31: fn(this: *mut c_void, *mut c_void),
69}