Improve change logic

This commit is contained in:
Michael Huebner 2025-03-24 13:11:55 +01:00
parent 5815d2f8f3
commit c7a7225c95

View file

@ -341,7 +341,7 @@ impl World {
Ok(())
}
pub fn commit_entity_changes(&mut self) -> Result<bool> {
pub fn commit_entity_changes(&mut self) -> Result<()> {
#[cfg(debug_assertions)]
{
if !self.entities_to_remove.is_empty() {
@ -361,7 +361,7 @@ impl World {
&& self.entities_to_add.is_empty()
&& self.entities_updates.is_empty()
{
return Ok(false);
return Ok(());
}
for entity in core::mem::take(&mut self.entities_to_remove) {
@ -409,7 +409,8 @@ impl World {
}
}
Ok(true)
self.had_entity_changes = true;
Ok(())
}
}
@ -431,13 +432,16 @@ impl World {
self.updates.update(w)?;
}
self.had_entity_changes = self.commit_entity_changes()?;
self.commit_entity_changes()?;
for system in systems.iter() {
if !system(self)? {
return Ok(());
}
}
// reset flag
self.had_entity_changes = false;
}
}
}