Skip to content

Commit

Permalink
add methods for ignoring auto-labels
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJoJet committed Jul 21, 2022
1 parent a91041c commit 217eb5c
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions crates/bevy_ecs/src/schedule/system_descriptor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ pub trait ParallelSystemDescriptorCoercion<Params> {
/// Assigns a label to the system; there can be more than one, and it doesn't have to be unique.
fn label(self, label: impl SystemLabel) -> ParallelSystemDescriptor;

/// Removes the specified label from this system. Does nothing if the label is not present.
fn ignoring(self, label: impl SystemLabel) -> ParallelSystemDescriptor;

/// Specifies that the system should run before systems with the given label.
fn before<Marker>(self, label: impl AsSystemLabel<Marker>) -> ParallelSystemDescriptor;

Expand All @@ -151,6 +154,12 @@ impl ParallelSystemDescriptorCoercion<()> for ParallelSystemDescriptor {
self
}

fn ignoring(mut self, label: impl SystemLabel) -> ParallelSystemDescriptor {
let label = label.as_label();
self.labels.retain(|item| item != &label);
self
}

fn before<Marker>(mut self, label: impl AsSystemLabel<Marker>) -> ParallelSystemDescriptor {
self.before.push(label.as_system_label().as_label());
self
Expand Down Expand Up @@ -183,6 +192,10 @@ where
new_parallel_descriptor(Box::new(IntoSystem::into_system(self))).label(label)
}

fn ignoring(self, label: impl SystemLabel) -> ParallelSystemDescriptor {
new_parallel_descriptor(Box::new(IntoSystem::into_system(self))).ignoring(label)
}

fn before<Marker>(self, label: impl AsSystemLabel<Marker>) -> ParallelSystemDescriptor {
new_parallel_descriptor(Box::new(IntoSystem::into_system(self))).before(label)
}
Expand All @@ -208,6 +221,10 @@ impl ParallelSystemDescriptorCoercion<()> for BoxedSystem<(), ()> {
new_parallel_descriptor(self).label(label)
}

fn ignoring(self, label: impl SystemLabel) -> ParallelSystemDescriptor {
new_parallel_descriptor(self).ignoring(label)
}

fn before<Marker>(self, label: impl AsSystemLabel<Marker>) -> ParallelSystemDescriptor {
new_parallel_descriptor(self).before(label)
}
Expand Down Expand Up @@ -262,6 +279,9 @@ pub trait ExclusiveSystemDescriptorCoercion {
/// Assigns a label to the system; there can be more than one, and it doesn't have to be unique.
fn label(self, label: impl SystemLabel) -> ExclusiveSystemDescriptor;

/// Removes the specified label from this system. Does nothing if the label is not present.
fn ignoring(self, label: impl SystemLabel) -> ExclusiveSystemDescriptor;

/// Specifies that the system should run before systems with the given label.
fn before(self, label: impl SystemLabel) -> ExclusiveSystemDescriptor;

Expand Down Expand Up @@ -297,6 +317,12 @@ impl ExclusiveSystemDescriptorCoercion for ExclusiveSystemDescriptor {
self
}

fn ignoring(mut self, label: impl SystemLabel) -> ExclusiveSystemDescriptor {
let label = label.as_label();
self.labels.retain(|item| item != &label);
self
}

fn before(mut self, label: impl SystemLabel) -> ExclusiveSystemDescriptor {
self.before.push(label.as_label());
self
Expand Down Expand Up @@ -343,6 +369,10 @@ where
new_exclusive_descriptor(Box::new(self)).label(label)
}

fn ignoring(self, label: impl SystemLabel) -> ExclusiveSystemDescriptor {
new_exclusive_descriptor(Box::new(self)).ignoring(label)
}

fn before(self, label: impl SystemLabel) -> ExclusiveSystemDescriptor {
new_exclusive_descriptor(Box::new(self)).before(label)
}
Expand Down

0 comments on commit 217eb5c

Please sign in to comment.