summaryrefslogtreecommitdiff
path: root/ecs/src/actions.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2024-12-09 18:16:50 +0100
committerHampusM <hampus@hampusmat.com>2024-12-09 18:16:50 +0100
commita318a32eba91cacd71c8f0cb09b49a10d12e96ca (patch)
treea76848818496a0e22c0f5f061c33ed89ab944999 /ecs/src/actions.rs
parent3553a24c86791f6f4501e3d19fb85f267435cf70 (diff)
feat(ecs): add action to despawn entity
Diffstat (limited to 'ecs/src/actions.rs')
-rw-r--r--ecs/src/actions.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/ecs/src/actions.rs b/ecs/src/actions.rs
index 35e9569..0878067 100644
--- a/ecs/src/actions.rs
+++ b/ecs/src/actions.rs
@@ -29,6 +29,14 @@ impl<'world> Actions<'world>
));
}
+ /// Queues up despawning a entity at the end of the current tick.
+ pub fn despawn(&mut self, entity_uid: Uid)
+ {
+ debug_assert_eq!(entity_uid.kind(), UidKind::Entity);
+
+ self.action_queue.push(Action::Despawn(entity_uid));
+ }
+
/// Queues up adding component(s) to a entity at the end of the current tick.
pub fn add_components<Comps>(&mut self, entity_uid: Uid, components: Comps)
where
@@ -155,6 +163,7 @@ pub(crate) struct EventIds
pub(crate) enum Action
{
Spawn(Vec<Box<dyn Component>>, EventIds),
+ Despawn(Uid),
AddComponents(Uid, Vec<Box<dyn Component>>, EventIds),
RemoveComponents(Uid, Vec<ComponentMetadata>, EventIds),
Stop,