Skip to main content

subtr_actor/stats/analysis_graph/nodes/
wall_aerial_shot.rs

1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5/// Detects wall-aerial shots from player frame state and frame events during live play.
6pub struct WallAerialShotNode {
7    calculator: WallAerialShotCalculator,
8}
9
10impl WallAerialShotNode {
11    pub fn new() -> Self {
12        Self {
13            calculator: WallAerialShotCalculator::new(),
14        }
15    }
16}
17
18impl Default for WallAerialShotNode {
19    fn default() -> Self {
20        Self::new()
21    }
22}
23
24impl AnalysisNode for WallAerialShotNode {
25    type State = WallAerialShotCalculator;
26
27    fn name(&self) -> &'static str {
28        "wall_aerial_shot"
29    }
30
31    fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32        crate::stats::calculators::WALL_AERIAL_SHOT_EMITTED_EVENTS
33    }
34
35    fn dependencies(&self) -> NodeDependencies {
36        vec![
37            frame_info_dependency(),
38            player_frame_state_dependency(),
39            frame_events_state_dependency(),
40            live_play_dependency(),
41        ]
42    }
43
44    fn evaluate(&mut self, ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
45        let frame = ctx.get::<FrameInfo>()?;
46        let players = ctx.get::<PlayerFrameState>()?;
47        let frame_events = ctx.get::<FrameEventsState>()?;
48        let live_play_state = ctx.get::<LivePlayState>()?;
49        self.calculator
50            .update(frame, players, frame_events, live_play_state)
51    }
52
53    fn state(&self) -> &Self::State {
54        &self.calculator
55    }
56}
57
58pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
59    Box::new(WallAerialShotNode::new())
60}