Add convenience method to access entities and resources
This commit is contained in:
parent
2a7e0e71eb
commit
86dd9c7d13
1 changed files with 12 additions and 0 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue