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