Class State

java.lang.Object
rekit.util.state.State

public abstract class State extends Object

Abstract State whose concrete implementations that a TimeStateMachine can be in.

Concrete classes may add functionality to enter(TimeStateMachine parent) (that is called upon entering this state), leave() (that is called upon leaving this state) and logicLoop() (that is called periodically by the TimeStateMachine).

For automatic switching states, the implementations must supply a getTimerTime() that specifies how (in millis) the TimeStateMachine is supposed to be in this state as well as a getNextState() that returns the next state to enter after that time.

Author:
Angelo Aracri
  • Field Details

  • Constructor Details

  • Method Details

    • enter

      public void enter(TimeStateMachine parent)
      Method that is called by the TimeStateMachine upon entering this State.
      Parameters:
      parent - the parenting TimeStateMachine that handles this (and probably other) States.
    • leave

      public void leave()
      Method that is called by the TimeStateMachine upon leaving this State.
    • logicLoop

      public void logicLoop()
      Method that is periodically called by the TimeStateMachine.
    • internalLogicLoop

      protected void internalLogicLoop()
      Method that may or may not be implemented by a concrete state to perform periodic actions
    • getNextState

      public abstract State getNextState()
      Must supply a fully instantiated State that the parenting TimeStateMachine will enter after this State is out of time as specified in getTimerTime().
      Returns:
      the next State to enter.
    • getTimerTime

      public abstract long getTimerTime()
      Must supply the time in millis how long the TimeStateMachine is supposed to be in this State before switching to the next as specified in getNextState().
      Returns:
      the time in millis to stay in this State.