Skip to main content

subtr_actor/stats/analysis_graph/nodes/
bump.rs

1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5/// Detects player-on-player bumps from player frame/events and 50/50 state.
6pub struct BumpNode {
7    calculator: BumpCalculator,
8}
9
10impl BumpNode {
11    pub fn new() -> Self {
12        Self {
13            calculator: BumpCalculator::new(),
14        }
15    }
16}
17
18impl Default for BumpNode {
19    fn default() -> Self {
20        Self::new()
21    }
22}
23
24impl AnalysisNode for BumpNode {
25    type State = BumpCalculator;
26
27    fn name(&self) -> &'static str {
28        "bump"
29    }
30
31    fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32        crate::stats::calculators::BUMP_EMITTED_EVENTS
33    }
34
35    fn dependencies(&self) -> NodeDependencies {
36        vec![
37            frame_info_dependency(),
38            player_frame_state_dependency(),
39            frame_events_state_dependency(),
40            fifty_fifty_state_dependency(),
41            live_play_dependency(),
42        ]
43    }
44
45    fn evaluate(&mut self, ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
46        self.calculator.update_with_fifty_fifty_state(
47            ctx.get::<FrameInfo>()?,
48            ctx.get::<PlayerFrameState>()?,
49            ctx.get::<FrameEventsState>()?,
50            ctx.get::<FiftyFiftyState>()?,
51            ctx.get::<LivePlayState>()?,
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(BumpNode::new())
62}