commonlibsse_ng\re\e/
ExtraCharge.rs

1use crate::re::BSExtraData::DerivedBSExtraData;
2use crate::re::offsets_rtti::RTTI_ExtraCharge;
3use crate::re::offsets_vtable::VTABLE_ExtraCharge;
4use crate::re::{BSExtraData::BSExtraData, ExtraDataType::ExtraDataType};
5use crate::rel::id::VariantID;
6
7#[repr(C)]
8#[derive(Debug, PartialEq)]
9pub struct ExtraCharge {
10    pub __base: BSExtraData,
11
12    /// - Offset: `0x10`
13    pub charge: f32,
14
15    /// - Offset: `0x14`
16    pub pad14: u32,
17}
18
19const _: () = {
20    assert!(core::mem::offset_of!(ExtraCharge, __base) == 0x0);
21    assert!(core::mem::offset_of!(ExtraCharge, charge) == 0x10);
22    assert!(core::mem::offset_of!(ExtraCharge, pad14) == 0x14);
23    assert!(core::mem::size_of::<ExtraCharge>() == 0x18);
24};
25
26impl Default for ExtraCharge {
27    #[inline]
28    fn default() -> Self {
29        Self::new()
30    }
31}
32
33impl DerivedBSExtraData for ExtraCharge {
34    #[inline]
35    fn get_extra_data(&self) -> &BSExtraData {
36        &self.__base
37    }
38
39    #[inline]
40    fn get_extra_data_type() -> ExtraDataType {
41        Self::EXTRA_DATA_TYPE
42    }
43}
44
45impl ExtraCharge {
46    /// Address & Offset of the runtime type information (RTTI) identifier.
47    pub const RTTI: VariantID = RTTI_ExtraCharge;
48
49    /// Address & Offset of the virtual function table.
50    pub const VTABLE: [VariantID; 1] = VTABLE_ExtraCharge;
51
52    /// The `ExtraDataType` value for ash pile references.
53    pub const EXTRA_DATA_TYPE: ExtraDataType = ExtraDataType::Charge;
54
55    /// Creates a new `ExtraCharge` instance with default values.
56    #[inline]
57    pub const fn new() -> Self {
58        Self { __base: BSExtraData::new(), charge: 0.0, pad14: 0 }
59    }
60
61    /// Retrieves the extra data type, always returning `ExtraDataType::kCharge`.
62    ///
63    /// # Returns
64    /// - `ExtraDataType::kCharge`
65    #[inline]
66    pub const fn get_type(&self) -> ExtraDataType {
67        ExtraDataType::Charge
68    }
69}
70
71/// The virtual function table for `ExtraCharge`.
72///
73/// This struct defines function pointers to simulate the C++ virtual functions.
74#[repr(C)]
75pub struct ExtraChargeVtbl {
76    /// Destructor function pointer.
77    pub CxxDrop: fn(this: &mut ExtraCharge),
78
79    /// Function pointer for retrieving the extra data type.
80    pub GetType: fn(this: &ExtraCharge) -> ExtraDataType,
81
82    /// Function pointer for equality check.
83    pub IsNotEqual: fn(this: &ExtraCharge, rhs: &ExtraCharge) -> bool,
84}
85
86impl Default for ExtraChargeVtbl {
87    #[inline]
88    fn default() -> Self {
89        Self::new()
90    }
91}
92
93impl ExtraChargeVtbl {
94    /// Creates a new default virtual table with stubbed functions.
95    #[inline]
96    pub const fn new() -> Self {
97        const fn CxxDrop(_this: &mut ExtraCharge) {}
98
99        const fn GetType(_this: &ExtraCharge) -> ExtraDataType {
100            ExtraCharge::EXTRA_DATA_TYPE
101        }
102
103        const fn IsNotEqual(_this: &ExtraCharge, _rhs: &ExtraCharge) -> bool {
104            false
105        }
106
107        Self { CxxDrop, GetType, IsNotEqual }
108    }
109}