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 possession_state_dependency(),
37 fifty_fifty_state_dependency(),
38 live_play_dependency(),
39 ]
40 }
41
42 fn evaluate(&mut self, ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
43 let touch_state = ctx.get::<TouchState>()?;
44 self.calculator.update(
45 ctx.get::<FrameInfo>()?,
46 ctx.get::<BallFrameState>()?,
47 ctx.get::<PlayerVerticalState>()?,
48 touch_state,
49 ctx.get::<PossessionState>()?,
50 ctx.get::<FiftyFiftyState>()?,
51 ctx.get::<LivePlayState>()?.is_live_play,
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(TouchNode::new())
62}