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