subtr_actor/stats/analysis_graph/nodes/
half_volley.rs1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5pub struct HalfVolleyNode {
7 calculator: HalfVolleyCalculator,
8}
9
10impl HalfVolleyNode {
11 pub fn new() -> Self {
12 Self {
13 calculator: HalfVolleyCalculator::new(),
14 }
15 }
16}
17
18impl Default for HalfVolleyNode {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl AnalysisNode for HalfVolleyNode {
25 type State = HalfVolleyCalculator;
26
27 fn name(&self) -> &'static str {
28 "half_volley"
29 }
30
31 fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32 crate::stats::calculators::HALF_VOLLEY_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 self.calculator.update(
47 ctx.get::<FrameInfo>()?,
48 ctx.get::<BallFrameState>()?,
49 ctx.get::<PlayerFrameState>()?,
50 ctx.get::<TouchState>()?,
51 ctx.get::<LivePlayState>()?,
52 )
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(HalfVolleyNode::new())
62}