diff --git a/crates/bevy_ecs/macros/src/set.rs b/crates/bevy_ecs/macros/src/set.rs index 785f097913..545de5ef87 100644 --- a/crates/bevy_ecs/macros/src/set.rs +++ b/crates/bevy_ecs/macros/src/set.rs @@ -67,10 +67,6 @@ pub fn derive_set(input: syn::DeriveInput, trait_path: &syn::Path) -> TokenStrea (quote! { impl #impl_generics #trait_path for #ident #ty_generics #where_clause { - fn is_system_type(&self) -> bool { - false - } - fn is_base(&self) -> bool { #is_base } diff --git a/crates/bevy_ecs/src/schedule/config.rs b/crates/bevy_ecs/src/schedule/config.rs index db18ea632e..9566265494 100644 --- a/crates/bevy_ecs/src/schedule/config.rs +++ b/crates/bevy_ecs/src/schedule/config.rs @@ -21,7 +21,7 @@ impl SystemSetConfig { // system type sets are automatically populated // to avoid unintentionally broad changes, they cannot be configured assert!( - !set.is_system_type(), + set.system_type().is_none(), "configuring system type sets is not allowed" ); @@ -200,7 +200,7 @@ impl IntoSystemSetConfig for SystemSetConfig { #[track_caller] fn in_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "adding arbitrary systems to a system type set is not allowed" ); assert!( @@ -218,7 +218,7 @@ impl IntoSystemSetConfig for SystemSetConfig { #[track_caller] fn in_base_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "System type sets cannot be base sets." ); assert!( @@ -394,7 +394,7 @@ impl IntoSystemConfig<()> for SystemConfig { #[track_caller] fn in_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "adding arbitrary systems to a system type set is not allowed" ); assert!( @@ -408,7 +408,7 @@ impl IntoSystemConfig<()> for SystemConfig { #[track_caller] fn in_base_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "System type sets cannot be base sets." ); assert!( @@ -548,7 +548,7 @@ impl IntoSystemConfigs<()> for SystemConfigs { #[track_caller] fn in_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "adding arbitrary systems to a system type set is not allowed" ); assert!( @@ -565,7 +565,7 @@ impl IntoSystemConfigs<()> for SystemConfigs { #[track_caller] fn in_base_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "System type sets cannot be base sets." ); assert!( @@ -692,7 +692,7 @@ impl IntoSystemSetConfigs for SystemSetConfigs { #[track_caller] fn in_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "adding arbitrary systems to a system type set is not allowed" ); assert!( @@ -713,7 +713,7 @@ impl IntoSystemSetConfigs for SystemSetConfigs { #[track_caller] fn in_base_set(mut self, set: impl SystemSet) -> Self { assert!( - !set.is_system_type(), + set.system_type().is_none(), "System type sets cannot be base sets." ); assert!( diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 581f80f008..083f70bd77 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -330,7 +330,7 @@ impl SystemSetNode { } pub fn is_system_type(&self) -> bool { - self.inner.is_system_type() + self.inner.system_type().is_some() } } diff --git a/crates/bevy_ecs/src/schedule/set.rs b/crates/bevy_ecs/src/schedule/set.rs index 086af0817a..06a162c754 100644 --- a/crates/bevy_ecs/src/schedule/set.rs +++ b/crates/bevy_ecs/src/schedule/set.rs @@ -1,3 +1,4 @@ +use std::any::TypeId; use std::fmt::Debug; use std::hash::{Hash, Hasher}; use std::marker::PhantomData; @@ -17,9 +18,9 @@ pub type BoxedScheduleLabel = Box; /// Types that identify logical groups of systems. pub trait SystemSet: DynHash + Debug + Send + Sync + 'static { - /// Returns `true` if this system set is a [`SystemTypeSet`]. - fn is_system_type(&self) -> bool { - false + /// Returns `Some` if this system set is a [`SystemTypeSet`]. + fn system_type(&self) -> Option { + None } /// Returns `true` if this set is a "base system set". Systems @@ -102,8 +103,8 @@ impl PartialEq for SystemTypeSet { impl Eq for SystemTypeSet {} impl SystemSet for SystemTypeSet { - fn is_system_type(&self) -> bool { - true + fn system_type(&self) -> Option { + Some(TypeId::of::()) } fn dyn_clone(&self) -> Box {