subtr_actor/stats/analysis_graph/nodes/
rotation.rs1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5pub struct RotationNode {
6 calculator: RotationCalculator,
7}
8
9impl RotationNode {
10 pub fn new() -> Self {
11 Self::with_config(RotationCalculatorConfig::default())
12 }
13
14 pub fn with_config(config: RotationCalculatorConfig) -> Self {
15 Self {
16 calculator: RotationCalculator::with_config(config),
17 }
18 }
19}
20
21impl Default for RotationNode {
22 fn default() -> Self {
23 Self::new()
24 }
25}
26
27impl AnalysisNode for RotationNode {
28 type State = RotationCalculator;
29
30 fn name(&self) -> &'static str {
31 "rotation"
32 }
33
34 fn dependencies(&self) -> NodeDependencies {
35 vec![
36 frame_info_dependency(),
37 gameplay_state_dependency(),
38 ball_frame_state_dependency(),
39 player_frame_state_dependency(),
40 frame_events_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::<GameplayState>()?,
49 ctx.get::<BallFrameState>()?,
50 ctx.get::<PlayerFrameState>()?,
51 ctx.get::<FrameEventsState>()?,
52 ctx.get::<LivePlayState>()?.is_live_play,
53 )
54 }
55
56 fn state(&self) -> &Self::State {
57 &self.calculator
58 }
59}
60
61pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
62 Box::new(RotationNode::new())
63}