diff options
| author | HampusM <hampus@hampusmat.com> | 2026-07-28 14:02:53 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-07-28 14:02:53 +0200 |
| commit | 3f9750edecad1615348d9ec0995a2fbde468c8a3 (patch) | |
| tree | 5133086e93c0fe6d2a9542980a0e39080971d1be /engine-ecs/src/lib.rs | |
| parent | 9226356b7b54c4c5b036b6fee00bba376245c5f3 (diff) | |
Diffstat (limited to 'engine-ecs/src/lib.rs')
| -rw-r--r-- | engine-ecs/src/lib.rs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/engine-ecs/src/lib.rs b/engine-ecs/src/lib.rs index 97316f9..039661a 100644 --- a/engine-ecs/src/lib.rs +++ b/engine-ecs/src/lib.rs @@ -285,9 +285,7 @@ impl World extension.collect(extension_collector); } - pub fn query<'this, TermsT>( - &'this self, - ) -> Query<'this, TermsT> + pub fn query<'this, TermsT>(&'this self) -> Query<'this, TermsT> where TermsT: QueryTermTuple<'this>, { @@ -609,6 +607,29 @@ impl World &mut self.data.component_storage, ); } + Action::SetPair { entity_id, pair_id, new_pair } => { + if self.get_entity(entity_id).is_none() { + tracing::error!( + entity = %entity_id, + pair = %pair_id, + new_pair = %new_pair.id, + "Cannot set pair of a non-existant entity" + ); + continue; + }; + + let _ = self + .data + .component_storage + .remove_entity_component(entity_id, pair_id); + + Self::add_entity_components( + entity_id, + [new_pair], + &mut self.data.component_storage, + &EventSubmitter::new(&self.data.new_events), + ); + } Action::Stop => { self.stop.store(true, Ordering::Relaxed); } @@ -712,7 +733,11 @@ impl World if let Err(err) = component_storage.remove_entity_component(entity_uid, component_id) { - tracing::error!("Failed to remove component to entity: {err}"); + tracing::error!( + entity=%entity_uid, + component=%component_id, + "Failed to remove component from entity: {err}" + ); } } } |
