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        visitor(ExportedStat::unsigned(
44            "touch",
45            "wall_touch_count",
46            StatUnit::Count,
47            self.wall_touch_count,
48        ));
49        visitor(ExportedStat::unsigned(
50            "touch",
51            "first_touch_count",
52            StatUnit::Count,
53            self.first_touch_count,
54        ));
55        for entry in self.complete_labeled_touch_counts().entries {
56            visitor(ExportedStat::unsigned_labeled(
57                "touch",
58                "touch_count",
59                StatUnit::Count,
60                entry.labels,
61                entry.count,
62            ));
63        }
64        for entry in self.complete_labeled_intention_counts().entries {
65            visitor(ExportedStat::unsigned_labeled(
66                "touch",
67                "intention_touch_count",
68                StatUnit::Count,
69                entry.labels,
70                entry.count,
71            ));
72        }
73        for entry in self.complete_touch_counts_by_role().entries {
74            visitor(ExportedStat::unsigned_labeled(
75                "touch",
76                "role_touch_count",
77                StatUnit::Count,
78                entry.labels,
79                entry.count,
80            ));
81        }
82        for entry in self.complete_touch_counts_by_play_depth().entries {
83            visitor(ExportedStat::unsigned_labeled(
84                "touch",
85                "play_depth_touch_count",
86                StatUnit::Count,
87                entry.labels,
88                entry.count,
89            ));
90        }
91        visitor(ExportedStat::unsigned(
92            "touch",
93            "is_last_touch",
94            StatUnit::Count,
95            u32::from(self.is_last_touch),
96        ));
97        if let Some(value) = self.last_touch_time {
98            visitor(ExportedStat::float(
99                "touch",
100                "last_touch_time",
101                StatUnit::Seconds,
102                value,
103            ));
104        }
105        if let Some(value) = self.last_touch_frame {
106            visitor(ExportedStat::unsigned(
107                "touch",
108                "last_touch_frame",
109                StatUnit::Count,
110                u32::try_from(value).unwrap_or(u32::MAX),
111            ));
112        }
113        if let Some(value) = self.time_since_last_touch {
114            visitor(ExportedStat::float(
115                "touch",
116                "time_since_last_touch",
117                StatUnit::Seconds,
118                value,
119            ));
120        }
121        if let Some(value) = self.frames_since_last_touch {
122            visitor(ExportedStat::unsigned(
123                "touch",
124                "frames_since_last_touch",
125                StatUnit::Count,
126                u32::try_from(value).unwrap_or(u32::MAX),
127            ));
128        }
129        if let Some(value) = self.last_ball_speed_change {
130            visitor(ExportedStat::float(
131                "touch",
132                "last_ball_speed_change",
133                StatUnit::UnrealUnitsPerSecond,
134                value,
135            ));
136        }
137        visitor(ExportedStat::float(
138            "touch",
139            "average_ball_speed_change",
140            StatUnit::UnrealUnitsPerSecond,
141            self.average_ball_speed_change(),
142        ));
143        visitor(ExportedStat::float(
144            "touch",
145            "max_ball_speed_change",
146            StatUnit::UnrealUnitsPerSecond,
147            self.max_ball_speed_change,
148        ));
149        visitor(ExportedStat::float(
150            "touch",
151            "total_ball_travel_distance",
152            StatUnit::UnrealUnits,
153            self.total_ball_travel_distance,
154        ));
155        visitor(ExportedStat::float(
156            "touch",
157            "total_ball_advance_distance",
158            StatUnit::UnrealUnits,
159            self.total_ball_advance_distance,
160        ));
161        visitor(ExportedStat::float(
162            "touch",
163            "total_ball_retreat_distance",
164            StatUnit::UnrealUnits,
165            self.total_ball_retreat_distance,
166        ));
167    }
168}
169
170#[cfg(test)]
171#[path = "touch_test.rs"]
172mod tests;