Class Toggleable


  • public class Toggleable
    extends java.lang.Object
    • Constructor Detail

      • 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)
    • Method Detail

      • 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​(java.lang.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​(java.lang.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.