1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
use specs::{Component, DenseVecStorage, Entity, LazyUpdate}; use crate::ActionEnt; #[derive(Debug, Component)] pub struct Action { pub factory: Box<dyn ActionFactory>, pub state: ActionState, } impl Action { pub fn new(factory: Box<dyn ActionFactory>) -> Self { Self { factory, state: ActionState::Init, } } } pub trait ActionFactory: std::fmt::Debug + Send + Sync { fn add(&self, ent: Entity, action: ActionEnt, lazy: &LazyUpdate); } #[derive(Debug, Clone, Eq, PartialEq)] pub enum ActionState { Init, Requested, Executing, Cancelled, Success, Failure, }