subtr_actor/stats/analysis_graph/nodes/
ceiling_shot.rs1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5pub struct CeilingShotNode {
7 calculator: CeilingShotCalculator,
8}
9
10impl CeilingShotNode {
11 pub fn new() -> Self {
12 Self {
13 calculator: CeilingShotCalculator::new(),
14 }
15 }
16}
17
18impl Default for CeilingShotNode {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl AnalysisNode for CeilingShotNode {
25 type State = CeilingShotCalculator;
26
27 fn name(&self) -> &'static str {
28 "ceiling_shot"
29 }
30
31 fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32 crate::stats::calculators::CEILING_SHOT_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.update_parts(
52 frame,
53 ball,
54 players,
55 &touch_state.touch_events,
56 live_play_state,
57 )
58 }
59
60 fn state(&self) -> &Self::State {
61 &self.calculator
62 }
63}
64
65pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
66 Box::new(CeilingShotNode::new())
67}