1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
use spring_ai_sys::{
    SFreePathCommand, SGetApproximateLengthPathCommand, SGetNextWaypointPathCommand,
    SInitPathCommand,
};

use crate::ai_interface::callback::command::command_data::{CData, CommandData};

// Free Path command data
pub struct FreePathCommandData {
    pub path_id: i32,
}

impl CommandData for FreePathCommandData {
    type CDataType = SFreePathCommand;

    fn c_data(&mut self) -> Self::CDataType {
        SFreePathCommand {
            pathId: self.path_id,
        }
    }
}

impl CData for SFreePathCommand {}

// Path Length command data
pub struct GetApproximateLengthPathCommandData {
    pub start_pos: [f32; 3],
    pub end_pos: [f32; 3],
    pub path_type: i32,
    pub goal_radius: f32,
}

impl CommandData for GetApproximateLengthPathCommandData {
    type CDataType = SGetApproximateLengthPathCommand;

    fn c_data(&mut self) -> Self::CDataType {
        SGetApproximateLengthPathCommand {
            start_posF3: self.start_pos.as_mut_ptr(),
            end_posF3: self.end_pos.as_mut_ptr(),
            pathType: self.path_type,
            goalRadius: self.goal_radius,
            ret_approximatePathLength: 0.0,
        }
    }
}

impl CData for SGetApproximateLengthPathCommand {}

// Path Next Waypoint command data
pub struct InitPathCommandData {
    pub start_pos: [f32; 3],
    pub end_pos: [f32; 3],
    pub path_type: i32,
    pub goal_radius: f32,
}

impl CommandData for InitPathCommandData {
    type CDataType = SInitPathCommand;

    fn c_data(&mut self) -> Self::CDataType {
        SInitPathCommand {
            start_posF3: self.start_pos.as_mut_ptr(),
            end_posF3: self.end_pos.as_mut_ptr(),
            pathType: self.path_type,
            goalRadius: self.goal_radius,
            ret_pathId: 0,
        }
    }
}

impl CData for SInitPathCommand {}

// Init Path command data
pub struct GetNextWaypointPathCommandData {
    pub path_id: i32,
    pub next_waypoint_position: [f32; 3],
}

impl CommandData for GetNextWaypointPathCommandData {
    type CDataType = SGetNextWaypointPathCommand;

    fn c_data(&mut self) -> Self::CDataType {
        SGetNextWaypointPathCommand {
            pathId: self.path_id,
            ret_nextWaypoint_posF3_out: self.next_waypoint_position.as_mut_ptr(),
        }
    }
}

impl CData for SGetNextWaypointPathCommand {}