Avoid using SystemTypeSet for transform systems ambiguity (#7808)

Alternative to #7804

Allows other instances of the `sync_simple_transforms` and `propagate_transforms` systems to be added.

Co-authored-by: devil-ira <justthecooldude@gmail.com>
This commit is contained in:
ira 2023-02-24 16:59:19 +00:00
parent d1a1f90902
commit 40e90b51b5

View File

@ -90,6 +90,11 @@ pub struct TransformPlugin;
impl Plugin for TransformPlugin { impl Plugin for TransformPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
// A set for `propagate_transforms` to mark it as ambiguous with `sync_simple_transforms`.
// Used instead of the `SystemTypeSet` as that would not allow multiple instances of the system.
#[derive(Debug, Hash, PartialEq, Eq, Clone, SystemSet)]
struct PropagateTransformsSet;
app.register_type::<Transform>() app.register_type::<Transform>()
.register_type::<GlobalTransform>() .register_type::<GlobalTransform>()
.add_plugin(ValidParentCheckPlugin::<GlobalTransform>::default()) .add_plugin(ValidParentCheckPlugin::<GlobalTransform>::default())
@ -106,14 +111,22 @@ impl Plugin for TransformPlugin {
.add_startup_system( .add_startup_system(
sync_simple_transforms sync_simple_transforms
.in_set(TransformSystem::TransformPropagate) .in_set(TransformSystem::TransformPropagate)
.ambiguous_with(propagate_transforms), .ambiguous_with(PropagateTransformsSet),
)
.add_startup_system(
propagate_transforms
.in_set(TransformSystem::TransformPropagate)
.in_set(PropagateTransformsSet),
) )
.add_startup_system(propagate_transforms.in_set(TransformSystem::TransformPropagate))
.add_system( .add_system(
sync_simple_transforms sync_simple_transforms
.in_set(TransformSystem::TransformPropagate) .in_set(TransformSystem::TransformPropagate)
.ambiguous_with(propagate_transforms), .ambiguous_with(PropagateTransformsSet),
) )
.add_system(propagate_transforms.in_set(TransformSystem::TransformPropagate)); .add_system(
propagate_transforms
.in_set(TransformSystem::TransformPropagate)
.in_set(PropagateTransformsSet),
);
} }
} }