commonlibsse_ng\re\b/
BSAnimationGraphChannel.rs

1use crate::re::BSFixedString::BSFixedString;
2use crate::re::BSIntrusiveRefCounted::BSIntrusiveRefCounted;
3use crate::re::offsets_rtti::RTTI_BSAnimationGraphChannel;
4use crate::re::offsets_vtable::VTABLE_BSAnimationGraphChannel;
5use crate::rel::id::VariantID;
6
7use super::BSIntrusiveRefCounted::BSIntrusiveRefCountedTrait;
8
9#[repr(C)]
10#[derive(Debug)]
11pub struct BSAnimationGraphChannel {
12    /// NOTE:
13    /// If the parent does not have a virtual function even if base is inherited, vtable comes before the
14    /// inherited parent member if the child has a virtual function.
15    /// - See [playground](https://godbolt.org/z/96rGaTG4e)
16    pub vtable: *const BSAnimationGraphChannelVtbl,
17
18    /// Base class `BSIntrusiveRefCounted`.
19    pub __base: BSIntrusiveRefCounted,
20
21    /// Padding for alignment.
22    pub pad0C: u32,
23
24    /// Channel name.
25    pub channelName: BSFixedString,
26
27    /// Value associated with the channel.
28    pub value: u32,
29
30    /// Padding for alignment.
31    pub pad1C: u32,
32}
33
34const _: () = {
35    assert!(core::mem::offset_of!(BSAnimationGraphChannel, __base) == 0x8);
36    assert!(core::mem::offset_of!(BSAnimationGraphChannel, pad0C) == 0x0C);
37    assert!(core::mem::offset_of!(BSAnimationGraphChannel, channelName) == 0x10);
38    assert!(core::mem::offset_of!(BSAnimationGraphChannel, value) == 0x18);
39    assert!(core::mem::offset_of!(BSAnimationGraphChannel, pad1C) == 0x1C);
40    assert!(core::mem::size_of::<BSAnimationGraphChannel>() == 0x20);
41};
42
43impl BSIntrusiveRefCountedTrait for BSAnimationGraphChannel {
44    #[inline]
45    fn inc_ref(&self) -> u32 {
46        self.__base.inc_ref()
47    }
48
49    #[inline]
50    fn dec_ref(&self) -> u32 {
51        self.__base.dec_ref()
52    }
53}
54
55impl Default for BSAnimationGraphChannel {
56    #[inline]
57    fn default() -> Self {
58        Self {
59            vtable: &BS_ANIMATION_GRAPH_CHANNEL_VTBL,
60            __base: BSIntrusiveRefCounted::default(),
61            pad0C: 0,
62            channelName: BSFixedString::default(),
63            value: 0,
64            pad1C: 0,
65        }
66    }
67}
68
69impl BSAnimationGraphChannel {
70    /// Address & offset of the runtime type information (RTTI) identifier.
71    pub const RTTI: VariantID = RTTI_BSAnimationGraphChannel;
72
73    /// Address & offset of the virtual function table.
74    pub const VTABLE: [VariantID; 1] = VTABLE_BSAnimationGraphChannel;
75
76    /// Virtual function to poll channel update (abstract function in C++).
77    pub const fn poll_channel_update_impl(&self, _a_arg1: bool) {
78        // Implementation in derived classes.
79    }
80
81    /// Virtual function to reset the channel (abstract function in C++).
82    pub const fn reset_impl(&self) {
83        // Implementation in derived classes.
84    }
85}
86
87/// The virtual function table for `BSAnimationGraphChannel`.
88///
89/// This struct defines function pointers to simulate the C++ virtual functions.
90#[repr(C)]
91#[derive(Debug)]
92pub struct BSAnimationGraphChannelVtbl {
93    /// Destructor function pointer.
94    pub CxxDrop: fn(this: &mut BSAnimationGraphChannel),
95
96    /// Function pointer for polling channel update.
97    pub PollChannelUpdateImpl: fn(this: &BSAnimationGraphChannel, a_arg1: bool),
98
99    /// Function pointer for resetting the channel.
100    pub ResetImpl: fn(this: &BSAnimationGraphChannel),
101}
102
103impl Default for BSAnimationGraphChannelVtbl {
104    #[inline]
105    fn default() -> Self {
106        Self::new()
107    }
108}
109
110impl BSAnimationGraphChannelVtbl {
111    /// Creates a new default virtual table with stubbed functions.
112    pub const fn new() -> Self {
113        const fn CxxDrop(_this: &mut BSAnimationGraphChannel) {}
114
115        const fn PollChannelUpdateImpl(_this: &BSAnimationGraphChannel, _a_arg1: bool) {}
116
117        const fn ResetImpl(_this: &BSAnimationGraphChannel) {}
118
119        Self { CxxDrop, PollChannelUpdateImpl, ResetImpl }
120    }
121}
122static BS_ANIMATION_GRAPH_CHANNEL_VTBL: BSAnimationGraphChannelVtbl =
123    BSAnimationGraphChannelVtbl::new();