mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[commands] Add unless() decorator (#4244)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "frc2/command/Command.h"
|
||||
|
||||
#include "frc2/command/CommandScheduler.h"
|
||||
#include "frc2/command/ConditionalCommand.h"
|
||||
#include "frc2/command/EndlessCommand.h"
|
||||
#include "frc2/command/InstantCommand.h"
|
||||
#include "frc2/command/ParallelCommandGroup.h"
|
||||
@@ -101,6 +102,12 @@ ProxyScheduleCommand Command::AsProxy() {
|
||||
return ProxyScheduleCommand(this);
|
||||
}
|
||||
|
||||
ConditionalCommand Command::Unless(std::function<bool()> condition) && {
|
||||
return ConditionalCommand(std::make_unique<InstantCommand>(),
|
||||
std::move(*this).TransferOwnership(),
|
||||
std::move(condition));
|
||||
}
|
||||
|
||||
void Command::Schedule(bool interruptible) {
|
||||
CommandScheduler::GetInstance().Schedule(interruptible, this);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user