omp_gdk/scripting/objects/
functions.rs

1use omp_codegen::native;
2use std::ffi::c_void;
3
4use crate::{players::Player, vehicles::Vehicle};
5
6use super::{Object, PlayerObject};
7
8native!(Object_Create, modelid: i32, x: f32, y: f32, z: f32, rotationX: f32, rotationY: f32, rotationZ: f32, drawDistance: f32, id: mut i32, -> struct Object);
9native!(Object_Destroy, object: struct Object, -> bool);
10native!(Object_FromID, objectid: i32, -> struct Object);
11native!(Object_GetID, object: struct Object, -> i32);
12native!(Object_AttachToVehicle, object: struct Object, vehicle: struct Vehicle, offsetX: f32, offsetY: f32, offsetZ: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
13native!(Object_AttachToObject, object: struct Object, objAttachedTo: struct Object, offsetX: f32, offsetY: f32, offsetZ: f32, rotationX: f32, rotationY: f32, rotationZ: f32, syncRotation: bool, -> bool);
14native!(Object_AttachToPlayer, object: struct Object, player: struct Player, offsetX: f32, offsetY: f32, offsetZ: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
15native!(Object_SetPos, object: struct Object, x: f32, y: f32, z: f32, -> bool);
16native!(Object_GetPos, object: struct Object, x: mut f32, y: mut f32, z: mut f32, -> bool);
17native!(Object_SetRot, object: struct Object, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
18native!(Object_GetRot, object: struct Object, rotationX: mut f32, rotationY: mut f32, rotationZ: mut f32, -> bool);
19native!(Object_GetModel, object: struct Object, -> i32);
20native!(Object_SetNoCameraCollision, object: struct Object, -> bool);
21native!(Object_IsValid, object: struct Object, -> bool);
22native!(Object_Move, object: struct Object, x: f32, y: f32, z: f32, speed: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> i32);
23native!(Object_Stop, object: struct Object, -> bool);
24native!(Object_IsMoving, object: struct Object, -> bool);
25native!(Object_BeginEditing, player: struct Player, object: struct Object, -> bool);
26native!(Object_BeginSelecting, player: struct Player, -> bool);
27native!(Object_EndEditing, player: struct Player, -> bool);
28native!(Object_SetMaterial, object: struct Object, materialIndex: i32, modelId: i32, textureLibrary: str, textureName: str, materialColor: u32, -> bool);
29native!(Object_SetMaterialText, object: struct Object, text: str, materialIndex: i32, materialSize: i32, fontface: str, fontsize: i32, bold: bool, fontColor: u32, backgroundColor: u32, textalignment: i32, -> bool);
30native!(Object_SetDefaultCameraCollision, disable: bool, -> bool);
31native!(Object_GetDrawDistance, object: struct Object, -> f32);
32native!(Object_GetMoveSpeed, object: struct Object, -> f32);
33native!(Object_GetMovingTargetPos, object: struct Object, targetX: mut f32, targetY: mut f32, targetZ: mut f32, -> bool);
34native!(Object_GetMovingTargetRot, object: struct Object, rotationX: mut f32, rotationY: mut f32, rotationZ: mut f32, -> bool);
35native!(Object_GetAttachedData, object: struct Object, parentVehicle: mut i32, parentObject: mut i32, parentPlayer: mut i32, -> bool);
36native!(Object_GetAttachedOffset, object: struct Object, offsetX: mut f32, offsetY: mut f32, offsetZ: mut f32, rotationX: mut f32, rotationY: mut f32, rotationZ: mut f32, -> bool);
37native!(Object_GetSyncRotation, object: struct Object, -> bool);
38native!(Object_IsMaterialSlotUsed, object: struct Object, materialIndex: i32, -> bool);
39native!(Object_GetMaterial, object: struct Object, materialIndex: i32, modelid: mut i32, textureLibrary: mut str, textureLibrary_len: usize, textureName: mut str, textureName_len: usize, materialColor: mut i32, -> bool);
40native!(Object_GetMaterialText, object: struct Object, materialIndex: i32, text: mut str, text_len: usize, materialSize: mut i32, fontFace: mut str, fontFace_len: usize, fontSize: mut i32, bold: mut bool, fontColor: mut i32, backgroundColor: mut i32, textAlignment: mut i32, -> bool);
41native!(Object_IsObjectNoCameraCollision, object: struct Object, -> bool);
42native!(Object_GetType, player: struct Player, objectid: i32, -> u8);
43
44// player object functions
45
46native!(PlayerObject_Create, player: struct Player, modelid: i32, x: f32, y: f32, z: f32, rotationX: f32, rotationY: f32, rotationZ: f32, drawDistance: f32, id: mut i32, -> struct PlayerObject);
47native!(PlayerObject_Destroy, player: struct Player, object: struct PlayerObject, -> bool);
48native!(PlayerObject_AttachToVehicle, player: struct Player, object: struct PlayerObject, vehicle: struct Vehicle, offsetX: f32, offsetY: f32, offsetZ: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
49native!(PlayerObject_AttachToPlayer, player: struct Player, object: struct PlayerObject, playerAttachedTo: struct Player, offsetX: f32, offsetY: f32, offsetZ: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
50native!(PlayerObject_AttachToObject, player: struct Player, object: struct PlayerObject, attachedTo: struct PlayerObject, offsetX: f32, offsetY: f32, offsetZ: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
51native!(PlayerObject_SetPos, player: struct Player, object: struct PlayerObject, x: f32, y: f32, z: f32, -> bool);
52native!(PlayerObject_GetPos, player: struct Player, object: struct PlayerObject, x: mut f32, y: mut f32, z: mut f32, -> bool);
53native!(PlayerObject_SetRot, player: struct Player, object: struct PlayerObject, rotationX: f32, rotationY: f32, rotationZ: f32, -> bool);
54native!(PlayerObject_GetRot, player: struct Player, object: struct PlayerObject, rotationX: mut f32, rotationY: mut f32, rotationZ: mut f32, -> bool);
55native!(PlayerObject_GetModel, player: struct Player, object: struct PlayerObject, -> i32);
56native!(PlayerObject_SetNoCameraCollision, player: struct Player, object: struct PlayerObject, -> bool);
57native!(PlayerObject_IsValid, player: struct Player, object: struct PlayerObject, -> bool);
58native!(PlayerObject_Move, player: struct Player, object: struct PlayerObject, x: f32, y: f32, z: f32, speed: f32, rotationX: f32, rotationY: f32, rotationZ: f32, -> i32);
59native!(PlayerObject_Stop, player: struct Player, object: struct PlayerObject, -> bool);
60native!(PlayerObject_IsMoving, player: struct Player, object: struct PlayerObject, -> bool);
61native!(PlayerObject_BeginEditing, player: struct Player, object: struct PlayerObject, -> bool);
62native!(PlayerObject_SetMaterial, player: struct Player, object: struct PlayerObject, materialIndex: i32, modelId: i32, textureLibrary: str, textureName: str, materialColor: u32, -> bool);
63native!(PlayerObject_SetMaterialText, player: struct Player, object: struct PlayerObject, text: str, materialIndex: i32, materialSize: i32, fontface: str, fontsize: i32, bold: bool, fontColor: u32, backgroundColor: u32, textalignment: i32, -> bool);
64native!(PlayerObject_GetDrawDistance, player: struct Player, object: struct PlayerObject, -> f32);
65native!(PlayerObject_GetMoveSpeed, player: struct Player, object: struct PlayerObject, -> f32);
66native!(PlayerObject_GetMovingTargetPos, player: struct Player, object: struct PlayerObject, targetX: mut f32, targetY: mut f32, targetZ: mut f32, -> bool);
67native!(PlayerObject_GetMovingTargetRot, player: struct Player, object: struct PlayerObject, rotationX: mut f32, rotationY: mut f32, rotationZ: mut f32, -> bool);
68native!(PlayerObject_GetAttachedData, player: struct Player, object: struct PlayerObject, parentVehicle: mut i32, parentObject: mut i32, parentPlayer: mut i32, -> bool);
69native!(PlayerObject_GetAttachedOffset, player: struct Player, object: struct PlayerObject, offsetX: mut f32, offsetY: mut f32, offsetZ: mut f32, rotationX: mut f32, rotationY: mut f32, rotationZ: mut f32, -> bool);
70native!(PlayerObject_GetSyncRotation, player: struct Player, object: struct PlayerObject, -> bool);
71native!(PlayerObject_IsMaterialSlotUsed, player: struct Player, object: struct PlayerObject, materialIndex: i32, -> bool);
72native!(PlayerObject_GetMaterial, player: struct Player, object: struct PlayerObject, materialIndex: i32, modelid: mut i32, textureLibrary: mut str,textureLibrary_len: usize, textureName: mut str, textureName_len: usize, materialColor: mut i32, -> bool);
73native!(PlayerObject_GetMaterialText, player: struct Player, object: struct PlayerObject, materialIndex: i32, text: mut str, text_len: usize, materialSize: mut i32, fontFace: mut str, fontFace_len: usize, fontSize: mut i32, bold: mut bool, fontColor: mut i32, backgroundColor: mut i32, textAlignment: mut i32, -> bool);
74native!(PlayerObject_IsNoCameraCollision, player: struct Player, object: struct PlayerObject, -> bool);
75native!(PlayerObject_FromID, player: struct Player,objectid: i32, -> struct PlayerObject);
76native!(PlayerObject_GetID, player: struct Player, object: struct PlayerObject, -> i32);
77
78#[doc(hidden)]
79pub fn load_functions() {
80    load_function!(Object_Create);
81    load_function!(Object_Destroy);
82    load_function!(Object_FromID);
83    load_function!(Object_GetID);
84    load_function!(Object_AttachToVehicle);
85    load_function!(Object_AttachToObject);
86    load_function!(Object_AttachToPlayer);
87    load_function!(Object_SetPos);
88    load_function!(Object_GetPos);
89    load_function!(Object_SetRot);
90    load_function!(Object_GetRot);
91    load_function!(Object_GetModel);
92    load_function!(Object_SetNoCameraCollision);
93    load_function!(Object_IsValid);
94    load_function!(Object_Move);
95    load_function!(Object_Stop);
96    load_function!(Object_IsMoving);
97    load_function!(Object_BeginEditing);
98    load_function!(Object_BeginSelecting);
99    load_function!(Object_EndEditing);
100    load_function!(Object_SetMaterial);
101    load_function!(Object_SetMaterialText);
102    load_function!(Object_SetDefaultCameraCollision);
103    load_function!(Object_GetDrawDistance);
104    load_function!(Object_GetMoveSpeed);
105    load_function!(Object_GetMovingTargetPos);
106    load_function!(Object_GetMovingTargetRot);
107    load_function!(Object_GetAttachedData);
108    load_function!(Object_GetAttachedOffset);
109    load_function!(Object_GetSyncRotation);
110    load_function!(Object_IsMaterialSlotUsed);
111    load_function!(Object_GetMaterial);
112    load_function!(Object_GetMaterialText);
113    load_function!(Object_IsObjectNoCameraCollision);
114    load_function!(Object_GetType);
115
116    // player object functions
117
118    load_function!(PlayerObject_Create);
119    load_function!(PlayerObject_Destroy);
120    load_function!(PlayerObject_AttachToVehicle);
121    load_function!(PlayerObject_AttachToPlayer);
122    load_function!(PlayerObject_AttachToObject);
123    load_function!(PlayerObject_SetPos);
124    load_function!(PlayerObject_GetPos);
125    load_function!(PlayerObject_SetRot);
126    load_function!(PlayerObject_GetRot);
127    load_function!(PlayerObject_GetModel);
128    load_function!(PlayerObject_SetNoCameraCollision);
129    load_function!(PlayerObject_IsValid);
130    load_function!(PlayerObject_Move);
131    load_function!(PlayerObject_Stop);
132    load_function!(PlayerObject_IsMoving);
133    load_function!(PlayerObject_BeginEditing);
134    load_function!(PlayerObject_SetMaterial);
135    load_function!(PlayerObject_SetMaterialText);
136    load_function!(PlayerObject_GetDrawDistance);
137    load_function!(PlayerObject_GetMoveSpeed);
138    load_function!(PlayerObject_GetMovingTargetPos);
139    load_function!(PlayerObject_GetMovingTargetRot);
140    load_function!(PlayerObject_GetAttachedData);
141    load_function!(PlayerObject_GetAttachedOffset);
142    load_function!(PlayerObject_GetSyncRotation);
143    load_function!(PlayerObject_IsMaterialSlotUsed);
144    load_function!(PlayerObject_GetMaterial);
145    load_function!(PlayerObject_GetMaterialText);
146    load_function!(PlayerObject_IsNoCameraCollision);
147}