dora_ssr/dora/platformer/
bullet.rs1extern "C" {
10 fn platformer_bullet_type() -> i32;
11 fn platformer_bullet_set_target_allow(slf: i64, val: i32);
12 fn platformer_bullet_get_target_allow(slf: i64) -> i32;
13 fn platformer_bullet_is_face_right(slf: i64) -> i32;
14 fn platformer_bullet_set_hit_stop(slf: i64, val: i32);
15 fn platformer_bullet_is_hit_stop(slf: i64) -> i32;
16 fn platformer_bullet_get_emitter(slf: i64) -> i64;
17 fn platformer_bullet_get_bullet_def(slf: i64) -> i64;
18 fn platformer_bullet_set_face(slf: i64, val: i64);
19 fn platformer_bullet_get_face(slf: i64) -> i64;
20 fn platformer_bullet_destroy(slf: i64);
21 fn platformer_bullet_new(def: i64, owner: i64) -> i64;
22}
23use crate::dora::IObject;
24use crate::dora::IBody;
25impl IBody for Bullet { }
26use crate::dora::INode;
27impl INode for Bullet { }
28pub struct Bullet { raw: i64 }
30crate::dora_object!(Bullet);
31impl Bullet {
32 pub(crate) fn type_info() -> (i32, fn(i64) -> Option<Box<dyn IObject>>) {
33 (unsafe { platformer_bullet_type() }, |raw: i64| -> Option<Box<dyn IObject>> {
34 match raw {
35 0 => None,
36 _ => Some(Box::new(Bullet { raw: raw }))
37 }
38 })
39 }
40 pub fn set_target_allow(&mut self, val: i32) {
42 unsafe { platformer_bullet_set_target_allow(self.raw(), val) };
43 }
44 pub fn get_target_allow(&self) -> i32 {
46 return unsafe { platformer_bullet_get_target_allow(self.raw()) };
47 }
48 pub fn is_face_right(&self) -> bool {
50 return unsafe { platformer_bullet_is_face_right(self.raw()) != 0 };
51 }
52 pub fn set_hit_stop(&mut self, val: bool) {
54 unsafe { platformer_bullet_set_hit_stop(self.raw(), if val { 1 } else { 0 }) };
55 }
56 pub fn is_hit_stop(&self) -> bool {
58 return unsafe { platformer_bullet_is_hit_stop(self.raw()) != 0 };
59 }
60 pub fn get_emitter(&self) -> crate::dora::platformer::Unit {
62 return unsafe { crate::dora::platformer::Unit::from(platformer_bullet_get_emitter(self.raw())).unwrap() };
63 }
64 pub fn get_bullet_def(&self) -> crate::dora::platformer::BulletDef {
66 return unsafe { crate::dora::platformer::BulletDef::from(platformer_bullet_get_bullet_def(self.raw())).unwrap() };
67 }
68 pub fn set_face(&mut self, val: &dyn crate::dora::INode) {
70 unsafe { platformer_bullet_set_face(self.raw(), val.raw()) };
71 }
72 pub fn get_face(&self) -> crate::dora::Node {
74 return unsafe { crate::dora::Node::from(platformer_bullet_get_face(self.raw())).unwrap() };
75 }
76 pub fn destroy(&mut self) {
78 unsafe { platformer_bullet_destroy(self.raw()); }
79 }
80 pub fn new(def: &crate::dora::platformer::BulletDef, owner: &crate::dora::platformer::Unit) -> Bullet {
91 unsafe { return Bullet { raw: platformer_bullet_new(def.raw(), owner.raw()) }; }
92 }
93}