use std::any::Any; use crate::component::{Component, Sequence as ComponentSequence}; use crate::system::{NoInitParamFlag, Param as SystemParam, System}; use crate::tuple::FilterExclude as TupleFilterExclude; use crate::WorldData; /// Used to to queue up actions for a [`World`] to perform. #[derive(Debug)] pub struct Actions<'world> { world_data: &'world WorldData, } impl<'world> Actions<'world> { /// Adds a spawning a new entity to the action queue. pub fn spawn(&mut self, components: Comps) { self.world_data .action_queue .write_nonblock() .expect("Failed to aquire read-write action queue lock") .push(Action::Spawn(components.into_vec())); } } unsafe impl<'world> SystemParam<'world> for Actions<'world> { type Flags = NoInitParamFlag; type Input = TupleFilterExclude; fn initialize( _system: &mut impl System<'world, SystemImpl>, _input: Self::Input, ) { } fn new( _system: &'world impl System<'world, SystemImpl>, world_data: &'world WorldData, ) -> Self { Self { world_data } } fn is_compatible>() -> bool { let other_comparable = Other::get_comparable(); other_comparable.downcast_ref::().is_none() } fn get_comparable() -> Box { Box::new(()) } } /// A action for a [`System`] to perform. #[derive(Debug)] pub(crate) enum Action { Spawn(Vec>), } struct Comparable;