spring_ai_rs/ai_interface/callback/game_mod/
construction_decay.rs1use std::error::Error;
2
3use crate::get_callback;
4
5#[derive(Debug, Copy, Clone)]
6pub struct GameModConstructionDecay {
7 pub ai_id: i32,
8}
9
10#[derive(Debug, Copy, Clone)]
11pub struct GameModConstructionDecayAll {
12 is_enabled: bool,
13 delay: i32,
14 speed: f32,
15}
16
17impl GameModConstructionDecay {
18 pub fn is_enabled(&self) -> Result<bool, Box<dyn Error>> {
19 let get_construction_decay = get_callback!(self.ai_id, Mod_getConstructionDecay)?;
20
21 Ok(unsafe { get_construction_decay(self.ai_id) })
22 }
23
24 pub fn delay(&self) -> Result<i32, Box<dyn Error>> {
25 let get_construction_decay_time = get_callback!(self.ai_id, Mod_getConstructionDecayTime)?;
26
27 Ok(unsafe { get_construction_decay_time(self.ai_id) })
28 }
29
30 pub fn speed(&self) -> Result<f32, Box<dyn Error>> {
31 let get_construction_decay_speed =
32 get_callback!(self.ai_id, Mod_getConstructionDecaySpeed)?;
33
34 Ok(unsafe { get_construction_decay_speed(self.ai_id) })
35 }
36
37 pub fn all(&self) -> Result<GameModConstructionDecayAll, Box<dyn Error>> {
38 Ok(GameModConstructionDecayAll {
39 is_enabled: self.is_enabled()?,
40 delay: self.delay()?,
41 speed: self.speed()?,
42 })
43 }
44}