Skip to content
Merged
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
3 changes: 2 additions & 1 deletion crates/bevy_asset/src/asset_changed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use crate::{AsAssetId, Asset, AssetId};
use bevy_ecs::component::Components;
use bevy_ecs::{
archetype::Archetype,
component::{ComponentId, Tick},
change_detection::Tick,
component::ComponentId,
prelude::{Entity, Resource, World},
query::{FilteredAccess, QueryData, QueryFilter, ReadFetch, WorldQuery},
storage::{Table, TableRow},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ pub fn derive_system_param(input: TokenStream) -> TokenStream {
state: &'s mut Self::State,
system_meta: &#path::system::SystemMeta,
world: #path::world::unsafe_world_cell::UnsafeWorldCell<'w>,
change_tick: #path::component::Tick,
change_tick: #path::change_detection::Tick,
) -> Self::Item<'w, 's> {
let (#(#tuple_patterns,)*) = <
(#(#tuple_types,)*) as #path::system::SystemParam
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/macros/src/world_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ pub(crate) fn world_query_impl(
unsafe fn init_fetch<'__w, '__s>(
_world: #path::world::unsafe_world_cell::UnsafeWorldCell<'__w>,
state: &'__s Self::State,
_last_run: #path::component::Tick,
_this_run: #path::component::Tick,
_last_run: #path::change_detection::Tick,
_this_run: #path::change_detection::Tick,
) -> <Self as #path::query::WorldQuery>::Fetch<'__w> {
#fetch_struct_name {
#(#named_field_idents:
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ecs/src/bundle/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ use indexmap::{IndexMap, IndexSet};
use crate::{
archetype::{Archetype, BundleComponentStatus, ComponentStatus},
bundle::{Bundle, DynamicBundle},
change_detection::MaybeLocation,
change_detection::{MaybeLocation, Tick},
component::{
ComponentId, Components, ComponentsRegistrator, RequiredComponentConstructor, StorageType,
Tick,
},
entity::Entity,
query::DebugCheckedUnwrap as _,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/bundle/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::{
ComponentStatus,
},
bundle::{ArchetypeMoveType, Bundle, BundleId, BundleInfo, DynamicBundle, InsertMode},
change_detection::MaybeLocation,
component::{Components, StorageType, Tick},
change_detection::{MaybeLocation, Tick},
component::{Components, StorageType},
entity::{Entities, Entity, EntityLocation},
event::EntityComponentsTrigger,
lifecycle::{Add, Insert, Replace, ADD, INSERT, REPLACE},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/bundle/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
archetype::{Archetype, ArchetypeCreated, ArchetypeId, SpawnBundleStatus},
bundle::{Bundle, BundleId, BundleInfo, DynamicBundle, InsertMode},
change_detection::MaybeLocation,
component::Tick,
change_detection::Tick,
entity::{Entities, Entity, EntityLocation},
event::EntityComponentsTrigger,
lifecycle::{Add, Insert, ADD, INSERT},
Expand Down
8 changes: 5 additions & 3 deletions crates/bevy_ecs/src/change_detection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

mod maybe_location;
mod params;
mod tick;
mod traits;

pub use maybe_location::MaybeLocation;
pub use params::*;
pub use tick::*;
pub use traits::{DetectChanges, DetectChangesMut};

/// The (arbitrarily chosen) minimum number of world tick increments between `check_tick` scans.
Expand All @@ -32,10 +34,10 @@ mod tests {

use crate::{
change_detection::{
ComponentTicksMut, MaybeLocation, Mut, NonSendMut, Ref, ResMut, CHECK_TICK_THRESHOLD,
MAX_CHANGE_AGE,
ComponentTicks, ComponentTicksMut, MaybeLocation, Mut, NonSendMut, Ref, ResMut, Tick,
CHECK_TICK_THRESHOLD, MAX_CHANGE_AGE,
},
component::{Component, ComponentTicks, Tick},
component::Component,
system::{IntoSystem, Single, System},
world::World,
};
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ecs/src/change_detection/params.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{
change_detection::{traits::*, MaybeLocation},
component::{ComponentTickCells, Tick},
change_detection::{traits::*, ComponentTickCells, MaybeLocation, Tick},
ptr::PtrMut,
resource::Resource,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Tick {
///
/// ```
/// use bevy_ecs::prelude::*;
/// use bevy_ecs::component::CheckChangeTicks;
/// use bevy_ecs::change_detection::CheckChangeTicks;
///
/// #[derive(Resource)]
/// struct CustomSchedule(Schedule);
Expand Down Expand Up @@ -173,7 +173,7 @@ impl ComponentTicks {
///
/// # Example
/// ```no_run
/// # use bevy_ecs::{world::World, component::ComponentTicks};
/// # use bevy_ecs::{world::World, change_detection::ComponentTicks};
/// let world: World = unimplemented!();
/// let component_ticks: ComponentTicks = unimplemented!();
///
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/change_detection/traits.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{change_detection::MaybeLocation, component::Tick};
use crate::{change_detection::MaybeLocation, change_detection::Tick};
use alloc::borrow::ToOwned;
use core::mem;

Expand Down
2 changes: 0 additions & 2 deletions crates/bevy_ecs/src/component/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ mod clone;
mod info;
mod register;
mod required;
mod tick;

pub use clone::*;
pub use info::*;
pub use register::*;
pub use required::*;
pub use tick::*;

use crate::{
entity::EntityMapper,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/component/required.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use thiserror::Error;

use crate::{
bundle::BundleInfo,
change_detection::MaybeLocation,
component::{Component, ComponentId, Components, ComponentsRegistrator, Tick},
change_detection::{MaybeLocation, Tick},
component::{Component, ComponentId, Components, ComponentsRegistrator},
entity::Entity,
query::DebugCheckedUnwrap as _,
storage::{SparseSets, Table, TableRow},
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ pub use unique_vec::{UniqueEntityEquivalentVec, UniqueEntityVec};

use crate::{
archetype::{ArchetypeId, ArchetypeRow},
change_detection::MaybeLocation,
component::{CheckChangeTicks, Tick},
change_detection::{CheckChangeTicks, MaybeLocation, Tick},
storage::{SparseSetIndex, TableId, TableRow},
};
use alloc::vec::Vec;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/error/handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::fmt::Display;

use crate::{component::Tick, error::BevyError, prelude::Resource};
use crate::{change_detection::Tick, error::BevyError, prelude::Resource};
use bevy_utils::prelude::DebugName;
use derive_more::derive::{Deref, DerefMut};

Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/lifecycle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
//! For example, [`Add`] corresponds to [`ADD`].
//! This is used to skip [`TypeId`](core::any::TypeId) lookups in hot paths.
use crate::{
change_detection::MaybeLocation,
component::{Component, ComponentId, ComponentIdFor, Tick},
change_detection::{MaybeLocation, Tick},
component::{Component, ComponentId, ComponentIdFor},
entity::Entity,
event::{EntityComponentsTrigger, EntityEvent, EventKey},
message::{
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/message/message_registry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
change_detection::{DetectChangesMut, MutUntyped},
component::{ComponentId, Tick},
change_detection::{DetectChangesMut, MutUntyped, Tick},
component::ComponentId,
message::{Message, Messages},
resource::Resource,
world::World,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/message/update.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
change_detection::Mut,
component::Tick,
change_detection::Tick,
message::{MessageRegistry, ShouldUpdateMessages},
system::{Local, Res, ResMut},
world::World,
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
archetype::{Archetype, Archetypes},
bundle::Bundle,
change_detection::{ComponentTicksMut, ComponentTicksRef, MaybeLocation},
component::{Component, ComponentId, Components, Mutable, StorageType, Tick},
change_detection::{ComponentTicksMut, ComponentTicksRef, MaybeLocation, Tick},
component::{Component, ComponentId, Components, Mutable, StorageType},
entity::{Entities, Entity, EntityLocation},
query::{Access, DebugCheckedUnwrap, FilteredAccess, WorldQuery},
storage::{ComponentSparseSet, Table, TableRow},
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/query/filter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
archetype::Archetype,
component::{Component, ComponentId, Components, StorageType, Tick},
change_detection::Tick,
component::{Component, ComponentId, Components, StorageType},
entity::{Entities, Entity},
query::{DebugCheckedUnwrap, FilteredAccess, StorageSwitch, WorldQuery},
storage::{ComponentSparseSet, Table, TableRow},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::{QueryData, QueryFilter, ReadOnlyQueryData};
use crate::{
archetype::{Archetype, ArchetypeEntity, Archetypes},
bundle::Bundle,
component::Tick,
change_detection::Tick,
entity::{ContainsEntity, Entities, Entity, EntityEquivalent, EntitySet, EntitySetIterator},
query::{ArchetypeFilter, DebugCheckedUnwrap, QueryState, StorageId},
storage::{Table, TableRow, Tables},
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ impl<T> DebugCheckedUnwrap for Option<T> {
mod tests {
use crate::{
archetype::Archetype,
component::{Component, ComponentId, Components, Tick},
change_detection::Tick,
component::{Component, ComponentId, Components},
prelude::{AnyOf, Changed, Entity, Or, QueryState, Resource, With, Without},
query::{
ArchetypeFilter, FilteredAccess, Has, QueryCombinationIter, QueryData,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/query/par_iter.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
batching::BatchingStrategy,
component::Tick,
change_detection::Tick,
entity::{EntityEquivalent, UniqueEntityEquivalentVec},
world::unsafe_world_cell::UnsafeWorldCell,
};
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/query/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
archetype::{Archetype, ArchetypeGeneration, ArchetypeId},
component::{ComponentId, Tick},
change_detection::Tick,
component::ComponentId,
entity::{Entity, EntityEquivalent, EntitySet, UniqueEntityArray},
entity_disabling::DefaultQueryFilters,
prelude::FromWorld,
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/query/world_query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::{
archetype::Archetype,
component::{ComponentId, Components, Tick},
change_detection::Tick,
component::{ComponentId, Components},
query::FilteredAccess,
storage::Table,
world::{unsafe_world_cell::UnsafeWorldCell, World},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/executor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub use self::multi_threaded::{MainThreadExecutor, MultiThreadedExecutor};
use fixedbitset::FixedBitSet;

use crate::{
component::{CheckChangeTicks, Tick},
change_detection::{CheckChangeTicks, Tick},
error::{BevyError, ErrorContext, Result},
prelude::{IntoSystemSet, SystemSet},
query::FilteredAccessSet,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use bevy_platform::collections::HashMap;
use slotmap::{new_key_type, Key, KeyData, SecondaryMap, SlotMap};

use crate::{
component::{CheckChangeTicks, Tick},
change_detection::{CheckChangeTicks, Tick},
prelude::{SystemIn, SystemSet},
query::FilteredAccessSet,
schedule::{
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/schedule/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use thiserror::Error;
#[cfg(feature = "trace")]
use tracing::info_span;

use crate::{component::CheckChangeTicks, system::System};
use crate::{change_detection::CheckChangeTicks, system::System};
use crate::{
component::{ComponentId, Components},
prelude::Component,
Expand Down
7 changes: 4 additions & 3 deletions crates/bevy_ecs/src/storage/resource.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use crate::{
change_detection::{ComponentTicksMut, MaybeLocation, MutUntyped},
component::{
CheckChangeTicks, ComponentId, ComponentTickCells, ComponentTicks, Components, Tick,
change_detection::{
CheckChangeTicks, ComponentTickCells, ComponentTicks, ComponentTicksMut, MaybeLocation,
MutUntyped, Tick,
},
component::{ComponentId, Components},
storage::{blob_array::BlobArray, SparseSet},
};
use bevy_ptr::{OwningPtr, Ptr, UnsafeCellDeref};
Expand Down
6 changes: 2 additions & 4 deletions crates/bevy_ecs/src/storage/sparse_set.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::{
change_detection::MaybeLocation,
component::{
CheckChangeTicks, ComponentId, ComponentInfo, ComponentTickCells, ComponentTicks, Tick,
},
change_detection::{CheckChangeTicks, ComponentTickCells, ComponentTicks, MaybeLocation, Tick},
component::{ComponentId, ComponentInfo},
entity::{Entity, EntityRow},
query::DebugCheckedUnwrap,
storage::{AbortOnPanic, Column, TableRow, VecExtensions},
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_ecs/src/storage/table/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
change_detection::MaybeLocation,
component::{CheckChangeTicks, ComponentId, ComponentInfo, ComponentTicks, Components, Tick},
change_detection::{CheckChangeTicks, ComponentTicks, MaybeLocation, Tick},
component::{ComponentId, ComponentInfo, Components},
entity::Entity,
query::DebugCheckedUnwrap,
storage::{AbortOnPanic, ImmutableSparseSet, SparseSet},
Expand Down Expand Up @@ -869,8 +869,8 @@ impl Drop for Table {
#[cfg(test)]
mod tests {
use crate::{
change_detection::MaybeLocation,
component::{Component, ComponentIds, Components, ComponentsRegistrator, Tick},
change_detection::{MaybeLocation, Tick},
component::{Component, ComponentIds, Components, ComponentsRegistrator},
entity::{Entity, EntityRow},
ptr::OwningPtr,
storage::{TableBuilder, TableId, TableRow, Tables},
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_ecs/src/system/adapter_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,19 @@ where
self.system.initialize(world)
}

fn check_change_tick(&mut self, check: crate::component::CheckChangeTicks) {
fn check_change_tick(&mut self, check: crate::change_detection::CheckChangeTicks) {
self.system.check_change_tick(check);
}

fn default_system_sets(&self) -> Vec<InternedSystemSet> {
self.system.default_system_sets()
}

fn get_last_run(&self) -> crate::component::Tick {
fn get_last_run(&self) -> crate::change_detection::Tick {
self.system.get_last_run()
}

fn set_last_run(&mut self, last_run: crate::component::Tick) {
fn set_last_run(&mut self, last_run: crate::change_detection::Tick) {
self.system.set_last_run(last_run);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/combinator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_utils::prelude::DebugName;
use core::marker::PhantomData;

use crate::{
component::{CheckChangeTicks, Tick},
change_detection::{CheckChangeTicks, Tick},
prelude::World,
query::FilteredAccessSet,
schedule::InternedSystemSet,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const _: () = {
state: &'s mut Self::State,
system_meta: &bevy_ecs::system::SystemMeta,
world: UnsafeWorldCell<'w>,
change_tick: bevy_ecs::component::Tick,
change_tick: bevy_ecs::change_detection::Tick,
) -> Self::Item<'w, 's> {
let(f0, f1) = <(Deferred<'s, CommandQueue>, &'w Entities) as bevy_ecs::system::SystemParam>::get_param(&mut state.state, system_meta, world, change_tick);
Commands {
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/exclusive_function_system.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
component::{CheckChangeTicks, Tick},
change_detection::{CheckChangeTicks, Tick},
error::Result,
query::FilteredAccessSet,
schedule::{InternedSystemSet, SystemSet},
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/function_system.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
component::{CheckChangeTicks, Tick},
change_detection::{CheckChangeTicks, Tick},
error::{BevyError, Result},
never::Never,
prelude::FromWorld,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/src/system/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy_utils::prelude::DebugName;

use crate::{
batching::BatchingStrategy,
component::Tick,
change_detection::Tick,
entity::{Entity, EntityDoesNotExistError, EntityEquivalent, EntitySet, UniqueEntityArray},
query::{
DebugCheckedUnwrap, NopWorldQuery, QueryCombinationIter, QueryData, QueryEntityError,
Expand Down
Loading