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