use bevy::{platform::collections::Equivalent, reflect::Reflect};
#[cfg(any(feature = "actionset_loader"))]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Reflect)]
#[cfg_attr(any(feature = "actionset_loader"), derive(Serialize, Deserialize))]
pub enum ActionState {
Queued,
Ready,
Running,
Paused,
Succeeded,
Failed,
Cancelled,
}
impl ActionState {
pub fn is_initial(&self) -> bool {
match self {
Self::Queued => true,
Self::Ready => true,
_ => false,
}
}
pub fn is_progressed(&self) -> bool {
match self {
Self::Running => true,
Self::Paused => true,
_ => false,
}
}
pub fn is_terminal(&self) -> bool {
match self {
Self::Succeeded => true,
Self::Failed => true,
Self::Cancelled => true,
_ => false,
}
}
pub fn should_process(&self) -> bool {
match self {
Self::Ready => true,
Self::Running => true,
_ => false,
}
}
}
impl Equivalent<ActionState> for &ActionState {
fn equivalent(&self, key: &ActionState) -> bool {
self == &key
}
}