Skip to content

Commit b914d59

Browse files
add some safe accessors to InteriorMutableWorld
1 parent ce33511 commit b914d59

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

crates/bevy_ecs/src/world/interior_mutable_world.rs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
use super::{Mut, World};
44
use crate::{
5+
archetype::Archetypes,
6+
bundle::Bundles,
57
change_detection::{MutUntyped, Ticks},
6-
component::ComponentId,
8+
component::{ComponentId, Components},
9+
entity::Entities,
10+
storage::Storages,
711
system::Resource,
812
};
913
use bevy_ptr::Ptr;
10-
use bevy_ptr::UnsafeCellDeref;
1114
use std::any::TypeId;
1215

1316
/// Variant of the [`World`] where resource and component accesses takes a `&World`, and the responsibility to avoid
@@ -84,6 +87,35 @@ impl<'w> InteriorMutableWorld<'w> {
8487
self.0
8588
}
8689

90+
/// Retrieves this world's [Entities] collection
91+
#[inline]
92+
pub fn entities(&self) -> &'w Entities {
93+
&self.0.entities
94+
}
95+
96+
/// Retrieves this world's [Archetypes] collection
97+
#[inline]
98+
pub fn archetypes(&self) -> &'w Archetypes {
99+
&self.0.archetypes
100+
}
101+
102+
/// Retrieves this world's [Components] collection
103+
#[inline]
104+
pub fn components(&self) -> &'w Components {
105+
&self.0.components
106+
}
107+
108+
/// Retrieves this world's [Storages] collection
109+
#[inline]
110+
pub fn storages(&self) -> &'w Storages {
111+
&self.0.storages
112+
}
113+
114+
/// Retrieves this world's [Bundles] collection
115+
#[inline]
116+
pub fn bundles(&self) -> &'w Bundles {
117+
&self.0.bundles
118+
}
87119
/// Gets a reference to the resource of the given type if it exists
88120
///
89121
/// # Safety

0 commit comments

Comments
 (0)