From 86dd9c7d13243bbcd1bcf0a9166c453d6141a03a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20H=C3=BCbner?= <michael.huebner@ptspaper.de> Date: Wed, 5 Mar 2025 09:09:06 +0100 Subject: [PATCH] Add convenience method to access entities and resources --- ecs/src/world.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ecs/src/world.rs b/ecs/src/world.rs index cbb648e..aa11188 100644 --- a/ecs/src/world.rs +++ b/ecs/src/world.rs @@ -95,6 +95,18 @@ impl World { self.entities.values() } + pub fn entity_resources( + &mut self, + entity: Entity, + ) -> Result<(&mut EntityObject, &mut Resources)> { + Ok(( + // actually safe: + // entity_mut only accesses entity map + unsafe { remove_life_time_mut(self.entity_mut(entity)?) }, + &mut self.resources, + )) + } + pub fn entity( &self, entity: Entity,