use std::marker::PhantomData; use sfsm::TransitGuard; use crate::game::GameContext; pub enum TimeGuard { Idle, Waiting(u32), } impl TimeGuard { pub fn start_wait(&mut self, time: u32) { *self = Self::Waiting(time); } pub fn tick(&mut self) { if let TimeGuard::Waiting(ref mut counter) = self { *counter = counter.saturating_sub(1); } } pub fn guard(&self) -> TransitGuard { matches!(self, TimeGuard::Waiting(0)).into() } }