spring_ai_rs/ai_interface/callback/command/command_data/
drawer.rs

1use std::ffi::CString;
2
3use spring_ai_sys::{
4    SAddLineDrawCommand, SAddNotificationDrawerCommand, SAddPointDrawCommand,
5    SBreakPathDrawerCommand, SCreateLineFigureDrawerCommand, SCreateSplineFigureDrawerCommand,
6    SDeleteFigureDrawerCommand, SDrawIconAtLastPosPathDrawerCommand,
7    SDrawLineAndIconPathDrawerCommand, SDrawLinePathDrawerCommand, SDrawUnitDrawerCommand,
8    SFinishPathDrawerCommand, SRemovePointDrawCommand, SRestartPathDrawerCommand,
9    SSetColorFigureDrawerCommand, SStartPathDrawerCommand,
10};
11
12use crate::ai_interface::callback::{
13    command::command_data::{CData, CommandData},
14    facing::Facing,
15};
16
17// Drawer Add Notification data
18pub struct AddNotificationDrawerCommandData {
19    pub position: [f32; 3],
20    pub color: [i16; 3],
21    pub alpha: i16,
22}
23
24impl CommandData for AddNotificationDrawerCommandData {
25    type CDataType = SAddNotificationDrawerCommand;
26
27    fn c_data(&mut self) -> Self::CDataType {
28        SAddNotificationDrawerCommand {
29            pos_posF3: self.position.as_mut_ptr(),
30            color_colorS3: self.color.as_mut_ptr(),
31            alpha: self.alpha,
32        }
33    }
34}
35
36impl CData for SAddNotificationDrawerCommand {}
37
38// Drawer Draw Unit data
39pub struct DrawUnitDrawerCommandData {
40    pub draw_unit_def_id: i32,
41    pub position: [f32; 3],
42    pub rotation: f32,
43    pub lifetime: i32,
44    pub team_id: i32,
45    pub transparent: bool,
46    pub draw_border: bool,
47    pub facing: Facing,
48}
49
50impl CommandData for DrawUnitDrawerCommandData {
51    type CDataType = SDrawUnitDrawerCommand;
52
53    fn c_data(&mut self) -> Self::CDataType {
54        SDrawUnitDrawerCommand {
55            toDrawUnitDefId: self.draw_unit_def_id,
56            pos_posF3: self.position.as_mut_ptr(),
57            rotation: self.rotation,
58            lifeTime: self.lifetime,
59            teamId: self.team_id,
60            transparent: self.transparent,
61            drawBorder: self.draw_border,
62            facing: self.facing.into(),
63        }
64    }
65}
66
67impl CData for SDrawUnitDrawerCommand {}
68
69// Drawer Figure Create Line data
70pub struct CreateLineFigureDrawerCommandData {
71    pub position_1: [f32; 3],
72    pub position_2: [f32; 3],
73    pub width: f32,
74    pub arrow: bool,
75    pub lifetime: i32,
76    pub figure_group_id: i32,
77}
78
79impl CommandData for CreateLineFigureDrawerCommandData {
80    type CDataType = SCreateLineFigureDrawerCommand;
81
82    fn c_data(&mut self) -> Self::CDataType {
83        SCreateLineFigureDrawerCommand {
84            pos1_posF3: self.position_1.as_mut_ptr(),
85            pos2_posF3: self.position_2.as_mut_ptr(),
86            width: self.width,
87            arrow: self.arrow,
88            lifeTime: self.lifetime,
89            figureGroupId: self.figure_group_id,
90            ret_newFigureGroupId: 0,
91        }
92    }
93}
94
95impl CData for SCreateLineFigureDrawerCommand {}
96
97// Drawer Figure Create Spline data
98pub struct CreateSplineFigureDrawerCommandData {
99    pub position_1: [f32; 3],
100    pub position_2: [f32; 3],
101    pub position_3: [f32; 3],
102    pub position_4: [f32; 3],
103    pub width: f32,
104    pub arrow: bool,
105    pub lifetime: i32,
106    pub figure_group_id: i32,
107}
108
109impl CommandData for CreateSplineFigureDrawerCommandData {
110    type CDataType = SCreateSplineFigureDrawerCommand;
111
112    fn c_data(&mut self) -> Self::CDataType {
113        SCreateSplineFigureDrawerCommand {
114            pos1_posF3: self.position_1.as_mut_ptr(),
115            pos2_posF3: self.position_2.as_mut_ptr(),
116            pos3_posF3: self.position_3.as_mut_ptr(),
117            pos4_posF3: self.position_4.as_mut_ptr(),
118            width: self.width,
119            arrow: self.arrow,
120            lifeTime: self.lifetime,
121            figureGroupId: self.figure_group_id,
122            ret_newFigureGroupId: 0,
123        }
124    }
125}
126
127impl CData for SCreateSplineFigureDrawerCommand {}
128
129// Drawer Figure Delete data
130pub struct DeleteFigureDrawerCommandData {
131    pub figure_group_id: i32,
132}
133
134impl CommandData for DeleteFigureDrawerCommandData {
135    type CDataType = SDeleteFigureDrawerCommand;
136
137    fn c_data(&mut self) -> Self::CDataType {
138        SDeleteFigureDrawerCommand {
139            figureGroupId: self.figure_group_id,
140        }
141    }
142}
143
144impl CData for SDeleteFigureDrawerCommand {}
145
146// Drawer Figure Set Color data
147pub struct SetColorFigureDrawerCommandData {
148    pub figure_group_id: i32,
149    pub color: [i16; 3],
150    pub alpha: i16,
151}
152
153impl CommandData for SetColorFigureDrawerCommandData {
154    type CDataType = SSetColorFigureDrawerCommand;
155
156    fn c_data(&mut self) -> Self::CDataType {
157        SSetColorFigureDrawerCommand {
158            figureGroupId: self.figure_group_id,
159            color_colorS3: self.color.as_mut_ptr(),
160            alpha: self.alpha,
161        }
162    }
163}
164
165impl CData for SSetColorFigureDrawerCommand {}
166
167// Drawer Add Line data
168pub struct AddLineDrawCommandData {
169    pub to: [f32; 3],
170    pub from: [f32; 3],
171}
172
173impl CommandData for AddLineDrawCommandData {
174    type CDataType = SAddLineDrawCommand;
175
176    fn c_data(&mut self) -> Self::CDataType {
177        SAddLineDrawCommand {
178            posFrom_posF3: self.from.as_mut_ptr(),
179            posTo_posF3: self.to.as_mut_ptr(),
180        }
181    }
182}
183
184impl CData for SAddLineDrawCommand {}
185
186// Drawer Break Path data
187pub struct BreakPathDrawerCommandData {
188    pub end_position: [f32; 3],
189    pub color: [i16; 3],
190    pub alpha: i16,
191}
192
193impl CommandData for BreakPathDrawerCommandData {
194    type CDataType = SBreakPathDrawerCommand;
195
196    fn c_data(&mut self) -> Self::CDataType {
197        SBreakPathDrawerCommand {
198            endPos_posF3: self.end_position.as_mut_ptr(),
199            color_colorS3: self.color.as_mut_ptr(),
200            alpha: self.alpha,
201        }
202    }
203}
204
205impl CData for SBreakPathDrawerCommand {}
206
207// Drawer Path Draw Icon at Last Position data
208pub struct DrawIconAtLastPosPathDrawerCommandData {
209    pub command_id: i32,
210}
211
212impl CommandData for DrawIconAtLastPosPathDrawerCommandData {
213    type CDataType = SDrawIconAtLastPosPathDrawerCommand;
214
215    fn c_data(&mut self) -> Self::CDataType {
216        SDrawIconAtLastPosPathDrawerCommand {
217            cmdId: self.command_id,
218        }
219    }
220}
221
222impl CData for SDrawIconAtLastPosPathDrawerCommand {}
223
224// Drawer Draw Path Line data
225pub struct DrawLinePathDrawerCommandData {
226    pub end_position: [f32; 3],
227    pub color: [i16; 3],
228    pub alpha: i16,
229}
230
231impl CommandData for DrawLinePathDrawerCommandData {
232    type CDataType = SDrawLinePathDrawerCommand;
233
234    fn c_data(&mut self) -> Self::CDataType {
235        SDrawLinePathDrawerCommand {
236            endPos_posF3: self.end_position.as_mut_ptr(),
237            color_colorS3: self.color.as_mut_ptr(),
238            alpha: self.alpha,
239        }
240    }
241}
242
243impl CData for SDrawLinePathDrawerCommand {}
244
245// Drawer Draw Path Line and Icon data
246pub struct DrawLineAndIconPathDrawerCommandData {
247    pub command_id: i32,
248    pub position: [f32; 3],
249    pub color: [i16; 3],
250    pub alpha: i16,
251}
252
253impl CommandData for DrawLineAndIconPathDrawerCommandData {
254    type CDataType = SDrawLineAndIconPathDrawerCommand;
255
256    fn c_data(&mut self) -> Self::CDataType {
257        SDrawLineAndIconPathDrawerCommand {
258            cmdId: self.command_id,
259            endPos_posF3: self.position.as_mut_ptr(),
260            color_colorS3: self.color.as_mut_ptr(),
261            alpha: self.alpha,
262        }
263    }
264}
265
266impl CData for SDrawLineAndIconPathDrawerCommand {}
267
268// Drawer Finish Path data
269pub struct FinishPathDrawerCommandData {
270    pub i_am_useless: bool,
271}
272
273impl CommandData for FinishPathDrawerCommandData {
274    type CDataType = SFinishPathDrawerCommand;
275
276    fn c_data(&mut self) -> Self::CDataType {
277        SFinishPathDrawerCommand {
278            iAmUseless: self.i_am_useless,
279        }
280    }
281}
282
283impl CData for SFinishPathDrawerCommand {}
284
285// Drawer Path Restart data
286pub struct RestartPathDrawerCommandData {
287    pub same_color: bool,
288}
289
290impl CommandData for RestartPathDrawerCommandData {
291    type CDataType = SRestartPathDrawerCommand;
292
293    fn c_data(&mut self) -> Self::CDataType {
294        SRestartPathDrawerCommand {
295            sameColor: self.same_color,
296        }
297    }
298}
299
300impl CData for SRestartPathDrawerCommand {}
301
302// Drawer Start Path data
303pub struct StartPathDrawerCommandData {
304    pub position: [f32; 3],
305    pub color: [i16; 3],
306    pub alpha: i16,
307}
308
309impl CommandData for StartPathDrawerCommandData {
310    type CDataType = SStartPathDrawerCommand;
311
312    fn c_data(&mut self) -> Self::CDataType {
313        SStartPathDrawerCommand {
314            pos_posF3: self.position.as_mut_ptr(),
315            color_colorS3: self.color.as_mut_ptr(),
316            alpha: self.alpha,
317        }
318    }
319}
320
321impl CData for SStartPathDrawerCommand {}
322
323// Drawer Add Point data
324pub struct AddPointDrawCommandData {
325    pub position: [f32; 3],
326    pub label: CString,
327}
328
329impl CommandData for AddPointDrawCommandData {
330    type CDataType = SAddPointDrawCommand;
331
332    fn c_data(&mut self) -> Self::CDataType {
333        SAddPointDrawCommand {
334            pos_posF3: self.position.as_mut_ptr(),
335            label: self.label.as_ptr(),
336        }
337    }
338}
339
340impl CData for SAddPointDrawCommand {}
341
342// Drawer Remove Point data
343pub struct RemovePointDrawCommandData {
344    pub position: [f32; 3],
345}
346
347impl CommandData for RemovePointDrawCommandData {
348    type CDataType = SRemovePointDrawCommand;
349
350    fn c_data(&mut self) -> Self::CDataType {
351        SRemovePointDrawCommand {
352            pos_posF3: self.position.as_mut_ptr(),
353        }
354    }
355}
356
357impl CData for SRemovePointDrawCommand {}