subtr_actor/stats/analysis_graph/nodes/
controlled_play.rs1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5pub struct ControlledPlayNode {
7 calculator: ControlledPlayCalculator,
8}
9
10impl ControlledPlayNode {
11 pub fn new() -> Self {
12 Self {
13 calculator: ControlledPlayCalculator::new(),
14 }
15 }
16}
17
18impl Default for ControlledPlayNode {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl AnalysisNode for ControlledPlayNode {
25 type State = ControlledPlayCalculator;
26
27 fn name(&self) -> &'static str {
28 "controlled_play"
29 }
30
31 fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32 crate::stats::calculators::CONTROLLED_PLAY_EMITTED_EVENTS
33 }
34
35 fn dependencies(&self) -> Vec<AnalysisDependency> {
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 finish(&mut self, _ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
56 self.calculator.finish();
57 Ok(())
58 }
59
60 fn state(&self) -> &Self::State {
61 &self.calculator
62 }
63}
64
65pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
66 Box::new(ControlledPlayNode::new())
67}