subtr_actor/stats/analysis_graph/nodes/
double_tap.rs1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5pub struct DoubleTapNode {
7 calculator: DoubleTapCalculator,
8}
9
10impl DoubleTapNode {
11 pub fn new() -> Self {
12 Self {
13 calculator: DoubleTapCalculator::new(),
14 }
15 }
16}
17
18impl Default for DoubleTapNode {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl AnalysisNode for DoubleTapNode {
25 type State = DoubleTapCalculator;
26
27 fn name(&self) -> &'static str {
28 "double_tap"
29 }
30
31 fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32 crate::stats::calculators::DOUBLE_TAP_EMITTED_EVENTS
33 }
34
35 fn dependencies(&self) -> NodeDependencies {
36 vec![
37 frame_info_dependency(),
38 ball_frame_state_dependency(),
39 player_frame_state_dependency(),
40 touch_state_dependency(),
41 backboard_bounce_state_dependency(),
42 live_play_dependency(),
43 ]
44 }
45
46 fn evaluate(&mut self, ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
47 self.calculator.update(
48 ctx.get::<FrameInfo>()?,
49 ctx.get::<BallFrameState>()?,
50 ctx.get::<PlayerFrameState>()?,
51 ctx.get::<TouchState>()?,
52 ctx.get::<BackboardBounceState>()?,
53 ctx.get::<LivePlayState>()?,
54 )
55 }
56
57 fn state(&self) -> &Self::State {
58 &self.calculator
59 }
60}
61
62pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
63 Box::new(DoubleTapNode::new())
64}