Skip to main content

subtr_actor/stats/export/
touch.rs

1use crate::*;
2
3use super::*;
4
5impl StatFieldProvider for TouchStats {
6    fn visit_stat_fields(&self, visitor: &mut dyn FnMut(ExportedStat)) {
7        visitor(ExportedStat::unsigned(
8            "touch",
9            "touch_count",
10            StatUnit::Count,
11            self.touch_count,
12        ));
13        visitor(ExportedStat::unsigned(
14            "touch",
15            "control_touch_count",
16            StatUnit::Count,
17            self.control_touch_count,
18        ));
19        visitor(ExportedStat::unsigned(
20            "touch",
21            "medium_hit_count",
22            StatUnit::Count,
23            self.medium_hit_count,
24        ));
25        visitor(ExportedStat::unsigned(
26            "touch",
27            "hard_hit_count",
28            StatUnit::Count,
29            self.hard_hit_count,
30        ));
31        visitor(ExportedStat::unsigned(
32            "touch",
33            "aerial_touch_count",
34            StatUnit::Count,
35            self.aerial_touch_count,
36        ));
37        visitor(ExportedStat::unsigned(
38            "touch",
39            "high_aerial_touch_count",
40            StatUnit::Count,
41            self.high_aerial_touch_count,
42        ));
43        for entry in self.complete_labeled_touch_counts().entries {
44            visitor(ExportedStat::unsigned_labeled(
45                "touch",
46                "touch_count",
47                StatUnit::Count,
48                entry.labels,
49                entry.count,
50            ));
51        }
52        visitor(ExportedStat::unsigned(
53            "touch",
54            "is_last_touch",
55            StatUnit::Count,
56            u32::from(self.is_last_touch),
57        ));
58        if let Some(value) = self.last_touch_time {
59            visitor(ExportedStat::float(
60                "touch",
61                "last_touch_time",
62                StatUnit::Seconds,
63                value,
64            ));
65        }
66        if let Some(value) = self.last_touch_frame {
67            visitor(ExportedStat::unsigned(
68                "touch",
69                "last_touch_frame",
70                StatUnit::Count,
71                u32::try_from(value).unwrap_or(u32::MAX),
72            ));
73        }
74        if let Some(value) = self.time_since_last_touch {
75            visitor(ExportedStat::float(
76                "touch",
77                "time_since_last_touch",
78                StatUnit::Seconds,
79                value,
80            ));
81        }
82        if let Some(value) = self.frames_since_last_touch {
83            visitor(ExportedStat::unsigned(
84                "touch",
85                "frames_since_last_touch",
86                StatUnit::Count,
87                u32::try_from(value).unwrap_or(u32::MAX),
88            ));
89        }
90        if let Some(value) = self.last_ball_speed_change {
91            visitor(ExportedStat::float(
92                "touch",
93                "last_ball_speed_change",
94                StatUnit::UnrealUnitsPerSecond,
95                value,
96            ));
97        }
98        visitor(ExportedStat::float(
99            "touch",
100            "average_ball_speed_change",
101            StatUnit::UnrealUnitsPerSecond,
102            self.average_ball_speed_change(),
103        ));
104        visitor(ExportedStat::float(
105            "touch",
106            "max_ball_speed_change",
107            StatUnit::UnrealUnitsPerSecond,
108            self.max_ball_speed_change,
109        ));
110        visitor(ExportedStat::float(
111            "touch",
112            "total_ball_travel_distance",
113            StatUnit::UnrealUnits,
114            self.total_ball_travel_distance,
115        ));
116        visitor(ExportedStat::float(
117            "touch",
118            "total_ball_advance_distance",
119            StatUnit::UnrealUnits,
120            self.total_ball_advance_distance,
121        ));
122        visitor(ExportedStat::float(
123            "touch",
124            "total_ball_retreat_distance",
125            StatUnit::UnrealUnits,
126            self.total_ball_retreat_distance,
127        ));
128    }
129}
130
131#[cfg(test)]
132#[path = "touch_test.rs"]
133mod tests;