diff options
Diffstat (limited to 'ecs/src/actions.rs')
-rw-r--r-- | ecs/src/actions.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs index 2ee5518..038f617 100644 --- a/ecs/src/actions.rs +++ b/ecs/src/actions.rs @@ -3,6 +3,7 @@ use std::marker::PhantomData; use std::sync::{Arc, Weak}; use crate::component::{Component, Sequence as ComponentSequence}; +use crate::entity::Uid as EntityUid; use crate::lock::{Lock, WriteGuard}; use crate::system::{NoInitParamFlag, Param as SystemParam, System}; use crate::{ActionQueue, World}; @@ -23,6 +24,15 @@ impl<'world> Actions<'world> self.action_queue.push(Action::Spawn(components.into_vec())); } + /// Adds component(s) to a entity. + pub fn add_components<Comps>(&mut self, entity_uid: EntityUid, components: Comps) + where + Comps: ComponentSequence, + { + self.action_queue + .push(Action::AddComponents(entity_uid, components.into_vec())); + } + /// Adds stopping the loop in [`Engine::event_loop`] at the next opportune time to the /// action queue. pub fn stop(&mut self) @@ -129,6 +139,7 @@ impl<'weak_ref> Ref<'weak_ref> pub(crate) enum Action { Spawn(Vec<Box<dyn Component>>), + AddComponents(EntityUid, Vec<Box<dyn Component>>), Stop, } |