subtr_actor/stats/analysis_graph/nodes/
demo.rs1use super::*;
2use crate::stats::calculators::*;
3use crate::*;
4
5pub struct DemoNode {
7 calculator: DemoCalculator,
8}
9
10impl DemoNode {
11 pub fn new() -> Self {
12 Self {
13 calculator: DemoCalculator::new(),
14 }
15 }
16}
17
18impl Default for DemoNode {
19 fn default() -> Self {
20 Self::new()
21 }
22}
23
24impl AnalysisNode for DemoNode {
25 type State = DemoCalculator;
26
27 fn name(&self) -> &'static str {
28 "demo"
29 }
30
31 fn emitted_events(&self) -> &'static [crate::stats::calculators::EmittedEvent] {
32 crate::stats::calculators::DEMO_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 ]
41 }
42
43 fn evaluate(&mut self, ctx: &AnalysisStateContext<'_>) -> SubtrActorResult<()> {
44 self.calculator.update(
45 ctx.get::<FrameInfo>()?,
46 ctx.get::<PlayerFrameState>()?,
47 ctx.get::<FrameEventsState>()?,
48 )
49 }
50
51 fn state(&self) -> &Self::State {
52 &self.calculator
53 }
54}
55
56pub(crate) fn boxed_default() -> Box<dyn AnalysisNodeDyn> {
57 Box::new(DemoNode::new())
58}