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