Interface IStateMachine<T extends IStateMachineTransition<S>,S extends IState>
- Type Parameters:
T- the statemachine transition.S- the State.
- All Known Subinterfaces:
ITickRateStateMachine<S>
- All Known Implementing Classes:
BasicStateMachine,TickRateStateMachine
public interface IStateMachine<T extends IStateMachineTransition<S>,S extends IState>
Statemachine interface, implement to add more statemachine types. Contains all needed functions for a basic statemachine
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddTransition(T transition) Adds a transitions to the machine's transition tablevoidaddTransitionGroup(List<S> stateGroup, T transition) Add a transition to a group of states has higher priority than normal transitionsbooleancheckTransition(T transition) Checks the transitions conditionnet.minecraft.network.chat.ComponentGet the state transition history for displaygetState()Return the current state of the StatemachinevoidremoveTransition(T transition) Removes a transition from the machine's transition tablevoidreset()Reset the statemachine to the startvoidsetHistoryEnabled(boolean enabled, int memorySize) Set whether the state history is trackedvoidtick()Update the statemachine, checks current state and its transitionsbooleantransitionToNext(T transition) Change the state to the next
-
Method Details
-
addTransition
Adds a transitions to the machine's transition table- Parameters:
transition- the transition to add.
-
addTransitionGroup
Add a transition to a group of states has higher priority than normal transitions- Parameters:
transition- the transition to add
-
removeTransition
Removes a transition from the machine's transition table- Parameters:
transition- the transition to remove.
-
tick
void tick()Update the statemachine, checks current state and its transitions -
checkTransition
Checks the transitions condition- Parameters:
transition- the transition to check.- Returns:
- true if should run.
-
transitionToNext
Change the state to the next- Parameters:
transition- the transition providing the state change- Returns:
- true if the transition provided a state to change to, false on null
-
getState
S getState()Return the current state of the Statemachine- Returns:
- the state.
-
reset
void reset()Reset the statemachine to the start -
setHistoryEnabled
void setHistoryEnabled(boolean enabled, int memorySize) Set whether the state history is tracked- Parameters:
enabled-memorySize- amount of entries kept
-
getHistory
net.minecraft.network.chat.Component getHistory()Get the state transition history for display- Returns:
-