Skip to main content

subtr_actor/stats/analysis_graph/nodes/
double_tap.rs

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