Class StateManager
java.lang.Object
com.blackrook.engine.state.StateManager
- All Implemented Interfaces:
EngineInputHandler, EngineUpdateHandler
The state manager class for maintaining exclusive, updatable states.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchange(StateManager.StateEntry... changeStates) Changes the current state by emptying the state stack and pushing new ones onto the stack by name.booleanisEmpty()booleanonInputFlag(String code, boolean set) Handles a boolean input code setting.booleanonInputValue(String code, double value) Handles an input value change.pop()Pops a bunch of game states off of the state stack as returns it.voidpop(int stateCount) Pops a bunch of game states off of the state stack.voidpush(StateManager.StateEntry... pushStates) Pushes new states onto the stack.intsize()voidupdate(long tick, long currentNanos) Updates this component.
-
Constructor Details
-
StateManager
public StateManager()
-
-
Method Details
-
change
Changes the current state by emptying the state stack and pushing new ones onto the stack by name. CallsState.exit()on each state popped andState.enter(StateConfig)on each state pushed.- Parameters:
changeStates- the states to push in the specified order.
-
push
Pushes new states onto the stack. CallsState.enter(StateConfig)on each state pushed.- Parameters:
pushStates- the states to push in the specified order. onto the stack, false if at least one was not.
-
pop
Pops a bunch of game states off of the state stack as returns it. CallsState.exit()on the state popped.- Returns:
- the state popped.
-
pop
public void pop(int stateCount) Pops a bunch of game states off of the state stack. CallsState.exit()on each state popped.- Parameters:
stateCount- the amount of states to pop.
-
update
public void update(long tick, long currentNanos) Description copied from interface:EngineUpdateHandlerUpdates this component.- Specified by:
updatein interfaceEngineUpdateHandler- Parameters:
tick- the current tick in the updater (counts upward each update).currentNanos- the current nanotime for the update frame.
-
onInputFlag
Description copied from interface:EngineInputHandlerHandles a boolean input code setting. This is best used for things like key presses and mouse buttons and anything else that has a semantically boolean state.This method is called if the previous input listeners did not handle this.
- Specified by:
onInputFlagin interfaceEngineInputHandler- Parameters:
code- the input code.set- true if active, false if inactive.- Returns:
- true if this method handled the call, false otherwise.
-
onInputValue
Description copied from interface:EngineInputHandlerHandles an input value change. This is best used for things like axis changes, throttles, and whatever has a variable input value.This method is called if the previous input listeners did not handle this.
- Specified by:
onInputValuein interfaceEngineInputHandler- Parameters:
code- the input code.value- the value of the input.- Returns:
- true if this method handled the call, false otherwise.
-
size
public int size()- Returns:
- the amount of states in the stack.
-
isEmpty
public boolean isEmpty()- Returns:
- true if there are no states on the stack.
-