diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index fbe7586c8d..3bf032590a 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -477,7 +477,7 @@ unsafe impl<'a, T: Resource> SystemParam for Res<'a, T> { fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State { let component_id = world.components.init_resource::(); - world.initialize_resource_internal(component_id); + let archetype_component_id = world.initialize_resource_internal(component_id).id(); let combined_access = system_meta.component_access_set.combined_access(); assert!( @@ -490,9 +490,6 @@ unsafe impl<'a, T: Resource> SystemParam for Res<'a, T> { .component_access_set .add_unfiltered_resource_read(component_id); - let archetype_component_id = world - .get_resource_archetype_component_id(component_id) - .unwrap(); system_meta .archetype_component_access .add_resource_read(archetype_component_id); @@ -574,7 +571,7 @@ unsafe impl<'a, T: Resource> SystemParam for ResMut<'a, T> { fn init_state(world: &mut World, system_meta: &mut SystemMeta) -> Self::State { let component_id = world.components.init_resource::(); - world.initialize_resource_internal(component_id); + let archetype_component_id = world.initialize_resource_internal(component_id).id(); let combined_access = system_meta.component_access_set.combined_access(); if combined_access.has_resource_write(component_id) { @@ -590,9 +587,6 @@ unsafe impl<'a, T: Resource> SystemParam for ResMut<'a, T> { .component_access_set .add_unfiltered_resource_write(component_id); - let archetype_component_id = world - .get_resource_archetype_component_id(component_id) - .unwrap(); system_meta .archetype_component_access .add_resource_write(archetype_component_id); @@ -1112,7 +1106,7 @@ unsafe impl<'a, T: 'static> SystemParam for NonSend<'a, T> { system_meta.set_non_send(); let component_id = world.components.init_non_send::(); - world.initialize_non_send_internal(component_id); + let archetype_component_id = world.initialize_non_send_internal(component_id).id(); let combined_access = system_meta.component_access_set.combined_access(); assert!( @@ -1125,9 +1119,6 @@ unsafe impl<'a, T: 'static> SystemParam for NonSend<'a, T> { .component_access_set .add_unfiltered_resource_read(component_id); - let archetype_component_id = world - .get_non_send_archetype_component_id(component_id) - .unwrap(); system_meta .archetype_component_access .add_resource_read(archetype_component_id); @@ -1206,7 +1197,7 @@ unsafe impl<'a, T: 'static> SystemParam for NonSendMut<'a, T> { system_meta.set_non_send(); let component_id = world.components.init_non_send::(); - world.initialize_non_send_internal(component_id); + let archetype_component_id = world.initialize_non_send_internal(component_id).id(); let combined_access = system_meta.component_access_set.combined_access(); if combined_access.has_component_write(component_id) { @@ -1222,9 +1213,6 @@ unsafe impl<'a, T: 'static> SystemParam for NonSendMut<'a, T> { .component_access_set .add_unfiltered_resource_write(component_id); - let archetype_component_id = world - .get_non_send_archetype_component_id(component_id) - .unwrap(); system_meta .archetype_component_access .add_resource_write(archetype_component_id); diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 7a798b4929..47b08506fc 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -26,7 +26,7 @@ pub use identifier::WorldId; pub use spawn_batch::*; use crate::{ - archetype::{ArchetypeComponentId, ArchetypeId, ArchetypeRow, Archetypes}, + archetype::{ArchetypeId, ArchetypeRow, Archetypes}, bundle::{Bundle, BundleInfo, BundleInserter, BundleSpawner, Bundles}, change_detection::{MutUntyped, TicksMut}, component::{ @@ -1783,26 +1783,6 @@ impl World { unsafe { self.as_unsafe_world_cell().get_non_send_resource_mut() } } - // Shorthand helper function for getting the [`ArchetypeComponentId`] for a resource. - #[inline] - pub(crate) fn get_resource_archetype_component_id( - &self, - component_id: ComponentId, - ) -> Option { - let resource = self.storages.resources.get(component_id)?; - Some(resource.id()) - } - - // Shorthand helper function for getting the [`ArchetypeComponentId`] for a resource. - #[inline] - pub(crate) fn get_non_send_archetype_component_id( - &self, - component_id: ComponentId, - ) -> Option { - let resource = self.storages.non_send_resources.get(component_id)?; - Some(resource.id()) - } - /// For a given batch of ([`Entity`], [`Bundle`]) pairs, either spawns each [`Entity`] with the given /// bundle (if the entity does not exist), or inserts the [`Bundle`] (if the entity already exists). /// This is faster than doing equivalent operations one-by-one.