Skip to main content

nil_core/behavior/impl/
idle.rs

1// Copyright (C) Call of Nil contributors
2// SPDX-License-Identifier: AGPL-3.0-only
3
4use crate::behavior::Behavior;
5use crate::behavior::score::BehaviorScore;
6use crate::error::Result;
7use crate::world::World;
8use std::ops::ControlFlow;
9
10#[derive(Debug)]
11pub struct IdleBehavior;
12
13impl IdleBehavior {
14  const SCORE: BehaviorScore = BehaviorScore::new(0.1);
15}
16
17impl Behavior for IdleBehavior {
18  fn score(&self, _: &World) -> Result<BehaviorScore> {
19    Ok(Self::SCORE)
20  }
21
22  fn behave(&self, _: &mut World) -> Result<ControlFlow<()>> {
23    Ok(ControlFlow::Break(()))
24  }
25}