Skip to main content

subtr_actor/stats/export/
movement.rs

1use crate::*;
2
3use super::*;
4
5impl StatFieldProvider for MovementStats {
6    fn visit_stat_fields(&self, visitor: &mut dyn FnMut(ExportedStat)) {
7        visitor(ExportedStat::float(
8            "movement",
9            "tracked_time",
10            StatUnit::Seconds,
11            self.tracked_time,
12        ));
13        for entry in self.complete_labeled_tracked_time().entries {
14            visitor(ExportedStat::float_labeled(
15                "movement",
16                "tracked_time",
17                StatUnit::Seconds,
18                entry.labels,
19                entry.value,
20            ));
21        }
22        visitor(ExportedStat::float(
23            "movement",
24            "total_distance",
25            StatUnit::UnrealUnits,
26            self.total_distance,
27        ));
28        visitor(ExportedStat::float(
29            "movement",
30            "avg_speed",
31            StatUnit::UnrealUnitsPerSecond,
32            self.average_speed(),
33        ));
34        visitor(ExportedStat::float(
35            "movement",
36            "time_supersonic_speed",
37            StatUnit::Seconds,
38            self.time_supersonic_speed,
39        ));
40        visitor(ExportedStat::float(
41            "movement",
42            "time_boost_speed",
43            StatUnit::Seconds,
44            self.time_boost_speed,
45        ));
46        visitor(ExportedStat::float(
47            "movement",
48            "time_slow_speed",
49            StatUnit::Seconds,
50            self.time_slow_speed,
51        ));
52        visitor(ExportedStat::float(
53            "movement",
54            "time_ground",
55            StatUnit::Seconds,
56            self.time_on_ground,
57        ));
58        visitor(ExportedStat::float(
59            "movement",
60            "time_low_air",
61            StatUnit::Seconds,
62            self.time_low_air,
63        ));
64        visitor(ExportedStat::float(
65            "movement",
66            "time_high_air",
67            StatUnit::Seconds,
68            self.time_high_air,
69        ));
70        visitor(ExportedStat::float(
71            "movement",
72            "avg_speed_percentage",
73            StatUnit::Percent,
74            self.average_speed_pct(),
75        ));
76        visitor(ExportedStat::float(
77            "movement",
78            "percent_slow_speed",
79            StatUnit::Percent,
80            self.slow_speed_pct(),
81        ));
82        visitor(ExportedStat::float(
83            "movement",
84            "percent_boost_speed",
85            StatUnit::Percent,
86            self.boost_speed_pct(),
87        ));
88        visitor(ExportedStat::float(
89            "movement",
90            "percent_supersonic_speed",
91            StatUnit::Percent,
92            self.supersonic_speed_pct(),
93        ));
94        visitor(ExportedStat::float(
95            "movement",
96            "percent_ground",
97            StatUnit::Percent,
98            self.on_ground_pct(),
99        ));
100        visitor(ExportedStat::float(
101            "movement",
102            "percent_low_air",
103            StatUnit::Percent,
104            self.low_air_pct(),
105        ));
106        visitor(ExportedStat::float(
107            "movement",
108            "percent_high_air",
109            StatUnit::Percent,
110            self.high_air_pct(),
111        ));
112    }
113}
114
115#[cfg(test)]
116#[path = "movement_test.rs"]
117mod tests;