diff options
| author | mat <github@matdoes.dev> | 2022-06-20 01:19:59 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-06-20 01:19:59 -0500 |
| commit | efd874957331d8bff1cefa0f43d81685690391bf (patch) | |
| tree | 8c3ba4dd23f0bb15f467a49597068a62fd91ff6c /azalea-world/src/lib.rs | |
| parent | 438d633b83dde37e3d3564706da466963a8bc999 (diff) | |
| download | azalea-drasl-efd874957331d8bff1cefa0f43d81685690391bf.tar.xz | |
add gametick event and find_one_entity
Diffstat (limited to 'azalea-world/src/lib.rs')
| -rw-r--r-- | azalea-world/src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/azalea-world/src/lib.rs b/azalea-world/src/lib.rs index dc538618..10beb309 100644 --- a/azalea-world/src/lib.rs +++ b/azalea-world/src/lib.rs @@ -87,6 +87,19 @@ impl World { pub fn entity_by_id(&self, id: u32) -> Option<&Entity> { self.entity_storage.get_by_id(id) } + + /// Get an iterator over all entities. + #[inline] + pub fn entities(&self) -> std::collections::hash_map::Values<'_, u32, Entity> { + self.entity_storage.entities() + } + + pub fn find_one_entity<F>(&self, mut f: F) -> Option<&Entity> + where + F: FnMut(&Entity) -> bool, + { + self.entity_storage.find_one_entity(|entity| f(entity)) + } } impl Index<&ChunkPos> for World { |
