Skip to main content

subtr_actor/stats/analysis_graph/nodes/
pass.rs

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