From b2661ea73d294f886e9c23fd5f5ff0287ba8510b Mon Sep 17 00:00:00 2001 From: Tygyh <32486062+tygyh@users.noreply.github.com> Date: Wed, 13 Dec 2023 22:19:49 +0100 Subject: [PATCH] Reorder impl to be the same as the trait (#10964) # Objective - Make the implementation order consistent between all sources to fit the order in the trait. ## Solution - Change the implementation order. --- crates/bevy_ecs/src/event.rs | 50 +++++----- crates/bevy_ecs/src/query/fetch.rs | 94 +++++++++---------- crates/bevy_ecs/src/query/filter.rs | 68 +++++++------- crates/bevy_ecs/src/schedule/config.rs | 10 +- .../src/schedule/executor/multi_threaded.rs | 8 +- .../bevy_ecs/src/schedule/executor/simple.rs | 8 +- .../src/schedule/executor/single_threaded.rs | 8 +- crates/bevy_ecs/src/schedule/set.rs | 8 +- crates/bevy_ecs/src/system/adapter_system.rs | 8 +- crates/bevy_ecs/src/system/combinator.rs | 12 +-- .../src/system/exclusive_function_system.rs | 26 ++--- crates/bevy_ecs/src/system/function_system.rs | 16 ++-- 12 files changed, 158 insertions(+), 158 deletions(-) diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index 11a53facb1..9c73cfeeb3 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -616,8 +616,12 @@ impl<'a, E: Event> Iterator for EventIterator<'a, E> { self.iter.next().map(|(event, _)| event) } - fn nth(&mut self, n: usize) -> Option { - self.iter.nth(n).map(|(event, _)| event) + fn size_hint(&self) -> (usize, Option) { + self.iter.size_hint() + } + + fn count(self) -> usize { + self.iter.count() } fn last(self) -> Option @@ -627,12 +631,8 @@ impl<'a, E: Event> Iterator for EventIterator<'a, E> { self.iter.last().map(|(event, _)| event) } - fn count(self) -> usize { - self.iter.count() - } - - fn size_hint(&self) -> (usize, Option) { - self.iter.size_hint() + fn nth(&mut self, n: usize) -> Option { + self.iter.nth(n).map(|(event, _)| event) } } @@ -696,16 +696,13 @@ impl<'a, E: Event> Iterator for EventIteratorWithId<'a, E> { } } - fn nth(&mut self, n: usize) -> Option { - if let Some(EventInstance { event_id, event }) = self.chain.nth(n) { - self.reader.last_event_count += n + 1; - self.unread -= n + 1; - Some((event, *event_id)) - } else { - self.reader.last_event_count += self.unread; - self.unread = 0; - None - } + fn size_hint(&self) -> (usize, Option) { + self.chain.size_hint() + } + + fn count(self) -> usize { + self.reader.last_event_count += self.unread; + self.unread } fn last(self) -> Option @@ -717,13 +714,16 @@ impl<'a, E: Event> Iterator for EventIteratorWithId<'a, E> { Some((event, *event_id)) } - fn count(self) -> usize { - self.reader.last_event_count += self.unread; - self.unread - } - - fn size_hint(&self) -> (usize, Option) { - self.chain.size_hint() + fn nth(&mut self, n: usize) -> Option { + if let Some(EventInstance { event_id, event }) = self.chain.nth(n) { + self.reader.last_event_count += n + 1; + self.unread -= n + 1; + Some((event, *event_id)) + } else { + self.reader.last_event_count += self.unread; + self.unread = 0; + None + } } } diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 3db9c59240..b384b18e27 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -278,16 +278,14 @@ pub type ROQueryItem<'w, D> = QueryItem<'w, ::ReadOnly>; /// `update_component_access` and `update_archetype_component_access` do nothing. /// This is sound because `fetch` does not access components. unsafe impl WorldQuery for Entity { - type Fetch<'w> = (); type Item<'w> = Entity; + type Fetch<'w> = (); type State = (); fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { item } - const IS_DENSE: bool = true; - unsafe fn init_fetch<'w>( _world: UnsafeWorldCell<'w>, _state: &Self::State, @@ -296,6 +294,8 @@ unsafe impl WorldQuery for Entity { ) -> Self::Fetch<'w> { } + const IS_DENSE: bool = true; + #[inline] unsafe fn set_archetype<'w>( _fetch: &mut Self::Fetch<'w>, @@ -350,16 +350,14 @@ unsafe impl ReadOnlyQueryData for Entity {} /// This is sound because `update_component_access` and `update_archetype_component_access` set read access for all components and panic when appropriate. /// Filters are unchanged. unsafe impl<'a> WorldQuery for EntityRef<'a> { - type Fetch<'w> = UnsafeWorldCell<'w>; type Item<'w> = EntityRef<'w>; + type Fetch<'w> = UnsafeWorldCell<'w>; type State = (); fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { item } - const IS_DENSE: bool = true; - unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, _state: &Self::State, @@ -369,6 +367,8 @@ unsafe impl<'a> WorldQuery for EntityRef<'a> { world } + const IS_DENSE: bool = true; + #[inline] unsafe fn set_archetype<'w>( _fetch: &mut Self::Fetch<'w>, @@ -432,16 +432,14 @@ unsafe impl ReadOnlyQueryData for EntityRef<'_> {} /// SAFETY: The accesses of `Self::ReadOnly` are a subset of the accesses of `Self` unsafe impl<'a> WorldQuery for EntityMut<'a> { - type Fetch<'w> = UnsafeWorldCell<'w>; type Item<'w> = EntityMut<'w>; + type Fetch<'w> = UnsafeWorldCell<'w>; type State = (); fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { item } - const IS_DENSE: bool = true; - unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, _state: &Self::State, @@ -451,6 +449,8 @@ unsafe impl<'a> WorldQuery for EntityMut<'a> { world } + const IS_DENSE: bool = true; + #[inline] unsafe fn set_archetype<'w>( _fetch: &mut Self::Fetch<'w>, @@ -530,21 +530,14 @@ impl Copy for ReadFetch<'_, T> {} /// `update_component_access` adds a `With` filter for a component. /// This is sound because `matches_component_set` returns whether the set contains that component. unsafe impl WorldQuery for &T { - type Fetch<'w> = ReadFetch<'w, T>; type Item<'w> = &'w T; + type Fetch<'w> = ReadFetch<'w, T>; type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(item: &'wlong T) -> &'wshort T { item } - const IS_DENSE: bool = { - match T::Storage::STORAGE_TYPE { - StorageType::Table => true, - StorageType::SparseSet => false, - } - }; - #[inline] unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, @@ -568,6 +561,13 @@ unsafe impl WorldQuery for &T { } } + const IS_DENSE: bool = { + match T::Storage::STORAGE_TYPE { + StorageType::Table => true, + StorageType::SparseSet => false, + } + }; + #[inline] unsafe fn set_archetype<'w>( fetch: &mut ReadFetch<'w, T>, @@ -686,21 +686,14 @@ impl Copy for RefFetch<'_, T> {} /// `update_component_access` adds a `With` filter for a component. /// This is sound because `matches_component_set` returns whether the set contains that component. unsafe impl<'__w, T: Component> WorldQuery for Ref<'__w, T> { - type Fetch<'w> = RefFetch<'w, T>; type Item<'w> = Ref<'w, T>; + type Fetch<'w> = RefFetch<'w, T>; type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(item: Ref<'wlong, T>) -> Ref<'wshort, T> { item } - const IS_DENSE: bool = { - match T::Storage::STORAGE_TYPE { - StorageType::Table => true, - StorageType::SparseSet => false, - } - }; - #[inline] unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, @@ -723,6 +716,13 @@ unsafe impl<'__w, T: Component> WorldQuery for Ref<'__w, T> { } } + const IS_DENSE: bool = { + match T::Storage::STORAGE_TYPE { + StorageType::Table => true, + StorageType::SparseSet => false, + } + }; + #[inline] unsafe fn set_archetype<'w>( fetch: &mut RefFetch<'w, T>, @@ -853,21 +853,14 @@ impl Copy for WriteFetch<'_, T> {} /// `update_component_access` adds a `With` filter for a component. /// This is sound because `matches_component_set` returns whether the set contains that component. unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T { - type Fetch<'w> = WriteFetch<'w, T>; type Item<'w> = Mut<'w, T>; + type Fetch<'w> = WriteFetch<'w, T>; type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(item: Mut<'wlong, T>) -> Mut<'wshort, T> { item } - const IS_DENSE: bool = { - match T::Storage::STORAGE_TYPE { - StorageType::Table => true, - StorageType::SparseSet => false, - } - }; - #[inline] unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, @@ -890,6 +883,13 @@ unsafe impl<'__w, T: Component> WorldQuery for &'__w mut T { } } + const IS_DENSE: bool = { + match T::Storage::STORAGE_TYPE { + StorageType::Table => true, + StorageType::SparseSet => false, + } + }; + #[inline] unsafe fn set_archetype<'w>( fetch: &mut WriteFetch<'w, T>, @@ -1009,16 +1009,14 @@ impl Clone for OptionFetch<'_, T> { /// This is sound because `update_component_access` and `update_archetype_component_access` add the same accesses as `T`. /// Filters are unchanged. unsafe impl WorldQuery for Option { - type Fetch<'w> = OptionFetch<'w, T>; type Item<'w> = Option>; + type Fetch<'w> = OptionFetch<'w, T>; type State = T::State; fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { item.map(T::shrink) } - const IS_DENSE: bool = T::IS_DENSE; - #[inline] unsafe fn init_fetch<'w>( world: UnsafeWorldCell<'w>, @@ -1032,6 +1030,8 @@ unsafe impl WorldQuery for Option { } } + const IS_DENSE: bool = T::IS_DENSE; + #[inline] unsafe fn set_archetype<'w>( fetch: &mut OptionFetch<'w, T>, @@ -1168,21 +1168,14 @@ pub struct Has(PhantomData); /// `update_component_access` and `update_archetype_component_access` do nothing. /// This is sound because `fetch` does not access components. unsafe impl WorldQuery for Has { - type Fetch<'w> = bool; type Item<'w> = bool; + type Fetch<'w> = bool; type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { item } - const IS_DENSE: bool = { - match T::Storage::STORAGE_TYPE { - StorageType::Table => true, - StorageType::SparseSet => false, - } - }; - #[inline] unsafe fn init_fetch<'w>( _world: UnsafeWorldCell<'w>, @@ -1193,6 +1186,13 @@ unsafe impl WorldQuery for Has { false } + const IS_DENSE: bool = { + match T::Storage::STORAGE_TYPE { + StorageType::Table => true, + StorageType::SparseSet => false, + } + }; + #[inline] unsafe fn set_archetype<'w>( fetch: &mut Self::Fetch<'w>, @@ -1408,14 +1408,12 @@ pub struct NopWorldQuery(PhantomData); /// `update_component_access` and `update_archetype_component_access` do nothing. /// This is sound because `fetch` does not access components. unsafe impl WorldQuery for NopWorldQuery { - type Fetch<'w> = (); type Item<'w> = (); + type Fetch<'w> = (); type State = D::State; fn shrink<'wlong: 'wshort, 'wshort>(_: ()) {} - const IS_DENSE: bool = D::IS_DENSE; - #[inline(always)] unsafe fn init_fetch( _world: UnsafeWorldCell, @@ -1425,6 +1423,8 @@ unsafe impl WorldQuery for NopWorldQuery { ) { } + const IS_DENSE: bool = D::IS_DENSE; + #[inline(always)] unsafe fn set_archetype( _fetch: &mut (), diff --git a/crates/bevy_ecs/src/query/filter.rs b/crates/bevy_ecs/src/query/filter.rs index bac5e70a31..301ddfbd6a 100644 --- a/crates/bevy_ecs/src/query/filter.rs +++ b/crates/bevy_ecs/src/query/filter.rs @@ -128,8 +128,8 @@ pub struct With(PhantomData); /// `update_component_access` adds a `With` filter for `T`. /// This is sound because `matches_component_set` returns whether the set contains the component. unsafe impl WorldQuery for With { - type Fetch<'w> = (); type Item<'w> = (); + type Fetch<'w> = (); type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(_: Self::Item<'wlong>) -> Self::Item<'wshort> {} @@ -150,9 +150,6 @@ unsafe impl WorldQuery for With { } }; - #[inline] - unsafe fn set_table(_fetch: &mut (), _state: &ComponentId, _table: &Table) {} - #[inline] unsafe fn set_archetype( _fetch: &mut (), @@ -162,6 +159,9 @@ unsafe impl WorldQuery for With { ) { } + #[inline] + unsafe fn set_table(_fetch: &mut (), _state: &ComponentId, _table: &Table) {} + #[inline(always)] unsafe fn fetch<'w>( _fetch: &mut Self::Fetch<'w>, @@ -240,8 +240,8 @@ pub struct Without(PhantomData); /// `update_component_access` adds a `Without` filter for `T`. /// This is sound because `matches_component_set` returns whether the set does not contain the component. unsafe impl WorldQuery for Without { - type Fetch<'w> = (); type Item<'w> = (); + type Fetch<'w> = (); type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(_: Self::Item<'wlong>) -> Self::Item<'wshort> {} @@ -262,9 +262,6 @@ unsafe impl WorldQuery for Without { } }; - #[inline] - unsafe fn set_table(_fetch: &mut (), _state: &Self::State, _table: &Table) {} - #[inline] unsafe fn set_archetype( _fetch: &mut (), @@ -274,6 +271,9 @@ unsafe impl WorldQuery for Without { ) { } + #[inline] + unsafe fn set_table(_fetch: &mut (), _state: &Self::State, _table: &Table) {} + #[inline(always)] unsafe fn fetch<'w>( _fetch: &mut Self::Fetch<'w>, @@ -561,8 +561,8 @@ pub struct AddedFetch<'w> { /// `update_component_access` adds a `With` filter for a component. /// This is sound because `matches_component_set` returns whether the set contains that component. unsafe impl WorldQuery for Added { - type Fetch<'w> = AddedFetch<'w>; type Item<'w> = bool; + type Fetch<'w> = AddedFetch<'w>; type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { @@ -592,18 +592,6 @@ unsafe impl WorldQuery for Added { } }; - #[inline] - unsafe fn set_table<'w>( - fetch: &mut Self::Fetch<'w>, - &component_id: &ComponentId, - table: &'w Table, - ) { - fetch.table_ticks = Some( - Column::get_added_ticks_slice(table.get_column(component_id).debug_checked_unwrap()) - .into(), - ); - } - #[inline] unsafe fn set_archetype<'w>( fetch: &mut Self::Fetch<'w>, @@ -616,6 +604,18 @@ unsafe impl WorldQuery for Added { } } + #[inline] + unsafe fn set_table<'w>( + fetch: &mut Self::Fetch<'w>, + &component_id: &ComponentId, + table: &'w Table, + ) { + fetch.table_ticks = Some( + Column::get_added_ticks_slice(table.get_column(component_id).debug_checked_unwrap()) + .into(), + ); + } + #[inline(always)] unsafe fn fetch<'w>( fetch: &mut Self::Fetch<'w>, @@ -737,8 +737,8 @@ pub struct ChangedFetch<'w> { /// `update_component_access` adds a `With` filter for a component. /// This is sound because `matches_component_set` returns whether the set contains that component. unsafe impl WorldQuery for Changed { - type Fetch<'w> = ChangedFetch<'w>; type Item<'w> = bool; + type Fetch<'w> = ChangedFetch<'w>; type State = ComponentId; fn shrink<'wlong: 'wshort, 'wshort>(item: Self::Item<'wlong>) -> Self::Item<'wshort> { @@ -768,18 +768,6 @@ unsafe impl WorldQuery for Changed { } }; - #[inline] - unsafe fn set_table<'w>( - fetch: &mut Self::Fetch<'w>, - &component_id: &ComponentId, - table: &'w Table, - ) { - fetch.table_ticks = Some( - Column::get_changed_ticks_slice(table.get_column(component_id).debug_checked_unwrap()) - .into(), - ); - } - #[inline] unsafe fn set_archetype<'w>( fetch: &mut Self::Fetch<'w>, @@ -792,6 +780,18 @@ unsafe impl WorldQuery for Changed { } } + #[inline] + unsafe fn set_table<'w>( + fetch: &mut Self::Fetch<'w>, + &component_id: &ComponentId, + table: &'w Table, + ) { + fetch.table_ticks = Some( + Column::get_changed_ticks_slice(table.get_column(component_id).debug_checked_unwrap()) + .into(), + ); + } + #[inline(always)] unsafe fn fetch<'w>( fetch: &mut Self::Fetch<'w>, diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index 80c175c880..3b16ca0326 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -390,6 +390,11 @@ impl IntoSystemConfigs<()> for SystemConfigs { self } + fn run_if(mut self, condition: impl Condition) -> SystemConfigs { + self.run_if_dyn(new_condition(condition)); + self + } + fn ambiguous_with(mut self, set: impl IntoSystemSet) -> Self { let set = set.into_system_set(); self.ambiguous_with_inner(set.intern()); @@ -401,11 +406,6 @@ impl IntoSystemConfigs<()> for SystemConfigs { self } - fn run_if(mut self, condition: impl Condition) -> SystemConfigs { - self.run_if_dyn(new_condition(condition)); - self - } - fn chain(self) -> Self { self.chain_inner() } diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 9e0fa0cd23..ef52430c86 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -128,10 +128,6 @@ impl SystemExecutor for MultiThreadedExecutor { ExecutorKind::MultiThreaded } - fn set_apply_final_deferred(&mut self, value: bool) { - self.apply_final_deferred = value; - } - fn init(&mut self, schedule: &SystemSchedule) { // pre-allocate space let sys_count = schedule.system_ids.len(); @@ -261,6 +257,10 @@ impl SystemExecutor for MultiThreadedExecutor { self.skipped_systems.clear(); self.completed_systems.clear(); } + + fn set_apply_final_deferred(&mut self, value: bool) { + self.apply_final_deferred = value; + } } impl MultiThreadedExecutor { diff --git a/crates/bevy_ecs/src/schedule/executor/simple.rs b/crates/bevy_ecs/src/schedule/executor/simple.rs index c34a88c57a..e31134506f 100644 --- a/crates/bevy_ecs/src/schedule/executor/simple.rs +++ b/crates/bevy_ecs/src/schedule/executor/simple.rs @@ -23,10 +23,6 @@ impl SystemExecutor for SimpleExecutor { ExecutorKind::Simple } - fn set_apply_final_deferred(&mut self, _: bool) { - // do nothing. simple executor does not do a final sync - } - fn init(&mut self, schedule: &SystemSchedule) { let sys_count = schedule.system_ids.len(); let set_count = schedule.set_ids.len(); @@ -91,6 +87,10 @@ impl SystemExecutor for SimpleExecutor { self.evaluated_sets.clear(); self.completed_systems.clear(); } + + fn set_apply_final_deferred(&mut self, _: bool) { + // do nothing. simple executor does not do a final sync + } } impl SimpleExecutor { diff --git a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs index dd6c4e6a41..90eb1d1c30 100644 --- a/crates/bevy_ecs/src/schedule/executor/single_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/single_threaded.rs @@ -29,10 +29,6 @@ impl SystemExecutor for SingleThreadedExecutor { ExecutorKind::SingleThreaded } - fn set_apply_final_deferred(&mut self, apply_final_deferred: bool) { - self.apply_final_deferred = apply_final_deferred; - } - fn init(&mut self, schedule: &SystemSchedule) { // pre-allocate space let sys_count = schedule.system_ids.len(); @@ -105,6 +101,10 @@ impl SystemExecutor for SingleThreadedExecutor { self.evaluated_sets.clear(); self.completed_systems.clear(); } + + fn set_apply_final_deferred(&mut self, apply_final_deferred: bool) { + self.apply_final_deferred = apply_final_deferred; + } } impl SingleThreadedExecutor { diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index e17561e737..37e36ac11c 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -131,6 +131,10 @@ impl SystemSet for AnonymousSet { true } + fn dyn_clone(&self) -> Box { + Box::new(*self) + } + fn as_dyn_eq(&self) -> &dyn DynEq { self } @@ -139,10 +143,6 @@ impl SystemSet for AnonymousSet { TypeId::of::().hash(&mut state); self.hash(&mut state); } - - fn dyn_clone(&self) -> Box { - Box::new(*self) - } } /// Types that can be converted into a [`SystemSet`]. diff --git a/crates/bevy_ecs/src/system/adapter_system.rs b/crates/bevy_ecs/src/system/adapter_system.rs index 228b5ddca2..8e087e15bf 100644 --- a/crates/bevy_ecs/src/system/adapter_system.rs +++ b/crates/bevy_ecs/src/system/adapter_system.rs @@ -135,6 +135,10 @@ where self.system.check_change_tick(change_tick); } + fn default_system_sets(&self) -> Vec { + self.system.default_system_sets() + } + fn get_last_run(&self) -> crate::component::Tick { self.system.get_last_run() } @@ -142,10 +146,6 @@ where fn set_last_run(&mut self, last_run: crate::component::Tick) { self.system.set_last_run(last_run); } - - fn default_system_sets(&self) -> Vec { - self.system.default_system_sets() - } } // SAFETY: The inner system is read-only. diff --git a/crates/bevy_ecs/src/system/combinator.rs b/crates/bevy_ecs/src/system/combinator.rs index f70712711c..5461e503a4 100644 --- a/crates/bevy_ecs/src/system/combinator.rs +++ b/crates/bevy_ecs/src/system/combinator.rs @@ -218,6 +218,12 @@ where self.b.check_change_tick(change_tick); } + fn default_system_sets(&self) -> Vec { + let mut default_sets = self.a.default_system_sets(); + default_sets.append(&mut self.b.default_system_sets()); + default_sets + } + fn get_last_run(&self) -> Tick { self.a.get_last_run() } @@ -226,12 +232,6 @@ where self.a.set_last_run(last_run); self.b.set_last_run(last_run); } - - fn default_system_sets(&self) -> Vec { - let mut default_sets = self.a.default_system_sets(); - default_sets.append(&mut self.b.default_system_sets()); - default_sets - } } /// SAFETY: Both systems are read-only, so any system created by combining them will only read from the world. diff --git a/crates/bevy_ecs/src/system/exclusive_function_system.rs b/crates/bevy_ecs/src/system/exclusive_function_system.rs index 1a06f1eb03..e9090b6f30 100644 --- a/crates/bevy_ecs/src/system/exclusive_function_system.rs +++ b/crates/bevy_ecs/src/system/exclusive_function_system.rs @@ -88,6 +88,11 @@ where false } + #[inline] + fn is_exclusive(&self) -> bool { + true + } + #[inline] unsafe fn run_unsafe(&mut self, _input: Self::In, _world: UnsafeWorldCell) -> Self::Out { panic!("Cannot run exclusive systems with a shared World reference"); @@ -114,19 +119,6 @@ where out } - #[inline] - fn is_exclusive(&self) -> bool { - true - } - - fn get_last_run(&self) -> Tick { - self.system_meta.last_run - } - - fn set_last_run(&mut self, last_run: Tick) { - self.system_meta.last_run = last_run; - } - #[inline] fn apply_deferred(&mut self, _world: &mut World) { // "pure" exclusive systems do not have any buffers to apply. @@ -155,6 +147,14 @@ where let set = crate::schedule::SystemTypeSet::::new(); vec![set.intern()] } + + fn get_last_run(&self) -> Tick { + self.system_meta.last_run + } + + fn set_last_run(&mut self, last_run: Tick) { + self.system_meta.last_run = last_run; + } } /// A trait implemented for all exclusive system functions that can be used as [`System`]s. diff --git a/crates/bevy_ecs/src/system/function_system.rs b/crates/bevy_ecs/src/system/function_system.rs index 6bd67fb89d..e327288685 100644 --- a/crates/bevy_ecs/src/system/function_system.rs +++ b/crates/bevy_ecs/src/system/function_system.rs @@ -487,14 +487,6 @@ where out } - fn get_last_run(&self) -> Tick { - self.system_meta.last_run - } - - fn set_last_run(&mut self, last_run: Tick) { - self.system_meta.last_run = last_run; - } - #[inline] fn apply_deferred(&mut self, world: &mut World) { let param_state = self.param_state.as_mut().expect(Self::PARAM_MESSAGE); @@ -533,6 +525,14 @@ where let set = crate::schedule::SystemTypeSet::::new(); vec![set.intern()] } + + fn get_last_run(&self) -> Tick { + self.system_meta.last_run + } + + fn set_last_run(&mut self, last_run: Tick) { + self.system_meta.last_run = last_run; + } } /// SAFETY: `F`'s param is [`ReadOnlySystemParam`], so this system will only read from the world.