Skip to main content

subtr_actor/stats/analysis_graph/nodes/
wall_aerial.rs

1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5/// Detects wall aerials from ball/player positions and touches during live play.
6pub struct WallAerialNode {
7    calculator: WallAerialCalculator,
8}
9
10impl WallAerialNode {
11    pub fn new() -> Self {
12        Self {
13            calculator: WallAerialCalculator::new(),
14        }
15    }
16}
17
18impl Default for WallAerialNode {
19    fn default() -> Self {
20        Self::new()
21    }
22}
23
24impl AnalysisNode for WallAerialNode {
25    type State = WallAerialCalculator;
26
27    fn name(&self) -> &'static str {
28        "wall_aerial"
29    }
30
31    fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32        crate::stats::calculators::WALL_AERIAL_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            live_play_dependency(),
42        ]
43    }
44
45    fn evaluate(&mut self, ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
46        let frame = ctx.get::<FrameInfo>()?;
47        let ball = ctx.get::<BallFrameState>()?;
48        let players = ctx.get::<PlayerFrameState>()?;
49        let touch_state = ctx.get::<TouchState>()?;
50        let live_play_state = ctx.get::<LivePlayState>()?;
51        self.calculator
52            .update(frame, ball, players, touch_state, live_play_state)
53    }
54
55    fn state(&self) -> &Self::State {
56        &self.calculator
57    }
58}
59
60pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
61    Box::new(WallAerialNode::new())
62}