use anyhow::Result;
use bevy_ecs::schedule::SystemConfigs;
use bevy_ecs::system::EntityCommands;
use bevy_ecs::world::EntityWorldMut;
use serde::Serialize;
#[typetag::serde]
pub trait Action: 'static {
fn duplicate(&self) -> Box<dyn Action>;
fn spawn(&self, entity: &mut EntityWorldMut<'_>);
fn spawn_with_command(&self, entity: &mut EntityCommands);
fn tick_system(&self) -> SystemConfigs;
fn post_tick_system(&self) -> SystemConfigs;
fn meta(&self) -> ActionMeta;
}
pub type SetActionFunc = Box<dyn Fn(&mut EntityCommands) -> Result<()>>;
pub trait SetAction: Action {
fn set(&mut self, func: SetActionFunc);
}
#[derive(Debug, Clone)]
pub struct ActionMeta {
pub name: &'static str,
pub id: usize,
}
pub trait IntoAction: 'static + Clone + Send + Sync + Serialize {
fn into_action(self) -> Box<dyn Action>;
fn into_action_ref(&self) -> &dyn Action;
fn into_action_mut(&mut self) -> &mut dyn Action;
}