spring_ai_rs/ai_interface/callback/game_mod/
transport.rs

1use std::error::Error;
2
3use crate::get_callback;
4
5#[derive(Debug, Copy, Clone)]
6pub struct GameModTransport {
7    pub ai_id: i32,
8}
9
10#[derive(Debug, Copy, Clone)]
11pub struct GameModTransportAll {
12    ground: bool,
13    hover: bool,
14    ship: bool,
15    air: bool,
16}
17
18impl GameModTransport {
19    pub fn ground(&self) -> Result<bool, Box<dyn Error>> {
20        let get_transport_ground = get_callback!(self.ai_id, Mod_getTransportGround)?;
21
22        Ok(unsafe { get_transport_ground(self.ai_id) } == 1)
23    }
24
25    pub fn hover(&self) -> Result<bool, Box<dyn Error>> {
26        let get_transport_hover = get_callback!(self.ai_id, Mod_getTransportHover)?;
27
28        Ok(unsafe { get_transport_hover(self.ai_id) } == 1)
29    }
30
31    pub fn ship(&self) -> Result<bool, Box<dyn Error>> {
32        let get_transport_ship = get_callback!(self.ai_id, Mod_getTransportShip)?;
33
34        Ok(unsafe { get_transport_ship(self.ai_id) } == 1)
35    }
36
37    pub fn air(&self) -> Result<bool, Box<dyn Error>> {
38        let get_transport_air = get_callback!(self.ai_id, Mod_getTransportAir)?;
39
40        Ok(unsafe { get_transport_air(self.ai_id) } == 1)
41    }
42
43    pub fn all(&self) -> Result<GameModTransportAll, Box<dyn Error>> {
44        Ok(GameModTransportAll {
45            ground: self.ground()?,
46            hover: self.hover()?,
47            ship: self.ship()?,
48            air: self.air()?,
49        })
50    }
51}