Package com.pocolifo.robobase.control
Class Toggleable
java.lang.Object
com.pocolifo.robobase.control.Toggleable
-
Constructor Summary
ConstructorsConstructorDescriptionToggleable(BoolSupplier currentState) Creates aToggleable.Toggleable(BoolSupplier currentState, boolean initialState) Creates aToggleable. -
Method Summary
Modifier and TypeMethodDescriptionbooleanget()Get the current toggled state.onToggleOff(Runnable runnable) Run code when thisToggleableis toggled OFF.onToggleOn(Runnable runnable) Run code when thisToggleableis toggled ON.Updates this Toggleable.
-
Constructor Details
-
Toggleable
Creates aToggleable.- Parameters:
currentState- A method to get the current state of something (like whether a gamepad button is pressed)
-
Toggleable
Creates aToggleable.- Parameters:
currentState- A method to get the current state of something (like whether a gamepad button is pressed)
-
-
Method Details
-
get
public boolean get()Get the current toggled state.- Returns:
- The toggled state of this
Toggleable
-
processUpdates
Updates this Toggleable. Should be called ONCE as frequent as possible or in the main loop!- Returns:
- This
Toggleableinstance.
-
onToggleOn
Run code when thisToggleableis toggled ON.- Parameters:
runnable- ARunnablethat is executed when this toggleable is toggled ON.- Returns:
- This
Toggleableinstance.
-
onToggleOff
Run code when thisToggleableis toggled OFF.- Parameters:
runnable- ARunnablethat is executed when this toggleable is toggled OFF.- Returns:
- This
Toggleableinstance.
-