Package rekit.util.state
Class State
java.lang.Object
rekit.util.state.State
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 Summary
FieldsModifier and TypeFieldDescriptionprotected TimeStateMachineA reference to the parentingTimeStateMachinethat is used to switchStates.protected Timer -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidenter(TimeStateMachine parent) Method that is called by theTimeStateMachineupon entering thisState.abstract StateMust supply a fully instantiatedStatethat the parentingTimeStateMachinewill enter after thisStateis out of time as specified ingetTimerTime().abstract longMust supply the time in millis how long theTimeStateMachineis supposed to be in thisStatebefore switching to the next as specified ingetNextState().protected voidMethod that may or may not be implemented by a concrete state to perform periodic actionsvoidleave()Method that is called by theTimeStateMachineupon leaving thisState.voidMethod that is periodically called by theTimeStateMachine.
-
Field Details
-
parent
A reference to the parentingTimeStateMachinethat is used to switchStates. -
timer
-
-
Constructor Details
-
State
public State()Constructor that initializes thetimerusinggetTimerTime().
-
-
Method Details
-
enter
Method that is called by theTimeStateMachineupon entering thisState.- Parameters:
parent- the parentingTimeStateMachinethat handles this (and probably other)States.
-
leave
public void leave()Method that is called by theTimeStateMachineupon leaving thisState. -
logicLoop
public void logicLoop()Method that is periodically called by theTimeStateMachine. -
internalLogicLoop
protected void internalLogicLoop()Method that may or may not be implemented by a concrete state to perform periodic actions -
getNextState
Must supply a fully instantiatedStatethat the parentingTimeStateMachinewill enter after thisStateis out of time as specified ingetTimerTime().- Returns:
- the next
Stateto enter.
-
getTimerTime
public abstract long getTimerTime()Must supply the time in millis how long theTimeStateMachineis supposed to be in thisStatebefore switching to the next as specified ingetNextState().- Returns:
- the time in millis to stay in this
State.
-