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