diff options
author | HampusM <hampus@hampusmat.com> | 2024-08-12 19:43:47 +0200 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-08-12 19:44:06 +0200 |
commit | 28438c40c09bb52f8bd444b6f5cf9b34bdf71fee (patch) | |
tree | ae6d506f9a9fc30a332deb0f51b098be87f8d78b /ecs/src/lib.rs | |
parent | ee69aa92802ba9f5becd533465ca1639cb670ace (diff) |
feat(ecs): add action for removing components(s) from entity
Diffstat (limited to 'ecs/src/lib.rs')
-rw-r--r-- | ecs/src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ecs/src/lib.rs b/ecs/src/lib.rs index df65cb3..04c9b9f 100644 --- a/ecs/src/lib.rs +++ b/ecs/src/lib.rs @@ -170,6 +170,19 @@ impl World component_storage_lock .add_components_to_entity(entity_uid, components); } + Action::RemoveComponents(entity_uid, component_ids) => { + let mut component_storage_lock = + self.data.component_storage.write_nonblock().expect( + "Failed to acquire read-write component storage lock", + ); + + component_storage_lock.remove_components_from_entity( + entity_uid, + component_ids + .iter() + .map(|component_metadata| component_metadata.id), + ); + } Action::Stop => { self.stop.store(true, Ordering::Relaxed); } |