diff --git a/crates/bevy_a11y/src/lib.rs b/crates/bevy_a11y/src/lib.rs index 453ac7b7f88cd..651236d876b2e 100644 --- a/crates/bevy_a11y/src/lib.rs +++ b/crates/bevy_a11y/src/lib.rs @@ -23,8 +23,8 @@ use bevy_app::Plugin; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::{Component, Event}, + resource::Resource, schedule::SystemSet, - system::Resource, }; /// Wrapper struct for [`accesskit::ActionRequest`]. Required to allow it to be used as an `Event`. diff --git a/crates/bevy_animation/src/graph.rs b/crates/bevy_animation/src/graph.rs index e570d25ab15e3..4db8ce47c3084 100644 --- a/crates/bevy_animation/src/graph.rs +++ b/crates/bevy_animation/src/graph.rs @@ -14,7 +14,8 @@ use bevy_ecs::{ component::Component, event::EventReader, reflect::ReflectComponent, - system::{Res, ResMut, Resource}, + resource::Resource, + system::{Res, ResMut}, }; use bevy_reflect::{prelude::ReflectDefault, Reflect, ReflectSerialize}; use bevy_utils::HashMap; diff --git a/crates/bevy_app/src/app.rs b/crates/bevy_app/src/app.rs index 2c6dc56e069ad..799c936ec00b7 100644 --- a/crates/bevy_app/src/app.rs +++ b/crates/bevy_app/src/app.rs @@ -1423,8 +1423,9 @@ mod tests { event::{Event, EventWriter, Events}, query::With, removal_detection::RemovedComponents, + resource::Resource, schedule::{IntoSystemConfigs, ScheduleLabel}, - system::{Commands, Query, Resource}, + system::{Commands, Query}, world::{FromWorld, World}, }; diff --git a/crates/bevy_app/src/main_schedule.rs b/crates/bevy_app/src/main_schedule.rs index 227a976de7e97..55f8bbf2beab8 100644 --- a/crates/bevy_app/src/main_schedule.rs +++ b/crates/bevy_app/src/main_schedule.rs @@ -1,11 +1,12 @@ use crate::{App, Plugin}; use alloc::{vec, vec::Vec}; use bevy_ecs::{ + resource::Resource, schedule::{ ExecutorKind, InternedScheduleLabel, IntoSystemSetConfigs, Schedule, ScheduleLabel, SystemSet, }, - system::{Local, Resource}, + system::Local, world::{Mut, World}, }; diff --git a/crates/bevy_app/src/plugin_group.rs b/crates/bevy_app/src/plugin_group.rs index 49d05f32290ba..6fa7224979669 100644 --- a/crates/bevy_app/src/plugin_group.rs +++ b/crates/bevy_app/src/plugin_group.rs @@ -226,7 +226,7 @@ impl PluginGroup for PluginGroupBuilder { /// Facilitates the creation and configuration of a [`PluginGroup`]. /// -/// Provides a build ordering to ensure that [`Plugin`]s which produce/require a [`Resource`](bevy_ecs::system::Resource) +/// Provides a build ordering to ensure that [`Plugin`]s which produce/require a [`Resource`](bevy_ecs::resource::Resource) /// are built before/after dependent/depending [`Plugin`]s. [`Plugin`]s inside the group /// can be disabled, enabled or reordered. pub struct PluginGroupBuilder { diff --git a/crates/bevy_asset/src/asset_changed.rs b/crates/bevy_asset/src/asset_changed.rs index 46fdf40d8606a..b165f2606ce7f 100644 --- a/crates/bevy_asset/src/asset_changed.rs +++ b/crates/bevy_asset/src/asset_changed.rs @@ -298,7 +298,8 @@ mod tests { use bevy_ecs::{ component::Component, event::EventWriter, - system::{Commands, IntoSystem, Local, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, IntoSystem, Local, Query, Res, ResMut}, }; use bevy_reflect::TypePath; diff --git a/crates/bevy_asset/src/assets.rs b/crates/bevy_asset/src/assets.rs index 2f753b362c486..344cd9bd3c666 100644 --- a/crates/bevy_asset/src/assets.rs +++ b/crates/bevy_asset/src/assets.rs @@ -6,7 +6,8 @@ use crate::{ use alloc::{sync::Arc, vec::Vec}; use bevy_ecs::{ prelude::EventWriter, - system::{Res, ResMut, Resource, SystemChangeTick}, + resource::Resource, + system::{Res, ResMut, SystemChangeTick}, }; use bevy_reflect::{Reflect, TypePath}; use bevy_utils::HashMap; diff --git a/crates/bevy_asset/src/io/embedded/mod.rs b/crates/bevy_asset/src/io/embedded/mod.rs index 1c9557b3329b6..8ea2e72e0d469 100644 --- a/crates/bevy_asset/src/io/embedded/mod.rs +++ b/crates/bevy_asset/src/io/embedded/mod.rs @@ -9,7 +9,7 @@ use crate::io::{ AssetSource, AssetSourceBuilders, }; use alloc::boxed::Box; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use std::path::{Path, PathBuf}; #[cfg(feature = "embedded_watcher")] diff --git a/crates/bevy_asset/src/io/source.rs b/crates/bevy_asset/src/io/source.rs index b48ed14856271..5b6e2df97b238 100644 --- a/crates/bevy_asset/src/io/source.rs +++ b/crates/bevy_asset/src/io/source.rs @@ -8,7 +8,7 @@ use alloc::{ sync::Arc, }; use atomicow::CowArc; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use bevy_utils::HashMap; use core::{fmt::Display, hash::Hash, time::Duration}; use thiserror::Error; diff --git a/crates/bevy_asset/src/server/mod.rs b/crates/bevy_asset/src/server/mod.rs index 6ea6f9031f349..3d92dc0ced7a0 100644 --- a/crates/bevy_asset/src/server/mod.rs +++ b/crates/bevy_asset/src/server/mod.rs @@ -521,7 +521,8 @@ impl AssetServer { /// /// ``` /// use bevy_asset::{Assets, Handle, LoadedUntypedAsset}; - /// use bevy_ecs::system::{Res, Resource}; + /// use bevy_ecs::system::Res; + /// use bevy_ecs::resource::Resource; /// /// #[derive(Resource)] /// struct LoadingUntypedHandle(Handle); diff --git a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs index 642791568acc1..544b420bfdb68 100644 --- a/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/downsampling_pipeline.rs @@ -2,7 +2,8 @@ use super::{Bloom, BLOOM_SHADER_HANDLE, BLOOM_TEXTURE_FORMAT}; use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ prelude::{Component, Entity}, - system::{Commands, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_math::{Vec2, Vec4}; diff --git a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs index b63a3eb633485..e4c4ed4a647f9 100644 --- a/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs +++ b/crates/bevy_core_pipeline/src/bloom/upsampling_pipeline.rs @@ -5,7 +5,8 @@ use super::{ use crate::fullscreen_vertex_shader::fullscreen_shader_vertex_state; use bevy_ecs::{ prelude::{Component, Entity}, - system::{Commands, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_render::{ diff --git a/crates/bevy_core_pipeline/src/dof/mod.rs b/crates/bevy_core_pipeline/src/dof/mod.rs index ca5eac082b4fa..c703bb0bb19c2 100644 --- a/crates/bevy_core_pipeline/src/dof/mod.rs +++ b/crates/bevy_core_pipeline/src/dof/mod.rs @@ -22,8 +22,9 @@ use bevy_ecs::{ entity::Entity, query::{QueryItem, With}, reflect::ReflectComponent, + resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs index 8109beeb4eb3a..61bb7b60ce42e 100644 --- a/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs +++ b/crates/bevy_core_pipeline/src/motion_blur/pipeline.rs @@ -2,7 +2,8 @@ use bevy_ecs::{ component::Component, entity::Entity, query::With, - system::{Commands, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, Query, Res, ResMut}, world::FromWorld, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_core_pipeline/src/post_process/mod.rs b/crates/bevy_core_pipeline/src/post_process/mod.rs index f1719c1384222..2873f5cb7754f 100644 --- a/crates/bevy_core_pipeline/src/post_process/mod.rs +++ b/crates/bevy_core_pipeline/src/post_process/mod.rs @@ -10,8 +10,9 @@ use bevy_ecs::{ entity::Entity, query::{QueryItem, With}, reflect::ReflectComponent, + resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; diff --git a/crates/bevy_core_pipeline/src/skybox/mod.rs b/crates/bevy_core_pipeline/src/skybox/mod.rs index 5ca7c3fce2d26..6799af2d52c6d 100644 --- a/crates/bevy_core_pipeline/src/skybox/mod.rs +++ b/crates/bevy_core_pipeline/src/skybox/mod.rs @@ -3,8 +3,9 @@ use bevy_asset::{load_internal_asset, Handle}; use bevy_ecs::{ prelude::{Component, Entity}, query::{QueryItem, With}, + resource::Resource, schedule::IntoSystemConfigs, - system::{Commands, Query, Res, ResMut, Resource}, + system::{Commands, Query, Res, ResMut}, }; use bevy_image::{BevyDefault, Image}; use bevy_math::{Mat4, Quat}; diff --git a/crates/bevy_core_pipeline/src/skybox/prepass.rs b/crates/bevy_core_pipeline/src/skybox/prepass.rs index c51e707808e93..ae7fcd325e7d1 100644 --- a/crates/bevy_core_pipeline/src/skybox/prepass.rs +++ b/crates/bevy_core_pipeline/src/skybox/prepass.rs @@ -5,7 +5,8 @@ use bevy_ecs::{ component::Component, entity::Entity, query::{Has, With}, - system::{Commands, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_render::{ diff --git a/crates/bevy_core_pipeline/src/smaa/mod.rs b/crates/bevy_core_pipeline/src/smaa/mod.rs index 12fc473061acf..3ab4ff1aec7e5 100644 --- a/crates/bevy_core_pipeline/src/smaa/mod.rs +++ b/crates/bevy_core_pipeline/src/smaa/mod.rs @@ -45,8 +45,9 @@ use bevy_ecs::{ entity::Entity, query::{QueryItem, With}, reflect::ReflectComponent, + resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; diff --git a/crates/bevy_core_pipeline/src/taa/mod.rs b/crates/bevy_core_pipeline/src/taa/mod.rs index aadc26cbc68b1..8e7c3a0c2a138 100644 --- a/crates/bevy_core_pipeline/src/taa/mod.rs +++ b/crates/bevy_core_pipeline/src/taa/mod.rs @@ -10,8 +10,9 @@ use bevy_diagnostic::FrameCount; use bevy_ecs::{ prelude::{require, Component, Entity, ReflectComponent}, query::{QueryItem, With}, + resource::Resource, schedule::IntoSystemConfigs, - system::{Commands, Query, Res, ResMut, Resource}, + system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_dev_tools/src/fps_overlay.rs b/crates/bevy_dev_tools/src/fps_overlay.rs index a68324e235137..38e10ec312ea4 100644 --- a/crates/bevy_dev_tools/src/fps_overlay.rs +++ b/crates/bevy_dev_tools/src/fps_overlay.rs @@ -9,8 +9,9 @@ use bevy_ecs::{ component::Component, entity::Entity, query::With, + resource::Resource, schedule::{common_conditions::resource_changed, IntoSystemConfigs}, - system::{Commands, Query, Res, Resource}, + system::{Commands, Query, Res}, }; use bevy_render::view::Visibility; use bevy_text::{Font, TextColor, TextFont, TextSpan}; diff --git a/crates/bevy_diagnostic/src/diagnostic.rs b/crates/bevy_diagnostic/src/diagnostic.rs index 88b1f650e33a5..d4fd054a2d36c 100644 --- a/crates/bevy_diagnostic/src/diagnostic.rs +++ b/crates/bevy_diagnostic/src/diagnostic.rs @@ -5,7 +5,8 @@ use core::{ }; use bevy_app::{App, SubApp}; -use bevy_ecs::system::{Deferred, Res, Resource, SystemBuffer, SystemParam}; +use bevy_ecs::resource::Resource; +use bevy_ecs::system::{Deferred, Res, SystemBuffer, SystemParam}; use bevy_platform_support::time::Instant; use bevy_utils::{HashMap, PassHash}; use const_fnv1a_hash::fnv1a_hash_str_64; diff --git a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs index cd390506cece3..16c9bc2e78469 100644 --- a/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs +++ b/crates/bevy_diagnostic/src/system_information_diagnostics_plugin.rs @@ -1,6 +1,6 @@ use crate::DiagnosticPath; use bevy_app::prelude::*; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; /// Adds a System Information Diagnostic, specifically `cpu_usage` (in %) and `mem_usage` (in %) /// @@ -64,7 +64,7 @@ pub mod internal { use std::{sync::Mutex, time::Instant}; use bevy_app::{App, First, Startup, Update}; - use bevy_ecs::system::Resource; + use bevy_ecs::resource::Resource; use bevy_tasks::{available_parallelism, block_on, poll_once, AsyncComputeTaskPool, Task}; use sysinfo::{CpuRefreshKind, MemoryRefreshKind, RefreshKind, System}; use tracing::info; diff --git a/crates/bevy_ecs/macros/src/component.rs b/crates/bevy_ecs/macros/src/component.rs index 44c25171c250a..ba695bef49550 100644 --- a/crates/bevy_ecs/macros/src/component.rs +++ b/crates/bevy_ecs/macros/src/component.rs @@ -46,7 +46,7 @@ pub fn derive_resource(input: TokenStream) -> TokenStream { let (impl_generics, type_generics, where_clause) = &ast.generics.split_for_impl(); TokenStream::from(quote! { - impl #impl_generics #bevy_ecs_path::system::Resource for #struct_name #type_generics #where_clause { + impl #impl_generics #bevy_ecs_path::resource::Resource for #struct_name #type_generics #where_clause { } }) } diff --git a/crates/bevy_ecs/src/archetype.rs b/crates/bevy_ecs/src/archetype.rs index cb72db3067650..8d0a6d3e5b7c9 100644 --- a/crates/bevy_ecs/src/archetype.rs +++ b/crates/bevy_ecs/src/archetype.rs @@ -766,7 +766,7 @@ struct ArchetypeComponents { /// /// [`Component`]: crate::component::Component /// [`World`]: crate::world::World -/// [`Resource`]: crate::system::Resource +/// [`Resource`]: crate::resource::Resource /// [many-to-many relationship]: https://en.wikipedia.org/wiki/Many-to-many_(data_model) #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct ArchetypeComponentId(usize); diff --git a/crates/bevy_ecs/src/change_detection.rs b/crates/bevy_ecs/src/change_detection.rs index e238287a7ec3d..b486be555d8f4 100644 --- a/crates/bevy_ecs/src/change_detection.rs +++ b/crates/bevy_ecs/src/change_detection.rs @@ -3,7 +3,7 @@ use crate::{ component::{Tick, TickCells}, ptr::PtrMut, - system::Resource, + resource::Resource, }; use alloc::borrow::ToOwned; use bevy_ptr::{Ptr, UnsafeCellDeref}; diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index 73deeacdf0028..f17bbb106c8cb 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -7,8 +7,9 @@ use crate::{ change_detection::MAX_CHANGE_AGE, entity::{ComponentCloneCtx, Entity}, query::DebugCheckedUnwrap, + resource::Resource, storage::{SparseSetIndex, SparseSets, Storages, Table, TableRow}, - system::{Local, Resource, SystemParam}, + system::{Local, SystemParam}, world::{DeferredWorld, FromWorld, World}, }; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_ecs/src/event/collections.rs b/crates/bevy_ecs/src/event/collections.rs index d35c4743ee648..77573d2151b25 100644 --- a/crates/bevy_ecs/src/event/collections.rs +++ b/crates/bevy_ecs/src/event/collections.rs @@ -2,7 +2,7 @@ use crate as bevy_ecs; use alloc::vec::Vec; use bevy_ecs::{ event::{Event, EventCursor, EventId, EventInstance}, - system::Resource, + resource::Resource, }; #[cfg(feature = "track_location")] use core::panic::Location; diff --git a/crates/bevy_ecs/src/event/registry.rs b/crates/bevy_ecs/src/event/registry.rs index 3f92c1134a4cf..070f08f846328 100644 --- a/crates/bevy_ecs/src/event/registry.rs +++ b/crates/bevy_ecs/src/event/registry.rs @@ -4,7 +4,7 @@ use bevy_ecs::{ change_detection::{DetectChangesMut, MutUntyped}, component::{ComponentId, Tick}, event::{Event, Events}, - system::Resource, + resource::Resource, world::World, }; diff --git a/crates/bevy_ecs/src/lib.rs b/crates/bevy_ecs/src/lib.rs index d0b93f0592676..21fc5cddd0c62 100644 --- a/crates/bevy_ecs/src/lib.rs +++ b/crates/bevy_ecs/src/lib.rs @@ -52,6 +52,7 @@ pub mod query; pub mod reflect; pub mod relationship; pub mod removal_detection; +pub mod resource; pub mod result; pub mod schedule; pub mod storage; @@ -81,6 +82,7 @@ pub mod prelude { observer::{CloneEntityWithObserversExt, Observer, Trigger}, query::{Added, AnyOf, Changed, Has, Or, QueryBuilder, QueryState, With, Without}, removal_detection::RemovedComponents, + resource::Resource, result::{Error, Result}, schedule::{ apply_deferred, common_conditions::*, ApplyDeferred, Condition, IntoSystemConfigs, @@ -89,7 +91,7 @@ pub mod prelude { system::{ Command, Commands, Deferred, EntityCommand, EntityCommands, In, InMut, InRef, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Populated, Query, ReadOnlySystem, - Res, ResMut, Resource, Single, System, SystemIn, SystemInput, SystemParamBuilder, + Res, ResMut, Single, System, SystemIn, SystemInput, SystemParamBuilder, SystemParamFunction, WithParamWarnPolicy, }, world::{ @@ -134,7 +136,7 @@ mod tests { entity::Entity, prelude::Or, query::{Added, Changed, FilteredAccess, QueryFilter, With, Without}, - system::Resource, + resource::Resource, world::{EntityMut, EntityRef, Mut, World}, }; use alloc::{ @@ -1223,7 +1225,7 @@ mod tests { #[test] fn resource() { - use crate::system::Resource; + use crate::resource::Resource; #[derive(Resource, PartialEq, Debug)] struct Num(i32); diff --git a/crates/bevy_ecs/src/observer/entity_observer.rs b/crates/bevy_ecs/src/observer/entity_observer.rs index 9fb6beb2a206e..ab2f4b33a2d62 100644 --- a/crates/bevy_ecs/src/observer/entity_observer.rs +++ b/crates/bevy_ecs/src/observer/entity_observer.rs @@ -116,7 +116,8 @@ mod tests { entity::EntityCloneBuilder, event::Event, observer::{CloneEntityWithObserversExt, Trigger}, - system::{ResMut, Resource}, + resource::Resource, + system::ResMut, world::World, }; diff --git a/crates/bevy_ecs/src/reflect/entity_commands.rs b/crates/bevy_ecs/src/reflect/entity_commands.rs index 15dedd8574cb4..3d5dd6815fc78 100644 --- a/crates/bevy_ecs/src/reflect/entity_commands.rs +++ b/crates/bevy_ecs/src/reflect/entity_commands.rs @@ -2,7 +2,8 @@ use crate::{ entity::Entity, prelude::Mut, reflect::{AppTypeRegistry, ReflectBundle, ReflectComponent}, - system::{EntityCommands, Resource}, + resource::Resource, + system::EntityCommands, world::{EntityWorldMut, World}, }; use alloc::{borrow::Cow, boxed::Box}; diff --git a/crates/bevy_ecs/src/reflect/mod.rs b/crates/bevy_ecs/src/reflect/mod.rs index ba27538d2ade9..9d30fea57b00a 100644 --- a/crates/bevy_ecs/src/reflect/mod.rs +++ b/crates/bevy_ecs/src/reflect/mod.rs @@ -6,7 +6,7 @@ use core::{ }; use crate as bevy_ecs; -use crate::{system::Resource, world::World}; +use crate::{resource::Resource, world::World}; use bevy_reflect::{ std_traits::ReflectDefault, PartialReflect, Reflect, ReflectFromReflect, TypePath, TypeRegistry, TypeRegistryArc, diff --git a/crates/bevy_ecs/src/reflect/resource.rs b/crates/bevy_ecs/src/reflect/resource.rs index f9da7adc7c9a2..238fd5f4e77ae 100644 --- a/crates/bevy_ecs/src/reflect/resource.rs +++ b/crates/bevy_ecs/src/reflect/resource.rs @@ -7,7 +7,7 @@ use crate::{ change_detection::Mut, component::ComponentId, - system::Resource, + resource::Resource, world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_reflect::{FromReflect, FromType, PartialReflect, Reflect, TypePath, TypeRegistry}; diff --git a/crates/bevy_ecs/src/resource.rs b/crates/bevy_ecs/src/resource.rs new file mode 100644 index 0000000000000..c3f7805631560 --- /dev/null +++ b/crates/bevy_ecs/src/resource.rs @@ -0,0 +1,75 @@ +//! Resources are unique, singleton-like data types that can be accessed from systems and stored in the [`World`](crate::world::World). + +// The derive macro for the `Resource` trait +pub use bevy_ecs_macros::Resource; + +/// A type that can be inserted into a [`World`] as a singleton. +/// +/// You can access resource data in systems using the [`Res`] and [`ResMut`] system parameters +/// +/// Only one resource of each type can be stored in a [`World`] at any given time. +/// +/// # Examples +/// +/// ``` +/// # let mut world = World::default(); +/// # let mut schedule = Schedule::default(); +/// # use bevy_ecs::prelude::*; +/// #[derive(Resource)] +/// struct MyResource { value: u32 } +/// +/// world.insert_resource(MyResource { value: 42 }); +/// +/// fn read_resource_system(resource: Res) { +/// assert_eq!(resource.value, 42); +/// } +/// +/// fn write_resource_system(mut resource: ResMut) { +/// assert_eq!(resource.value, 42); +/// resource.value = 0; +/// assert_eq!(resource.value, 0); +/// } +/// # schedule.add_systems((read_resource_system, write_resource_system).chain()); +/// # schedule.run(&mut world); +/// ``` +/// +/// # `!Sync` Resources +/// A `!Sync` type cannot implement `Resource`. However, it is possible to wrap a `Send` but not `Sync` +/// type in [`SyncCell`] or the currently unstable [`Exclusive`] to make it `Sync`. This forces only +/// having mutable access (`&mut T` only, never `&T`), but makes it safe to reference across multiple +/// threads. +/// +/// This will fail to compile since `RefCell` is `!Sync`. +/// ```compile_fail +/// # use std::cell::RefCell; +/// # use bevy_ecs::resource::Resource; +/// +/// #[derive(Resource)] +/// struct NotSync { +/// counter: RefCell, +/// } +/// ``` +/// +/// This will compile since the `RefCell` is wrapped with `SyncCell`. +/// ``` +/// # use std::cell::RefCell; +/// # use bevy_ecs::resource::Resource; +/// use bevy_utils::synccell::SyncCell; +/// +/// #[derive(Resource)] +/// struct ActuallySync { +/// counter: SyncCell>, +/// } +/// ``` +/// +/// [`Exclusive`]: https://doc.rust-lang.org/nightly/std/sync/struct.Exclusive.html +/// [`World`]: crate::world::World +/// [`Res`]: crate::system::Res +/// [`ResMut`]: crate::system::ResMut +/// [`SyncCell`]: bevy_utils::synccell::SyncCell +#[diagnostic::on_unimplemented( + message = "`{Self}` is not a `Resource`", + label = "invalid `Resource`", + note = "consider annotating `{Self}` with `#[derive(Resource)]`" +)] +pub trait Resource: Send + Sync + 'static {} diff --git a/crates/bevy_ecs/src/schedule/condition.rs b/crates/bevy_ecs/src/schedule/condition.rs index 112d6d9481f4e..f80a0ad086aed 100644 --- a/crates/bevy_ecs/src/schedule/condition.rs +++ b/crates/bevy_ecs/src/schedule/condition.rs @@ -400,7 +400,8 @@ pub mod common_conditions { prelude::{Component, Query, With}, query::QueryFilter, removal_detection::RemovedComponents, - system::{In, IntoSystem, Local, Res, Resource, System, SystemInput}, + resource::Resource, + system::{In, IntoSystem, Local, Res, System, SystemInput}, }; use alloc::format; diff --git a/crates/bevy_ecs/src/schedule/mod.rs b/crates/bevy_ecs/src/schedule/mod.rs index 59340f0d9228d..cd565173eaf06 100644 --- a/crates/bevy_ecs/src/schedule/mod.rs +++ b/crates/bevy_ecs/src/schedule/mod.rs @@ -22,8 +22,9 @@ mod tests { pub use crate as bevy_ecs; pub use crate::{ prelude::World, + resource::Resource, schedule::{Schedule, SystemSet}, - system::{Res, ResMut, Resource}, + system::{Res, ResMut}, }; #[derive(SystemSet, Clone, Debug, PartialEq, Eq, Hash)] diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 33568ec09f5f5..eca575a9491c0 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -23,9 +23,10 @@ use crate::{ self as bevy_ecs, component::{ComponentId, Components, Tick}, prelude::Component, + resource::Resource, result::Result, schedule::*, - system::{IntoSystem, Resource, ScheduleSystem}, + system::{IntoSystem, ScheduleSystem}, world::World, }; diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index a48ccd16ae803..010e9b5303848 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -217,8 +217,8 @@ where #[cfg(test)] mod tests { use crate::{ + resource::Resource, schedule::{tests::ResMut, Schedule}, - system::Resource, }; use super::*; diff --git a/crates/bevy_ecs/src/schedule/stepping.rs b/crates/bevy_ecs/src/schedule/stepping.rs index 7855053de6fb7..26d04655b4a23 100644 --- a/crates/bevy_ecs/src/schedule/stepping.rs +++ b/crates/bevy_ecs/src/schedule/stepping.rs @@ -1,6 +1,7 @@ use crate::{ + resource::Resource, schedule::{InternedScheduleLabel, NodeId, Schedule, ScheduleLabel}, - system::{IntoSystem, ResMut, Resource}, + system::{IntoSystem, ResMut}, }; use alloc::vec::Vec; use bevy_utils::{HashMap, TypeIdMap}; diff --git a/crates/bevy_ecs/src/storage/resource.rs b/crates/bevy_ecs/src/storage/resource.rs index 501c6e80a535b..ac9bbfa54d76d 100644 --- a/crates/bevy_ecs/src/storage/resource.rs +++ b/crates/bevy_ecs/src/storage/resource.rs @@ -308,7 +308,7 @@ impl ResourceData { /// The backing store for all [`Resource`]s stored in the [`World`]. /// -/// [`Resource`]: crate::system::Resource +/// [`Resource`]: crate::resource::Resource /// [`World`]: crate::world::World #[derive(Default)] pub struct Resources { diff --git a/crates/bevy_ecs/src/system/builder.rs b/crates/bevy_ecs/src/system/builder.rs index 89ec9f25189fc..c7605764e98f7 100644 --- a/crates/bevy_ecs/src/system/builder.rs +++ b/crates/bevy_ecs/src/system/builder.rs @@ -5,6 +5,7 @@ use variadics_please::all_tuples; use crate::{ prelude::QueryBuilder, query::{QueryData, QueryFilter, QueryState}, + resource::Resource, system::{ DynSystemParam, DynSystemParamState, Local, ParamSet, Query, SystemMeta, SystemParam, }, @@ -15,7 +16,7 @@ use crate::{ }; use core::fmt::Debug; -use super::{init_query_param, Res, ResMut, Resource, SystemState}; +use super::{init_query_param, Res, ResMut, SystemState}; /// A builder that can create a [`SystemParam`]. /// diff --git a/crates/bevy_ecs/src/system/commands/command.rs b/crates/bevy_ecs/src/system/commands/command.rs index bbff4240684d4..71875f9d41edd 100644 --- a/crates/bevy_ecs/src/system/commands/command.rs +++ b/crates/bevy_ecs/src/system/commands/command.rs @@ -12,9 +12,10 @@ use crate::{ entity::Entity, event::{Event, Events}, observer::TriggerTargets, + resource::Resource, result::{Error, Result}, schedule::ScheduleLabel, - system::{error_handler, IntoSystem, Resource, SystemId, SystemInput}, + system::{error_handler, IntoSystem, SystemId, SystemInput}, world::{FromWorld, SpawnBatchIter, World}, }; diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index d68c1f5a6769c..b68e46667f350 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -26,11 +26,12 @@ use crate::{ entity::{Entities, Entity, EntityCloneBuilder}, event::Event, observer::{Observer, TriggerTargets}, + resource::Resource, result::Error, schedule::ScheduleLabel, system::{ command::HandleError, entity_command::CommandWithEntity, input::SystemInput, Deferred, - IntoObserverSystem, IntoSystem, RegisteredSystem, Resource, SystemId, + IntoObserverSystem, IntoSystem, RegisteredSystem, SystemId, }, world::{ command_queue::RawCommandQueue, unsafe_world_cell::UnsafeWorldCell, CommandQueue, @@ -2166,7 +2167,8 @@ mod tests { use crate::{ self as bevy_ecs, component::{require, Component}, - system::{Commands, Resource}, + resource::Resource, + system::Commands, world::{CommandQueue, FromWorld, World}, }; use alloc::{string::String, sync::Arc, vec, vec::Vec}; diff --git a/crates/bevy_ecs/src/system/mod.rs b/crates/bevy_ecs/src/system/mod.rs index 72dcbfb11e996..824b178464960 100644 --- a/crates/bevy_ecs/src/system/mod.rs +++ b/crates/bevy_ecs/src/system/mod.rs @@ -339,6 +339,7 @@ mod tests { prelude::{AnyOf, EntityRef}, query::{Added, Changed, Or, With, Without}, removal_detection::RemovedComponents, + resource::Resource, result::Result, schedule::{ common_conditions::resource_exists, ApplyDeferred, Condition, IntoSystemConfigs, @@ -346,7 +347,7 @@ mod tests { }, system::{ Commands, In, IntoSystem, Local, NonSend, NonSendMut, ParamSet, Query, Res, ResMut, - Resource, Single, StaticSystemParam, System, SystemState, + Single, StaticSystemParam, System, SystemState, }, world::{EntityMut, FromWorld, World}, }; @@ -397,7 +398,7 @@ mod tests { #[test] fn get_many_is_ordered() { - use crate::system::Resource; + use crate::resource::Resource; const ENTITIES_COUNT: usize = 1000; #[derive(Resource)] @@ -478,7 +479,7 @@ mod tests { #[test] fn changed_resource_system() { - use crate::system::Resource; + use crate::resource::Resource; #[derive(Resource)] struct Flipper(bool); diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index 8358bc66af827..ae4cd0b9366fe 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -9,6 +9,7 @@ use crate::{ Access, FilteredAccess, FilteredAccessSet, QueryData, QueryFilter, QuerySingleError, QueryState, ReadOnlyQueryData, }, + resource::Resource, storage::ResourceData, system::{Query, Single, SystemMeta}, world::{ @@ -17,7 +18,7 @@ use crate::{ }, }; use alloc::{borrow::ToOwned, boxed::Box, vec::Vec}; -pub use bevy_ecs_macros::{Resource, SystemParam}; +pub use bevy_ecs_macros::SystemParam; use bevy_ptr::UnsafeCellDeref; use bevy_utils::synccell::SyncCell; #[cfg(feature = "track_location")] @@ -797,73 +798,6 @@ macro_rules! impl_param_set { all_tuples_enumerated!(impl_param_set, 1, 8, P, m, p); -/// A type that can be inserted into a [`World`] as a singleton. -/// -/// You can access resource data in systems using the [`Res`] and [`ResMut`] system parameters -/// -/// Only one resource of each type can be stored in a [`World`] at any given time. -/// -/// # Examples -/// -/// ``` -/// # let mut world = World::default(); -/// # let mut schedule = Schedule::default(); -/// # use bevy_ecs::prelude::*; -/// #[derive(Resource)] -/// struct MyResource { value: u32 } -/// -/// world.insert_resource(MyResource { value: 42 }); -/// -/// fn read_resource_system(resource: Res) { -/// assert_eq!(resource.value, 42); -/// } -/// -/// fn write_resource_system(mut resource: ResMut) { -/// assert_eq!(resource.value, 42); -/// resource.value = 0; -/// assert_eq!(resource.value, 0); -/// } -/// # schedule.add_systems((read_resource_system, write_resource_system).chain()); -/// # schedule.run(&mut world); -/// ``` -/// -/// # `!Sync` Resources -/// A `!Sync` type cannot implement `Resource`. However, it is possible to wrap a `Send` but not `Sync` -/// type in [`SyncCell`] or the currently unstable [`Exclusive`] to make it `Sync`. This forces only -/// having mutable access (`&mut T` only, never `&T`), but makes it safe to reference across multiple -/// threads. -/// -/// This will fail to compile since `RefCell` is `!Sync`. -/// ```compile_fail -/// # use std::cell::RefCell; -/// # use bevy_ecs::system::Resource; -/// -/// #[derive(Resource)] -/// struct NotSync { -/// counter: RefCell, -/// } -/// ``` -/// -/// This will compile since the `RefCell` is wrapped with `SyncCell`. -/// ``` -/// # use std::cell::RefCell; -/// # use bevy_ecs::system::Resource; -/// use bevy_utils::synccell::SyncCell; -/// -/// #[derive(Resource)] -/// struct ActuallySync { -/// counter: SyncCell>, -/// } -/// ``` -/// -/// [`Exclusive`]: https://doc.rust-lang.org/nightly/std/sync/struct.Exclusive.html -#[diagnostic::on_unimplemented( - message = "`{Self}` is not a `Resource`", - label = "invalid `Resource`", - note = "consider annotating `{Self}` with `#[derive(Resource)]`" -)] -pub trait Resource: Send + Sync + 'static {} - // SAFETY: Res only reads a single World resource unsafe impl<'a, T: Resource> ReadOnlySystemParam for Res<'a, T> {} diff --git a/crates/bevy_ecs/src/world/command_queue.rs b/crates/bevy_ecs/src/world/command_queue.rs index 5b78b7a974e3f..f1563643fcc8c 100644 --- a/crates/bevy_ecs/src/world/command_queue.rs +++ b/crates/bevy_ecs/src/world/command_queue.rs @@ -335,7 +335,7 @@ impl SystemBuffer for CommandQueue { #[cfg(test)] mod test { use super::*; - use crate::{self as bevy_ecs, system::Resource}; + use crate::{self as bevy_ecs, resource::Resource}; use alloc::{borrow::ToOwned, string::String, sync::Arc}; use core::{ panic::AssertUnwindSafe, diff --git a/crates/bevy_ecs/src/world/deferred_world.rs b/crates/bevy_ecs/src/world/deferred_world.rs index 9a6674afe56db..8d77503f8c73a 100644 --- a/crates/bevy_ecs/src/world/deferred_world.rs +++ b/crates/bevy_ecs/src/world/deferred_world.rs @@ -9,7 +9,8 @@ use crate::{ observer::{Observers, TriggerTargets}, prelude::{Component, QueryState}, query::{QueryData, QueryFilter}, - system::{Commands, Query, Resource}, + resource::Resource, + system::{Commands, Query}, traversal::Traversal, world::{error::EntityFetchError, WorldEntityFetch}, }; diff --git a/crates/bevy_ecs/src/world/entity_ref.rs b/crates/bevy_ecs/src/world/entity_ref.rs index 66018f7a4e476..d4ebad7efe7a5 100644 --- a/crates/bevy_ecs/src/world/entity_ref.rs +++ b/crates/bevy_ecs/src/world/entity_ref.rs @@ -10,8 +10,9 @@ use crate::{ observer::Observer, query::{Access, ReadOnlyQueryData}, removal_detection::RemovedComponentEvents, + resource::Resource, storage::Storages, - system::{IntoObserverSystem, Resource}, + system::IntoObserverSystem, world::{ error::EntityComponentError, unsafe_world_cell::UnsafeEntityCell, DeferredWorld, Mut, Ref, World, ON_DESPAWN, ON_REMOVE, ON_REPLACE, diff --git a/crates/bevy_ecs/src/world/filtered_resource.rs b/crates/bevy_ecs/src/world/filtered_resource.rs index b2fe54478b6bb..78794866e84b5 100644 --- a/crates/bevy_ecs/src/world/filtered_resource.rs +++ b/crates/bevy_ecs/src/world/filtered_resource.rs @@ -2,7 +2,7 @@ use crate::{ change_detection::{Mut, MutUntyped, Ref, Ticks, TicksMut}, component::{ComponentId, Tick}, query::Access, - system::Resource, + resource::Resource, world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_ptr::Ptr; diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 7ebd8b07f0017..e34e2752c2b25 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -44,10 +44,11 @@ use crate::{ observer::Observers, query::{DebugCheckedUnwrap, QueryData, QueryFilter, QueryState}, removal_detection::RemovedComponentEvents, + resource::Resource, result::Result, schedule::{Schedule, ScheduleLabel, Schedules}, storage::{ResourceData, Storages}, - system::{Commands, Resource}, + system::Commands, world::{ command_queue::RawCommandQueue, error::{EntityFetchError, TryRunScheduleError}, @@ -3698,7 +3699,7 @@ mod tests { component::{ComponentDescriptor, ComponentInfo, StorageType}, entity::hash_set::EntityHashSet, ptr::OwningPtr, - system::Resource, + resource::Resource, world::error::EntityFetchError, }; use alloc::{ diff --git a/crates/bevy_ecs/src/world/unsafe_world_cell.rs b/crates/bevy_ecs/src/world/unsafe_world_cell.rs index 7bf9e9f53a4d0..a5ff0f2c9a0bd 100644 --- a/crates/bevy_ecs/src/world/unsafe_world_cell.rs +++ b/crates/bevy_ecs/src/world/unsafe_world_cell.rs @@ -11,8 +11,8 @@ use crate::{ prelude::Component, query::{DebugCheckedUnwrap, ReadOnlyQueryData}, removal_detection::RemovedComponentEvents, + resource::Resource, storage::{ComponentSparseSet, Storages, Table}, - system::Resource, world::RawCommandQueue, }; use bevy_platform_support::sync::atomic::Ordering; @@ -51,7 +51,7 @@ use {bevy_ptr::UnsafeCellDeref, core::panic::Location}; /// ``` /// use bevy_ecs::world::World; /// use bevy_ecs::change_detection::Mut; -/// use bevy_ecs::system::Resource; +/// use bevy_ecs::resource::Resource; /// use bevy_ecs::world::unsafe_world_cell::UnsafeWorldCell; /// /// // INVARIANT: existence of this struct means that users of it are the only ones being able to access resources in the world diff --git a/crates/bevy_gizmos/src/config.rs b/crates/bevy_gizmos/src/config.rs index 76b22bead2495..a7e60088b6d7b 100644 --- a/crates/bevy_gizmos/src/config.rs +++ b/crates/bevy_gizmos/src/config.rs @@ -9,7 +9,7 @@ pub use bevy_gizmos_macros::GizmoConfigGroup; ))] use {crate::GizmoAsset, bevy_asset::Handle, bevy_ecs::component::Component}; -use bevy_ecs::{reflect::ReflectResource, system::Resource}; +use bevy_ecs::{reflect::ReflectResource, resource::Resource}; use bevy_reflect::{std_traits::ReflectDefault, Reflect, TypePath}; use bevy_utils::TypeIdMap; use core::{ diff --git a/crates/bevy_gizmos/src/gizmos.rs b/crates/bevy_gizmos/src/gizmos.rs index 04f5404c8d20a..b1fe363f510cb 100644 --- a/crates/bevy_gizmos/src/gizmos.rs +++ b/crates/bevy_gizmos/src/gizmos.rs @@ -10,7 +10,8 @@ use core::{ use bevy_color::{Color, LinearRgba}; use bevy_ecs::{ component::Tick, - system::{Deferred, ReadOnlySystemParam, Res, Resource, SystemBuffer, SystemMeta, SystemParam}, + resource::Resource, + system::{Deferred, ReadOnlySystemParam, Res, SystemBuffer, SystemMeta, SystemParam}, world::{unsafe_world_cell::UnsafeWorldCell, World}, }; use bevy_math::{Isometry2d, Isometry3d, Vec2, Vec3}; diff --git a/crates/bevy_gizmos/src/lib.rs b/crates/bevy_gizmos/src/lib.rs index a7bca0769a352..2a7baab6dfa0a 100644 --- a/crates/bevy_gizmos/src/lib.rs +++ b/crates/bevy_gizmos/src/lib.rs @@ -78,8 +78,9 @@ pub mod prelude { use bevy_app::{App, FixedFirst, FixedLast, Last, Plugin, RunFixedMainLoop}; use bevy_asset::{Asset, AssetApp, AssetId, Assets, Handle}; use bevy_ecs::{ + resource::Resource, schedule::{IntoSystemConfigs, SystemSet}, - system::{Res, ResMut, Resource}, + system::{Res, ResMut}, }; use bevy_math::{Vec3, Vec4}; use bevy_reflect::TypePath; diff --git a/crates/bevy_gizmos/src/pipeline_2d.rs b/crates/bevy_gizmos/src/pipeline_2d.rs index 13c9b89dd98ff..72a2428ff0b5b 100644 --- a/crates/bevy_gizmos/src/pipeline_2d.rs +++ b/crates/bevy_gizmos/src/pipeline_2d.rs @@ -9,8 +9,9 @@ use bevy_core_pipeline::core_2d::{Transparent2d, CORE_2D_DEPTH_FORMAT}; use bevy_ecs::{ prelude::Entity, + resource::Resource, schedule::{IntoSystemConfigs, IntoSystemSetConfigs}, - system::{Query, Res, ResMut, Resource}, + system::{Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_gizmos/src/pipeline_3d.rs b/crates/bevy_gizmos/src/pipeline_3d.rs index aac6358d638bf..f7806b64d65bf 100644 --- a/crates/bevy_gizmos/src/pipeline_3d.rs +++ b/crates/bevy_gizmos/src/pipeline_3d.rs @@ -13,8 +13,9 @@ use bevy_core_pipeline::{ use bevy_ecs::{ prelude::Entity, query::Has, + resource::Resource, schedule::{IntoSystemConfigs, IntoSystemSetConfigs}, - system::{Query, Res, ResMut, Resource}, + system::{Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_gltf/src/loader.rs b/crates/bevy_gltf/src/loader.rs index 487515a6d90e9..f809101ab0fbf 100644 --- a/crates/bevy_gltf/src/loader.rs +++ b/crates/bevy_gltf/src/loader.rs @@ -2293,7 +2293,7 @@ mod test { }, AssetApp, AssetPlugin, AssetServer, Assets, Handle, LoadState, }; - use bevy_ecs::{system::Resource, world::World}; + use bevy_ecs::{resource::Resource, world::World}; use bevy_log::LogPlugin; use bevy_render::mesh::{skinning::SkinnedMeshInverseBindposes, MeshPlugin}; use bevy_scene::ScenePlugin; diff --git a/crates/bevy_input/src/axis.rs b/crates/bevy_input/src/axis.rs index ffaadf01202d0..99b8315f136fe 100644 --- a/crates/bevy_input/src/axis.rs +++ b/crates/bevy_input/src/axis.rs @@ -1,6 +1,6 @@ //! The generic axis type. -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use bevy_utils::HashMap; use core::hash::Hash; diff --git a/crates/bevy_input/src/button_input.rs b/crates/bevy_input/src/button_input.rs index c781fafe49ac6..a6f0583e36b7a 100644 --- a/crates/bevy_input/src/button_input.rs +++ b/crates/bevy_input/src/button_input.rs @@ -1,6 +1,6 @@ //! The generic input type. -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use bevy_utils::HashSet; use core::hash::Hash; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_input/src/mouse.rs b/crates/bevy_input/src/mouse.rs index a6fd70f013712..c19eff6b878ef 100644 --- a/crates/bevy_input/src/mouse.rs +++ b/crates/bevy_input/src/mouse.rs @@ -5,7 +5,8 @@ use bevy_ecs::{ change_detection::DetectChangesMut, entity::Entity, event::{Event, EventReader}, - system::{ResMut, Resource}, + resource::Resource, + system::ResMut, }; use bevy_math::Vec2; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_input/src/touch.rs b/crates/bevy_input/src/touch.rs index a67d1bc2b2f68..a246e204f1e57 100644 --- a/crates/bevy_input/src/touch.rs +++ b/crates/bevy_input/src/touch.rs @@ -3,7 +3,8 @@ use bevy_ecs::{ entity::Entity, event::{Event, EventReader}, - system::{ResMut, Resource}, + resource::Resource, + system::ResMut, }; use bevy_math::Vec2; #[cfg(feature = "bevy_reflect")] diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 8328744e5b024..f0743f022de0f 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -62,7 +62,7 @@ use tracing_subscriber::{ }; #[cfg(feature = "tracing-chrome")] use { - bevy_ecs::system::Resource, + bevy_ecs::resource::Resource, bevy_utils::synccell::SyncCell, tracing_subscriber::fmt::{format::DefaultFields, FormattedFields}, }; diff --git a/crates/bevy_mesh/src/vertex.rs b/crates/bevy_mesh/src/vertex.rs index 8776b99bb4c5c..2e85cce1b9f3f 100644 --- a/crates/bevy_mesh/src/vertex.rs +++ b/crates/bevy_mesh/src/vertex.rs @@ -1,6 +1,6 @@ use alloc::sync::Arc; use bevy_derive::EnumVariantMeta; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use bevy_math::Vec3; use bevy_utils::HashSet; use bytemuck::cast_slice; diff --git a/crates/bevy_pbr/src/cluster/mod.rs b/crates/bevy_pbr/src/cluster/mod.rs index 6a2baa554ad69..68fea8de0990e 100644 --- a/crates/bevy_pbr/src/cluster/mod.rs +++ b/crates/bevy_pbr/src/cluster/mod.rs @@ -8,7 +8,8 @@ use bevy_ecs::{ entity::{hash_map::EntityHashMap, Entity}, query::{With, Without}, reflect::ReflectComponent, - system::{Commands, Query, Res, Resource}, + resource::Resource, + system::{Commands, Query, Res}, world::{FromWorld, World}, }; use bevy_math::{uvec4, AspectRatio, UVec2, UVec3, UVec4, Vec3Swizzles as _, Vec4}; diff --git a/crates/bevy_pbr/src/light_probe/mod.rs b/crates/bevy_pbr/src/light_probe/mod.rs index 75bf47b5ce61a..ae2c4b05735eb 100644 --- a/crates/bevy_pbr/src/light_probe/mod.rs +++ b/crates/bevy_pbr/src/light_probe/mod.rs @@ -9,8 +9,9 @@ use bevy_ecs::{ entity::Entity, query::With, reflect::ReflectComponent, + resource::Resource, schedule::IntoSystemConfigs, - system::{Commands, Local, Query, Res, ResMut, Resource}, + system::{Commands, Local, Query, Res, ResMut}, }; use bevy_image::Image; use bevy_math::{Affine3A, FloatOrd, Mat4, Vec3A, Vec4}; diff --git a/crates/bevy_pbr/src/lightmap/mod.rs b/crates/bevy_pbr/src/lightmap/mod.rs index 3a7b8aa3ad80e..ee38a94d3bcc4 100644 --- a/crates/bevy_pbr/src/lightmap/mod.rs +++ b/crates/bevy_pbr/src/lightmap/mod.rs @@ -40,8 +40,9 @@ use bevy_ecs::{ query::{Changed, Or}, reflect::ReflectComponent, removal_detection::RemovedComponents, + resource::Resource, schedule::IntoSystemConfigs, - system::{Query, Res, ResMut, Resource}, + system::{Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::Image; diff --git a/crates/bevy_pbr/src/material_bind_groups.rs b/crates/bevy_pbr/src/material_bind_groups.rs index a7c06dfcf21ad..fddd4d7712cba 100644 --- a/crates/bevy_pbr/src/material_bind_groups.rs +++ b/crates/bevy_pbr/src/material_bind_groups.rs @@ -7,7 +7,7 @@ use crate::Material; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - system::Resource, + resource::Resource, world::{FromWorld, World}, }; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; diff --git a/crates/bevy_pbr/src/meshlet/instance_manager.rs b/crates/bevy_pbr/src/meshlet/instance_manager.rs index e87f100f8a139..f19cb0a008efe 100644 --- a/crates/bevy_pbr/src/meshlet/instance_manager.rs +++ b/crates/bevy_pbr/src/meshlet/instance_manager.rs @@ -8,7 +8,8 @@ use bevy_ecs::{ entity::{hash_map::EntityHashMap, Entities, Entity}, event::EventReader, query::Has, - system::{Local, Query, Res, ResMut, Resource, SystemState}, + resource::Resource, + system::{Local, Query, Res, ResMut, SystemState}, }; use bevy_render::{ render_resource::StorageBuffer, sync_world::MainEntity, view::RenderLayers, MainWorld, diff --git a/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs b/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs index 4cae0d50d19f5..fe9064ebc263c 100644 --- a/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs +++ b/crates/bevy_pbr/src/meshlet/meshlet_mesh_manager.rs @@ -6,7 +6,8 @@ use super::{ use alloc::sync::Arc; use bevy_asset::{AssetId, Assets}; use bevy_ecs::{ - system::{Res, ResMut, Resource}, + resource::Resource, + system::{Res, ResMut}, world::{FromWorld, World}, }; use bevy_math::Vec2; diff --git a/crates/bevy_pbr/src/meshlet/pipelines.rs b/crates/bevy_pbr/src/meshlet/pipelines.rs index 97f1203d2d3b2..2d271c678d5a8 100644 --- a/crates/bevy_pbr/src/meshlet/pipelines.rs +++ b/crates/bevy_pbr/src/meshlet/pipelines.rs @@ -4,7 +4,7 @@ use bevy_core_pipeline::{ core_3d::CORE_3D_DEPTH_FORMAT, fullscreen_vertex_shader::fullscreen_shader_vertex_state, }; use bevy_ecs::{ - system::Resource, + resource::Resource, world::{FromWorld, World}, }; use bevy_render::render_resource::*; diff --git a/crates/bevy_pbr/src/meshlet/resource_manager.rs b/crates/bevy_pbr/src/meshlet/resource_manager.rs index 05c7e52249594..653c90f162273 100644 --- a/crates/bevy_pbr/src/meshlet/resource_manager.rs +++ b/crates/bevy_pbr/src/meshlet/resource_manager.rs @@ -9,7 +9,8 @@ use bevy_ecs::{ component::Component, entity::{hash_map::EntityHashMap, Entity}, query::AnyOf, - system::{Commands, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, Query, Res, ResMut}, }; use bevy_math::{UVec2, Vec4Swizzles}; use bevy_render::{ diff --git a/crates/bevy_pbr/src/render/gpu_preprocess.rs b/crates/bevy_pbr/src/render/gpu_preprocess.rs index 8ac5a7c96e29c..dac3c68068ac7 100644 --- a/crates/bevy_pbr/src/render/gpu_preprocess.rs +++ b/crates/bevy_pbr/src/render/gpu_preprocess.rs @@ -16,8 +16,9 @@ use bevy_ecs::{ component::Component, entity::Entity, query::{Has, QueryState, Without}, + resource::Resource, schedule::{common_conditions::resource_exists, IntoSystemConfigs as _}, - system::{lifetimeless::Read, Commands, Res, ResMut, Resource}, + system::{lifetimeless::Read, Commands, Res, ResMut}, world::{FromWorld, World}, }; use bevy_render::{ diff --git a/crates/bevy_pbr/src/render/mesh_view_bindings.rs b/crates/bevy_pbr/src/render/mesh_view_bindings.rs index 385c942c46835..99ac659cff28b 100644 --- a/crates/bevy_pbr/src/render/mesh_view_bindings.rs +++ b/crates/bevy_pbr/src/render/mesh_view_bindings.rs @@ -12,7 +12,8 @@ use bevy_ecs::{ component::Component, entity::Entity, query::Has, - system::{Commands, Query, Res, Resource}, + resource::Resource, + system::{Commands, Query, Res}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_pbr/src/ssao/mod.rs b/crates/bevy_pbr/src/ssao/mod.rs index 96c88702312e9..cdb069b2a1d93 100644 --- a/crates/bevy_pbr/src/ssao/mod.rs +++ b/crates/bevy_pbr/src/ssao/mod.rs @@ -10,8 +10,9 @@ use bevy_ecs::{ prelude::{require, Component, Entity}, query::{Has, QueryItem, With}, reflect::ReflectComponent, + resource::Resource, schedule::IntoSystemConfigs, - system::{Commands, Query, Res, ResMut, Resource}, + system::{Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; diff --git a/crates/bevy_pbr/src/ssr/mod.rs b/crates/bevy_pbr/src/ssr/mod.rs index aa4e1037d5196..4d2847f986cab 100644 --- a/crates/bevy_pbr/src/ssr/mod.rs +++ b/crates/bevy_pbr/src/ssr/mod.rs @@ -16,8 +16,9 @@ use bevy_ecs::{ entity::Entity, query::{Has, QueryItem, With}, reflect::ReflectComponent, + resource::Resource, schedule::IntoSystemConfigs as _, - system::{lifetimeless::Read, Commands, Query, Res, ResMut, Resource}, + system::{lifetimeless::Read, Commands, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::BevyDefault as _; diff --git a/crates/bevy_pbr/src/volumetric_fog/render.rs b/crates/bevy_pbr/src/volumetric_fog/render.rs index a9eedad1e8e70..753bf67d68625 100644 --- a/crates/bevy_pbr/src/volumetric_fog/render.rs +++ b/crates/bevy_pbr/src/volumetric_fog/render.rs @@ -13,7 +13,8 @@ use bevy_ecs::{ component::Component, entity::Entity, query::{Has, QueryItem, With}, - system::{lifetimeless::Read, Commands, Local, Query, Res, ResMut, Resource}, + resource::Resource, + system::{lifetimeless::Read, Commands, Local, Query, Res, ResMut}, world::{FromWorld, World}, }; use bevy_image::{BevyDefault, Image}; diff --git a/crates/bevy_remote/src/builtin_methods.rs b/crates/bevy_remote/src/builtin_methods.rs index d9ffc03d1986d..5bdae8048f7e2 100644 --- a/crates/bevy_remote/src/builtin_methods.rs +++ b/crates/bevy_remote/src/builtin_methods.rs @@ -1512,7 +1512,7 @@ mod tests { ); } use super::*; - use bevy_ecs::{component::Component, system::Resource}; + use bevy_ecs::{component::Component, resource::Resource}; use bevy_reflect::Reflect; #[test] diff --git a/crates/bevy_remote/src/http.rs b/crates/bevy_remote/src/http.rs index 04c99ea21010f..4e36e4a0bfe94 100644 --- a/crates/bevy_remote/src/http.rs +++ b/crates/bevy_remote/src/http.rs @@ -15,7 +15,8 @@ use anyhow::Result as AnyhowResult; use async_channel::{Receiver, Sender}; use async_io::Async; use bevy_app::{App, Plugin, Startup}; -use bevy_ecs::system::{Res, Resource}; +use bevy_ecs::resource::Resource; +use bevy_ecs::system::Res; use bevy_tasks::{futures_lite::StreamExt, IoTaskPool}; use core::{ convert::Infallible, diff --git a/crates/bevy_remote/src/lib.rs b/crates/bevy_remote/src/lib.rs index 214d6655ff95c..78ef0bcb3381d 100644 --- a/crates/bevy_remote/src/lib.rs +++ b/crates/bevy_remote/src/lib.rs @@ -323,8 +323,9 @@ use bevy_app::{prelude::*, MainScheduleOrder}; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ entity::Entity, + resource::Resource, schedule::{IntoSystemConfigs, IntoSystemSetConfigs, ScheduleLabel, SystemSet}, - system::{Commands, In, IntoSystem, ResMut, Resource, System, SystemId}, + system::{Commands, In, IntoSystem, ResMut, System, SystemId}, world::World, }; use bevy_utils::{prelude::default, HashMap}; diff --git a/crates/bevy_render/src/batching/gpu_preprocessing.rs b/crates/bevy_render/src/batching/gpu_preprocessing.rs index d9cfbbf334cb3..a6509517930cf 100644 --- a/crates/bevy_render/src/batching/gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/gpu_preprocessing.rs @@ -6,8 +6,9 @@ use bevy_app::{App, Plugin}; use bevy_ecs::{ entity::{hash_map::EntityHashMap, Entity}, query::{Has, With}, + resource::Resource, schedule::IntoSystemConfigs as _, - system::{Query, Res, ResMut, Resource, StaticSystemParam}, + system::{Query, Res, ResMut, StaticSystemParam}, world::{FromWorld, World}, }; use bevy_encase_derive::ShaderType; diff --git a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs index d1e6c5b248ddc..6e0b893028f8d 100644 --- a/crates/bevy_render/src/batching/no_gpu_preprocessing.rs +++ b/crates/bevy_render/src/batching/no_gpu_preprocessing.rs @@ -1,7 +1,8 @@ //! Batching functionality when GPU preprocessing isn't in use. use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::system::{Res, ResMut, Resource, StaticSystemParam}; +use bevy_ecs::resource::Resource; +use bevy_ecs::system::{Res, ResMut, StaticSystemParam}; use smallvec::{smallvec, SmallVec}; use tracing::error; use wgpu::BindingResource; diff --git a/crates/bevy_render/src/camera/camera.rs b/crates/bevy_render/src/camera/camera.rs index 1bc4b3737ad81..f7ef9e09a8830 100644 --- a/crates/bevy_render/src/camera/camera.rs +++ b/crates/bevy_render/src/camera/camera.rs @@ -28,7 +28,8 @@ use bevy_ecs::{ prelude::{require, With}, query::Has, reflect::ReflectComponent, - system::{Commands, Query, Res, ResMut, Resource}, + resource::Resource, + system::{Commands, Query, Res, ResMut}, world::DeferredWorld, }; use bevy_image::Image; diff --git a/crates/bevy_render/src/camera/manual_texture_view.rs b/crates/bevy_render/src/camera/manual_texture_view.rs index 11d82364a611a..34a37807f82a3 100644 --- a/crates/bevy_render/src/camera/manual_texture_view.rs +++ b/crates/bevy_render/src/camera/manual_texture_view.rs @@ -1,5 +1,5 @@ use crate::{extract_resource::ExtractResource, render_resource::TextureView}; -use bevy_ecs::{prelude::Component, reflect::ReflectComponent, system::Resource}; +use bevy_ecs::{prelude::Component, reflect::ReflectComponent, resource::Resource}; use bevy_image::BevyDefault as _; use bevy_math::UVec2; use bevy_reflect::prelude::*; diff --git a/crates/bevy_render/src/diagnostic/internal.rs b/crates/bevy_render/src/diagnostic/internal.rs index 190471f1a265f..b7c045b7c5994 100644 --- a/crates/bevy_render/src/diagnostic/internal.rs +++ b/crates/bevy_render/src/diagnostic/internal.rs @@ -6,7 +6,8 @@ use core::{ use std::thread::{self, ThreadId}; use bevy_diagnostic::{Diagnostic, DiagnosticMeasurement, DiagnosticPath, DiagnosticsStore}; -use bevy_ecs::system::{Res, ResMut, Resource}; +use bevy_ecs::resource::Resource; +use bevy_ecs::system::{Res, ResMut}; use bevy_platform_support::time::Instant; use std::sync::Mutex; use wgpu::{ diff --git a/crates/bevy_render/src/extract_instances.rs b/crates/bevy_render/src/extract_instances.rs index b1344c0e78648..a8e5a9ecbdf92 100644 --- a/crates/bevy_render/src/extract_instances.rs +++ b/crates/bevy_render/src/extract_instances.rs @@ -11,7 +11,8 @@ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::Entity, query::{QueryFilter, QueryItem, ReadOnlyQueryData}, - system::{Query, ResMut, Resource}, + resource::Resource, + system::{Query, ResMut}, }; use crate::sync_world::MainEntityHashMap; diff --git a/crates/bevy_render/src/mesh/allocator.rs b/crates/bevy_render/src/mesh/allocator.rs index f144b371639ee..781e6e195b884 100644 --- a/crates/bevy_render/src/mesh/allocator.rs +++ b/crates/bevy_render/src/mesh/allocator.rs @@ -11,8 +11,9 @@ use bevy_app::{App, Plugin}; use bevy_asset::AssetId; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ + resource::Resource, schedule::IntoSystemConfigs as _, - system::{Res, ResMut, Resource}, + system::{Res, ResMut}, world::{FromWorld, World}, }; use bevy_utils::{default, HashMap, HashSet}; diff --git a/crates/bevy_render/src/pipelined_rendering.rs b/crates/bevy_render/src/pipelined_rendering.rs index 39caaedac7048..ed54a6301a4b7 100644 --- a/crates/bevy_render/src/pipelined_rendering.rs +++ b/crates/bevy_render/src/pipelined_rendering.rs @@ -2,8 +2,8 @@ use async_channel::{Receiver, Sender}; use bevy_app::{App, AppExit, AppLabel, Plugin, SubApp}; use bevy_ecs::{ + resource::Resource, schedule::MainThreadExecutor, - system::Resource, world::{Mut, World}, }; use bevy_tasks::ComputeTaskPool; diff --git a/crates/bevy_render/src/render_graph/graph.rs b/crates/bevy_render/src/render_graph/graph.rs index 96a37286ca237..7793ca0e9ac71 100644 --- a/crates/bevy_render/src/render_graph/graph.rs +++ b/crates/bevy_render/src/render_graph/graph.rs @@ -5,7 +5,7 @@ use crate::{ }, renderer::RenderContext, }; -use bevy_ecs::{define_label, intern::Interned, prelude::World, system::Resource}; +use bevy_ecs::{define_label, intern::Interned, prelude::World, resource::Resource}; use bevy_utils::HashMap; use core::fmt::Debug; diff --git a/crates/bevy_render/src/render_phase/draw.rs b/crates/bevy_render/src/render_phase/draw.rs index 22f4ce5fc8fb6..4343fda6d3941 100644 --- a/crates/bevy_render/src/render_phase/draw.rs +++ b/crates/bevy_render/src/render_phase/draw.rs @@ -3,7 +3,8 @@ use bevy_app::{App, SubApp}; use bevy_ecs::{ entity::Entity, query::{QueryEntityError, QueryState, ROQueryItem, ReadOnlyQueryData}, - system::{ReadOnlySystemParam, Resource, SystemParam, SystemParamItem, SystemState}, + resource::Resource, + system::{ReadOnlySystemParam, SystemParam, SystemParamItem, SystemState}, world::World, }; use bevy_utils::TypeIdMap; diff --git a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs index c4c5906373029..92fb014939f92 100644 --- a/crates/bevy_render/src/render_resource/gpu_array_buffer.rs +++ b/crates/bevy_render/src/render_resource/gpu_array_buffer.rs @@ -6,7 +6,7 @@ use crate::{ render_resource::batched_uniform_buffer::BatchedUniformBuffer, renderer::{RenderDevice, RenderQueue}, }; -use bevy_ecs::{prelude::Component, system::Resource}; +use bevy_ecs::{prelude::Component, resource::Resource}; use core::marker::PhantomData; use encase::{private::WriteInto, ShaderSize, ShaderType}; use nonmax::NonMaxU32; diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 29cca0aba01f6..9afae4f70029b 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -8,7 +8,8 @@ use alloc::{borrow::Cow, sync::Arc}; use bevy_asset::{AssetEvent, AssetId, Assets}; use bevy_ecs::{ event::EventReader, - system::{Res, ResMut, Resource}, + resource::Resource, + system::{Res, ResMut}, }; use bevy_tasks::Task; use bevy_utils::{default, hashbrown::hash_map::EntryRef, HashMap, HashSet}; diff --git a/crates/bevy_render/src/render_resource/pipeline_specializer.rs b/crates/bevy_render/src/render_resource/pipeline_specializer.rs index 7801381acb59a..d2656a5e62318 100644 --- a/crates/bevy_render/src/render_resource/pipeline_specializer.rs +++ b/crates/bevy_render/src/render_resource/pipeline_specializer.rs @@ -5,7 +5,7 @@ use crate::{ RenderPipelineDescriptor, }, }; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use bevy_utils::{ default, hashbrown::hash_map::{RawEntryMut, VacantEntry}, diff --git a/crates/bevy_render/src/render_resource/texture.rs b/crates/bevy_render/src/render_resource/texture.rs index ca8d26b085f43..0da64053e1433 100644 --- a/crates/bevy_render/src/render_resource/texture.rs +++ b/crates/bevy_render/src/render_resource/texture.rs @@ -2,7 +2,7 @@ use crate::define_atomic_id; use crate::renderer::WgpuWrapper; use alloc::sync::Arc; use bevy_derive::{Deref, DerefMut}; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use core::ops::Deref; define_atomic_id!(TextureId); diff --git a/crates/bevy_render/src/renderer/render_device.rs b/crates/bevy_render/src/renderer/render_device.rs index 827d0d2ca328f..97ce7e34856cc 100644 --- a/crates/bevy_render/src/renderer/render_device.rs +++ b/crates/bevy_render/src/renderer/render_device.rs @@ -5,7 +5,7 @@ use crate::render_resource::{ }; use crate::WgpuWrapper; use alloc::sync::Arc; -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use wgpu::{ util::DeviceExt, BindGroupDescriptor, BindGroupEntry, BindGroupLayoutDescriptor, BindGroupLayoutEntry, BufferAsyncError, BufferBindingType, MaintainResult, diff --git a/crates/bevy_render/src/sync_world.rs b/crates/bevy_render/src/sync_world.rs index 15fb582fb7682..31957a1154d94 100644 --- a/crates/bevy_render/src/sync_world.rs +++ b/crates/bevy_render/src/sync_world.rs @@ -7,7 +7,8 @@ use bevy_ecs::{ observer::Trigger, query::With, reflect::ReflectComponent, - system::{Local, Query, ResMut, Resource, SystemState}, + resource::Resource, + system::{Local, Query, ResMut, SystemState}, world::{Mut, OnAdd, OnRemove, World}, }; use bevy_reflect::Reflect; diff --git a/crates/bevy_render/src/texture/fallback_image.rs b/crates/bevy_render/src/texture/fallback_image.rs index fa61b88abfc8d..49e8ea21e60f0 100644 --- a/crates/bevy_render/src/texture/fallback_image.rs +++ b/crates/bevy_render/src/texture/fallback_image.rs @@ -7,7 +7,8 @@ use crate::{ use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ prelude::{FromWorld, Res, ResMut}, - system::{Resource, SystemParam}, + resource::Resource, + system::SystemParam, }; use bevy_image::{BevyDefault, Image, ImageSampler, TextureFormatPixelInfo}; use bevy_utils::HashMap; diff --git a/crates/bevy_render/src/texture/texture_cache.rs b/crates/bevy_render/src/texture/texture_cache.rs index 898d3d7511c3b..fd0fabbd566a8 100644 --- a/crates/bevy_render/src/texture/texture_cache.rs +++ b/crates/bevy_render/src/texture/texture_cache.rs @@ -2,7 +2,7 @@ use crate::{ render_resource::{Texture, TextureView}, renderer::RenderDevice, }; -use bevy_ecs::{prelude::ResMut, system::Resource}; +use bevy_ecs::{prelude::ResMut, resource::Resource}; use bevy_utils::{Entry, HashMap}; use wgpu::{TextureDescriptor, TextureViewDescriptor}; diff --git a/crates/bevy_render/src/view/visibility/range.rs b/crates/bevy_render/src/view/visibility/range.rs index e6f6484d05584..5984e3ec88dcb 100644 --- a/crates/bevy_render/src/view/visibility/range.rs +++ b/crates/bevy_render/src/view/visibility/range.rs @@ -13,8 +13,9 @@ use bevy_ecs::{ query::{Changed, With}, reflect::ReflectComponent, removal_detection::RemovedComponents, + resource::Resource, schedule::IntoSystemConfigs as _, - system::{Query, Res, ResMut, Resource}, + system::{Query, Res, ResMut}, }; use bevy_math::{vec4, FloatOrd, Vec4}; use bevy_reflect::Reflect; diff --git a/crates/bevy_scene/src/dynamic_scene.rs b/crates/bevy_scene/src/dynamic_scene.rs index 51521995c8ea4..88d0105035deb 100644 --- a/crates/bevy_scene/src/dynamic_scene.rs +++ b/crates/bevy_scene/src/dynamic_scene.rs @@ -205,7 +205,7 @@ mod tests { }, hierarchy::ChildOf, reflect::{AppTypeRegistry, ReflectComponent, ReflectMapEntities, ReflectResource}, - system::Resource, + resource::Resource, world::World, }; use bevy_reflect::Reflect; diff --git a/crates/bevy_scene/src/dynamic_scene_builder.rs b/crates/bevy_scene/src/dynamic_scene_builder.rs index 208702dd81b3b..842b985a48954 100644 --- a/crates/bevy_scene/src/dynamic_scene_builder.rs +++ b/crates/bevy_scene/src/dynamic_scene_builder.rs @@ -4,7 +4,7 @@ use bevy_ecs::{ component::{Component, ComponentId}, prelude::Entity, reflect::{AppTypeRegistry, ReflectComponent, ReflectResource}, - system::Resource, + resource::Resource, world::World, }; use bevy_reflect::{PartialReflect, ReflectFromReflect}; diff --git a/crates/bevy_scene/src/scene_spawner.rs b/crates/bevy_scene/src/scene_spawner.rs index 4f66b41ba66a1..eacd6b9c6f536 100644 --- a/crates/bevy_scene/src/scene_spawner.rs +++ b/crates/bevy_scene/src/scene_spawner.rs @@ -5,7 +5,7 @@ use bevy_ecs::{ event::{Event, EventCursor, Events}, hierarchy::ChildOf, reflect::AppTypeRegistry, - system::Resource, + resource::Resource, world::{Mut, World}, }; use bevy_reflect::Reflect; diff --git a/crates/bevy_state/src/state/resources.rs b/crates/bevy_state/src/state/resources.rs index 71c192cb2a3e7..4bbe6d1b1f24e 100644 --- a/crates/bevy_state/src/state/resources.rs +++ b/crates/bevy_state/src/state/resources.rs @@ -2,7 +2,8 @@ use core::ops::Deref; use bevy_ecs::{ change_detection::DetectChangesMut, - system::{ResMut, Resource}, + resource::Resource, + system::ResMut, world::{FromWorld, World}, }; diff --git a/crates/bevy_state/src/state_scoped_events.rs b/crates/bevy_state/src/state_scoped_events.rs index 1906370ad3f60..8ee9fea0c889c 100644 --- a/crates/bevy_state/src/state_scoped_events.rs +++ b/crates/bevy_state/src/state_scoped_events.rs @@ -4,7 +4,8 @@ use core::marker::PhantomData; use bevy_app::{App, SubApp}; use bevy_ecs::{ event::{Event, EventReader, Events}, - system::{Commands, Resource}, + resource::Resource, + system::Commands, world::World, }; use bevy_utils::HashMap; diff --git a/crates/bevy_text/src/font_atlas_set.rs b/crates/bevy_text/src/font_atlas_set.rs index 4028f7eab8754..5172f038bd3df 100644 --- a/crates/bevy_text/src/font_atlas_set.rs +++ b/crates/bevy_text/src/font_atlas_set.rs @@ -1,8 +1,5 @@ use bevy_asset::{Asset, AssetEvent, AssetId, Assets}; -use bevy_ecs::{ - event::EventReader, - system::{ResMut, Resource}, -}; +use bevy_ecs::{event::EventReader, resource::Resource, system::ResMut}; use bevy_image::prelude::*; use bevy_math::{IVec2, UVec2}; use bevy_reflect::TypePath; diff --git a/crates/bevy_text/src/pipeline.rs b/crates/bevy_text/src/pipeline.rs index 6eb9ed44636b6..9ab627b56246f 100644 --- a/crates/bevy_text/src/pipeline.rs +++ b/crates/bevy_text/src/pipeline.rs @@ -4,10 +4,8 @@ use bevy_asset::{AssetId, Assets}; use bevy_color::Color; use bevy_derive::{Deref, DerefMut}; use bevy_ecs::{ - component::Component, - entity::Entity, - reflect::ReflectComponent, - system::{ResMut, Resource}, + component::Component, entity::Entity, reflect::ReflectComponent, resource::Resource, + system::ResMut, }; use bevy_image::prelude::*; use bevy_math::{UVec2, Vec2}; diff --git a/crates/bevy_time/src/lib.rs b/crates/bevy_time/src/lib.rs index dc3883132a0a6..cb85872672678 100644 --- a/crates/bevy_time/src/lib.rs +++ b/crates/bevy_time/src/lib.rs @@ -161,7 +161,8 @@ mod tests { use bevy_app::{App, FixedUpdate, Startup, Update}; use bevy_ecs::{ event::{Event, EventReader, EventRegistry, EventWriter, Events, ShouldUpdateEvents}, - system::{Local, Res, ResMut, Resource}, + resource::Resource, + system::{Local, Res, ResMut}, }; use core::error::Error; use core::time::Duration; diff --git a/crates/bevy_time/src/time.rs b/crates/bevy_time/src/time.rs index fa0bf8a6cb2ac..3b5dbc8e26633 100644 --- a/crates/bevy_time/src/time.rs +++ b/crates/bevy_time/src/time.rs @@ -1,4 +1,4 @@ -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use core::time::Duration; #[cfg(feature = "bevy_reflect")] use { diff --git a/crates/bevy_ui/src/render/debug_overlay.rs b/crates/bevy_ui/src/render/debug_overlay.rs index bc08eaad5d368..52d5f847fbfa1 100644 --- a/crates/bevy_ui/src/render/debug_overlay.rs +++ b/crates/bevy_ui/src/render/debug_overlay.rs @@ -5,11 +5,11 @@ use crate::UiTargetCamera; use bevy_asset::AssetId; use bevy_color::Hsla; use bevy_ecs::entity::Entity; +use bevy_ecs::resource::Resource; use bevy_ecs::system::Commands; use bevy_ecs::system::Query; use bevy_ecs::system::Res; use bevy_ecs::system::ResMut; -use bevy_ecs::system::Resource; use bevy_math::Rect; use bevy_math::Vec2; use bevy_render::sync_world::RenderEntity; diff --git a/crates/bevy_winit/src/winit_config.rs b/crates/bevy_winit/src/winit_config.rs index e8703ff66bcd5..feeeb8d3bb15e 100644 --- a/crates/bevy_winit/src/winit_config.rs +++ b/crates/bevy_winit/src/winit_config.rs @@ -1,4 +1,4 @@ -use bevy_ecs::system::Resource; +use bevy_ecs::resource::Resource; use core::time::Duration; /// Settings for the [`WinitPlugin`](super::WinitPlugin). diff --git a/crates/bevy_winit/src/winit_monitors.rs b/crates/bevy_winit/src/winit_monitors.rs index e0b0f0fd32a1b..46c62038e2cd4 100644 --- a/crates/bevy_winit/src/winit_monitors.rs +++ b/crates/bevy_winit/src/winit_monitors.rs @@ -1,6 +1,6 @@ use winit::monitor::MonitorHandle; -use bevy_ecs::{entity::Entity, system::Resource}; +use bevy_ecs::{entity::Entity, resource::Resource}; /// Stores [`winit`] monitors and their corresponding entities ///