Class StateMachine<S>
java.lang.Object
nl.colorize.multimedialib.scene.StateMachine<S>
- Type Parameters:
S- The type of state represented by this finite state machine. States are considered equal ifstateA.equals(stateB). If the state implements theUpdatableinterface, theupdatemethod of the currently active state will be called when the state machine itself receives frame updates.
- All Implemented Interfaces:
Updatable
Finite state machine that allows a number of possible states, but can
only have one currently active state at any point in time.
The state machine implements the Updatable interface, so it needs
to receive frame updates in order to function. Requested states are stored
in a queue, with the actual state change only occurring during the frame
update.
By default, every state is allowed to transition into every other state. The state machine can optionally be configured to restrict allowed transitions based on the currently active state.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidforceState(S nextState) Forces this state machine into the specified state, clearing the queue so that the requested state becomes active during the next frame update.booleanrequestState(S nextState) Requests the state machine to transition into the specified state at the earliest opportunity.booleanrequestState(S nextState, float duration) Requests the state machine to transition into the specified state at the earliest opportunity.voidupdate(float deltaTime) Updates this state machine based on the elapsed relative time, as specified by theUpdatableinterface.
-
Constructor Details
-
StateMachine
-
-
Method Details
-
requestState
Requests the state machine to transition into the specified state at the earliest opportunity. Once active, the state will remain active until another state is requested.Returns a boolean indicating if the state machine allows a transition from the preceding state in the queue into the requested state.
-
requestState
Requests the state machine to transition into the specified state at the earliest opportunity. Once active, the state will remain active for the specified duration (in seconds).Returns a boolean indicating if the state machine allows a transition from the preceding state in the queue into the requested state.
-
forceState
Forces this state machine into the specified state, clearing the queue so that the requested state becomes active during the next frame update. -
update
-
getActiveState
-
getActiveStateTimer
-