spring_ai_rs/ai_interface/callback/drawer/
mod.rs1use spring_ai_sys::COMMAND_TO_ID_ENGINE;
2
3use crate::ai_interface::callback::{
4 command::{
5 command_data::{
6 drawer::{AddNotificationDrawerCommandData, DrawUnitDrawerCommandData},
7 CommandData,
8 },
9 command_topic::CommandTopic,
10 },
11 engine::handle_command,
12 facing::Facing,
13};
14
15pub mod debug;
16pub mod figure;
17pub mod line;
18pub mod path;
19pub mod point;
20
21pub struct Drawer {
22 pub ai_id: i32,
23}
24
25impl Drawer {
26 pub fn add_notification(
27 &self,
28 position: [f32; 3],
29 color: [i16; 3],
30 alpha: i16,
31 ) -> Result<(), String> {
32 let mut command_c_data = AddNotificationDrawerCommandData {
33 position,
34 color,
35 alpha,
36 }
37 .c_data();
38
39 handle_command(
40 self.ai_id,
41 COMMAND_TO_ID_ENGINE,
42 -1,
43 CommandTopic::DrawerAddNotification.into(),
44 &mut command_c_data,
45 )?;
46
47 Ok(())
48 }
49
50 pub fn draw_unit(
51 &self,
52 draw_unit_def_id: i32,
53 position: [f32; 3],
54 rotation: f32,
55 lifetime: i32,
56 team_id: i32,
57 transparent: bool,
58 draw_border: bool,
59 facing: Facing,
60 ) -> Result<(), String> {
61 let mut command_c_data = DrawUnitDrawerCommandData {
62 draw_unit_def_id,
63 position,
64 rotation,
65 lifetime,
66 team_id,
67 transparent,
68 draw_border,
69 facing,
70 }
71 .c_data();
72
73 handle_command(
74 self.ai_id,
75 COMMAND_TO_ID_ENGINE,
76 -1,
77 CommandTopic::DrawerDrawUnit.into(),
78 &mut command_c_data,
79 )?;
80
81 Ok(())
82 }
83}