use crate::prelude::*;
#[derive(Default)]
pub struct YesTick {
pub ticked: bool,
}
impl YesTick {
pub fn action<T>() -> Node<T> {
Node::stateful_action("yes", Box::new(YesTick::default()))
}
}
impl<T> StatefulAction<T> for YesTick {
fn tick(&mut self, _data: &mut T) -> Status {
self.ticked = true;
Status::Success
}
fn reset(&mut self) {
}
}
impl Drop for YesTick {
fn drop(&mut self) {
if !self.ticked {
panic!("YesTick dropped without being ticked");
}
}
}
#[derive(Default)]
pub struct NoTick;
impl NoTick {
pub fn action<T>() -> Node<T> {
Node::stateful_action("no", Box::new(NoTick::default()))
}
}
impl<T> StatefulAction<T> for NoTick {
fn tick(&mut self, _data: &mut T) -> Status {
panic!("NoTick node should never be ticked");
}
fn reset(&mut self) {
panic!("Since NoTick should never be ticked, it should also never be reset");
}
}
pub struct AlwaysRunning;
impl AlwaysRunning {
pub fn action<T>() -> Node<T> {
Node::action("running", |_| Status::Running)
}
}