mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[commands] Add unless() decorator (#4244)
This commit is contained in:
@@ -302,6 +302,18 @@ public interface Command {
|
||||
return new ProxyScheduleCommand(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decorates this command to only run if this condition is not met. If the command is already
|
||||
* running and the condition changes to true, the command will not stop running. The requirements
|
||||
* of this command will be kept for the new conditonal command.
|
||||
*
|
||||
* @param condition the condition that will prevent the command from running
|
||||
* @return the decorated command
|
||||
*/
|
||||
default ConditionalCommand unless(BooleanSupplier condition) {
|
||||
return new ConditionalCommand(new InstantCommand(), this, condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules this command.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user