Skip to content

Remove WorldCell #3939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions crates/bevy_audio/src/audio_output.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{Audio, AudioSource, Decodable};
use bevy_asset::{Asset, Assets};
use bevy_ecs::world::World;
use bevy_ecs::system::{NonSend, Res, ResMut};
use bevy_utils::tracing::warn;
use rodio::{OutputStream, OutputStreamHandle, Sink};
use std::marker::PhantomData;
Expand Down Expand Up @@ -67,15 +67,14 @@ where
}

/// Plays audio currently queued in the [`Audio`] resource through the [`AudioOutput`] resource
pub fn play_queued_audio_system<Source: Asset>(world: &mut World)
where
pub fn play_queued_audio_system<Source: Asset>(
audio_output: NonSend<AudioOutput<Source>>,
mut audio: ResMut<Audio<Source>>,
audio_assets: Option<Res<Assets<Source>>>,
) where
Source: Decodable,
{
let world = world.cell();
let audio_output = world.get_non_send::<AudioOutput<Source>>().unwrap();
let mut audio = world.get_resource_mut::<Audio<Source>>().unwrap();

if let Some(audio_sources) = world.get_resource::<Assets<Source>>() {
if let Some(audio_sources) = audio_assets {
audio_output.try_play_queued(&*audio_sources, &mut *audio);
};
}
12 changes: 0 additions & 12 deletions crates/bevy_ecs/src/world/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
mod entity_ref;
mod spawn_batch;
mod world_cell;

pub use crate::change_detection::Mut;
pub use entity_ref::*;
pub use spawn_batch::*;
pub use world_cell::*;

use crate::{
archetype::{ArchetypeComponentId, ArchetypeComponentInfo, ArchetypeId, Archetypes},
Expand Down Expand Up @@ -77,8 +75,6 @@ pub struct World {
pub(crate) storages: Storages,
pub(crate) bundles: Bundles,
pub(crate) removed_components: SparseSet<ComponentId, Vec<Entity>>,
/// Access cache used by [WorldCell].
pub(crate) archetype_component_access: ArchetypeComponentAccess,
main_thread_validator: MainThreadValidator,
pub(crate) change_tick: AtomicU32,
pub(crate) last_change_tick: u32,
Expand All @@ -94,7 +90,6 @@ impl Default for World {
storages: Default::default(),
bundles: Default::default(),
removed_components: Default::default(),
archetype_component_access: Default::default(),
main_thread_validator: Default::default(),
// Default value is `1`, and `last_change_tick`s default to `0`, such that changes
// are detected on first system runs and for direct world queries.
Expand Down Expand Up @@ -164,13 +159,6 @@ impl World {
&self.bundles
}

/// Retrieves a [`WorldCell`], which safely enables multiple mutable World accesses at the same
/// time, provided those accesses do not conflict with each other.
#[inline]
pub fn cell(&mut self) -> WorldCell<'_> {
WorldCell::new(self)
}

pub fn init_component<T: Component>(&mut self) -> ComponentId {
self.components.init_component::<T>(&mut self.storages)
}
Expand Down
Loading