Class Toggleable

java.lang.Object
com.pocolifo.robobase.control.Toggleable

public class Toggleable extends Object
  • Constructor Details

    • Toggleable

      public Toggleable(BoolSupplier currentState)
      Creates a Toggleable.
      Parameters:
      currentState - A method to get the current state of something (like whether a gamepad button is pressed)
    • Toggleable

      public Toggleable(BoolSupplier currentState, boolean initialState)
      Creates a Toggleable.
      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

      public Toggleable processUpdates()
      Updates this Toggleable. Should be called ONCE as frequent as possible or in the main loop!
      Returns:
      This Toggleable instance.
    • onToggleOn

      public Toggleable onToggleOn(Runnable runnable)
      Run code when this Toggleable is toggled ON.
      Parameters:
      runnable - A Runnable that is executed when this toggleable is toggled ON.
      Returns:
      This Toggleable instance.
    • onToggleOff

      public Toggleable onToggleOff(Runnable runnable)
      Run code when this Toggleable is toggled OFF.
      Parameters:
      runnable - A Runnable that is executed when this toggleable is toggled OFF.
      Returns:
      This Toggleable instance.