spring_ai_rs/ai_interface/callback/weapon_def/
bounce.rs1use std::error::Error;
2
3use crate::get_callback;
4
5#[derive(Debug, Copy, Clone)]
6pub struct WeaponBounce {
7 pub ai_id: i32,
8 pub weapon_def_id: i32,
9}
10
11#[derive(Debug, Copy, Clone)]
12pub struct WeaponBounceAll {
13 water: bool,
14 ground: bool,
15 rebound: f32,
16 slip: f32,
17 number_of_bounces: i32,
18}
19
20impl WeaponBounce {
21 pub fn water(&self) -> Result<bool, Box<dyn Error>> {
22 let get_water_bounce = get_callback!(self.ai_id, WeaponDef_isWaterBounce)?;
23 Ok(unsafe { get_water_bounce(self.ai_id, self.weapon_def_id) })
24 }
25
26 pub fn ground(&self) -> Result<bool, Box<dyn Error>> {
27 let get_ground_bounce = get_callback!(self.ai_id, WeaponDef_isGroundBounce)?;
28 Ok(unsafe { get_ground_bounce(self.ai_id, self.weapon_def_id) })
29 }
30
31 pub fn rebound(&self) -> Result<f32, Box<dyn Error>> {
32 let get_bounce_rebound = get_callback!(self.ai_id, WeaponDef_getBounceRebound)?;
33 Ok(unsafe { get_bounce_rebound(self.ai_id, self.weapon_def_id) })
34 }
35
36 pub fn slip(&self) -> Result<f32, Box<dyn Error>> {
37 let get_bounce_slip = get_callback!(self.ai_id, WeaponDef_getBounceSlip)?;
38 Ok(unsafe { get_bounce_slip(self.ai_id, self.weapon_def_id) })
39 }
40
41 pub fn number_of_bounces(&self) -> Result<i32, Box<dyn Error>> {
42 let get_number_of_bounces = get_callback!(self.ai_id, WeaponDef_getNumBounce)?;
43 Ok(unsafe { get_number_of_bounces(self.ai_id, self.weapon_def_id) })
44 }
45
46 pub fn all(&self) -> Result<WeaponBounceAll, Box<dyn Error>> {
47 Ok(WeaponBounceAll {
48 water: self.water()?,
49 ground: self.ground()?,
50 rebound: self.rebound()?,
51 slip: self.slip()?,
52 number_of_bounces: self.number_of_bounces()?,
53 })
54 }
55}