Skip to main content

subtr_actor/stats/analysis_graph/nodes/
half_volley.rs

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