il2cpp_bridge_rs/structs/components/animation/
animator.rs1use crate::structs::components::Transform;
3use crate::structs::components::{Component, ComponentTrait};
4use std::ffi::c_void;
5use std::ops::Deref;
6
7#[repr(i32)]
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum HumanBodyBones {
10 Hips = 0,
11 LeftUpperLeg = 1,
12 RightUpperLeg = 2,
13 LeftLowerLeg = 3,
14 RightLowerLeg = 4,
15 LeftFoot = 5,
16 RightFoot = 6,
17 Spine = 7,
18 Chest = 8,
19 UpperChest = 54,
20 Neck = 9,
21 Head = 10,
22 LeftShoulder = 11,
23 RightShoulder = 12,
24 LeftUpperArm = 13,
25 RightUpperArm = 14,
26 LeftLowerArm = 15,
27 RightLowerArm = 16,
28 LeftHand = 17,
29 RightHand = 18,
30 LeftToes = 19,
31 RightToes = 20,
32 LeftEye = 21,
33 RightEye = 22,
34 Jaw = 23,
35 LeftThumbProximal = 24,
36 LeftThumbIntermediate = 25,
37 LeftThumbDistal = 26,
38 LeftIndexProximal = 27,
39 LeftIndexIntermediate = 28,
40 LeftIndexDistal = 29,
41 LeftMiddleProximal = 30,
42 LeftMiddleIntermediate = 31,
43 LeftMiddleDistal = 32,
44 LeftRingProximal = 33,
45 LeftRingIntermediate = 34,
46 LeftRingDistal = 35,
47 LeftLittleProximal = 36,
48 LeftLittleIntermediate = 37,
49 LeftLittleDistal = 38,
50 RightThumbProximal = 39,
51 RightThumbIntermediate = 40,
52 RightThumbDistal = 41,
53 RightIndexProximal = 42,
54 RightIndexIntermediate = 43,
55 RightIndexDistal = 44,
56 RightMiddleProximal = 45,
57 RightMiddleIntermediate = 46,
58 RightMiddleDistal = 47,
59 RightRingProximal = 48,
60 RightRingIntermediate = 49,
61 RightRingDistal = 50,
62 RightLittleProximal = 51,
63 RightLittleIntermediate = 52,
64 RightLittleDistal = 53,
65 LastBone = 55,
66}
67
68#[repr(C)]
69#[derive(Debug, Clone, Copy)]
70pub struct Animator {
71 pub component: Component,
73}
74
75impl ComponentTrait for Animator {
76 fn from_ptr(ptr: *mut c_void) -> Self {
77 Self {
78 component: Component::from_ptr(ptr),
79 }
80 }
81}
82
83impl Deref for Animator {
84 type Target = Component;
85 fn deref(&self) -> &Self::Target {
86 &self.component
87 }
88}
89
90impl Animator {
91 pub fn get_bone_transform(&self, bone: HumanBodyBones) -> Result<Transform, String> {
99 let bone_id = bone as i32;
100 unsafe {
101 let ptr = self
102 .method("GetBoneTransform")
103 .ok_or("Method 'GetBoneTransform' not found")?
104 .call::<*mut c_void>(&[&bone_id as *const i32 as *mut c_void])?;
105
106 if ptr.is_null() {
107 return Err("Bone transform is null".to_string());
108 }
109
110 Ok(Transform::from_ptr(ptr))
111 }
112 }
113}