Skip to main content

subtr_actor/stats/analysis_graph/nodes/
movement.rs

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