diff --git a/framework_crates/bones_ecs/src/entities.rs b/framework_crates/bones_ecs/src/entities.rs index c79a2c387e..d8b1f838b1 100644 --- a/framework_crates/bones_ecs/src/entities.rs +++ b/framework_crates/bones_ecs/src/entities.rs @@ -500,6 +500,19 @@ impl Entities { } } + /// Returns a list of all `Entity`s cloned into a new vec. + pub fn all_cloned(&self) -> Vec { + self.iter().collect() + } + + /// Kills all entities. + pub fn kill_all(&mut self) { + let entities: Vec = self.all_cloned(); + for entity in entities { + self.kill(entity); + } + } + /// Returns entities in the killed list. pub fn killed(&self) -> &Vec { &self.killed @@ -528,6 +541,17 @@ impl Entities { bitset, } } + + /// Iterates over all alive entities. + pub fn iter(&self) -> EntityIterator { + EntityIterator { + current_id: 0, + next_id: self.next_id, + entities: self.bitset(), + generations: &self.generation, + bitset: self.bitset(), + } + } } /// Iterator over entities using the provided bitset.