◆ FiniteStateMachine() [1/3]
game2dai.fsm.FiniteStateMachine.FiniteStateMachine |
( |
| ) |
|
|
private |
Prevent use of default constructor
◆ FiniteStateMachine() [2/3]
game2dai.fsm.FiniteStateMachine.FiniteStateMachine |
( |
BaseEntity |
owner | ) |
|
A FSM belongs to an entity (it cannot be shared by other entities)
- Parameters
-
◆ FiniteStateMachine() [3/3]
game2dai.fsm.FiniteStateMachine.FiniteStateMachine |
( |
BaseEntity |
owner, |
|
|
State |
currentState, |
|
|
State |
previousState, |
|
|
State |
globalState |
|
) |
| |
- Parameters
-
owner | |
currentState | |
previousState | |
globalState | |
◆ changeState()
void game2dai.fsm.FiniteStateMachine.changeState |
( |
State |
newState | ) |
|
Change the current state of the entity.
Before changing the entity's state, the current state will be saved as the previous state. This method will also call the exit() method of the old state and the enter() method of the new state.
- Parameters
-
newState | the new current state |
◆ getCurrentState()
State game2dai.fsm.FiniteStateMachine.getCurrentState |
( |
| ) |
|
◆ getGlobalState()
State game2dai.fsm.FiniteStateMachine.getGlobalState |
( |
| ) |
|
◆ isCurrentState()
boolean game2dai.fsm.FiniteStateMachine.isCurrentState |
( |
State |
state | ) |
|
Sees if the current state is of the same type (class) as the parameter.
- Parameters
-
state | the state we want to compare with. |
- Returns
- true if it is the same class as the current state.
◆ isGlobalState()
boolean game2dai.fsm.FiniteStateMachine.isGlobalState |
( |
State |
state | ) |
|
Sees if the global state is of the same type (class) as the parameter.
- Parameters
-
state | the state we want to compare with. |
- Returns
- true if it is the same class as the global state.
◆ isPreviousState()
boolean game2dai.fsm.FiniteStateMachine.isPreviousState |
( |
State |
state | ) |
|
Sees if the previous state is of the same type (class) as the parameter.
- Parameters
-
state | the state we want to compare with. |
- Returns
- true if it is the same class as the previous state.
◆ isUsingState()
boolean game2dai.fsm.FiniteStateMachine.isUsingState |
( |
State |
st | ) |
|
Use this method if using the singleton objects for each state. If in doubt use the other is????State methods.
- Parameters
-
st | the current state object |
- Returns
- true if the parameter is the same object as this
◆ onMessage()
boolean game2dai.fsm.FiniteStateMachine.onMessage |
( |
Telegram |
msg | ) |
|
This method is called when a telegram for the owning entity is received.
It first passes it to the current state and if it is not processed by that state it is passed to the global state.
- Parameters
-
- Returns
- true if this method processed the telegram
◆ revertToPreviousState()
void game2dai.fsm.FiniteStateMachine.revertToPreviousState |
( |
| ) |
|
Performs the same actions as the changeState() method but the new state will be the previous state.
◆ setCurrentState()
void game2dai.fsm.FiniteStateMachine.setCurrentState |
( |
State |
s | ) |
|
Use this to set the current state.
This will leave the previous state value unchanged.
- Parameters
-
◆ setGlobalState()
void game2dai.fsm.FiniteStateMachine.setGlobalState |
( |
State |
s | ) |
|
Use this to set the global state.
- Parameters
-
◆ setPreviousState()
void game2dai.fsm.FiniteStateMachine.setPreviousState |
( |
State |
s | ) |
|
Use this to set the previous state.
- Parameters
-
◆ update()
void game2dai.fsm.FiniteStateMachine.update |
( |
double |
deltaTime, |
|
|
World |
world |
|
) |
| |
This method is called by the world update method and should not be caled directly.
- Parameters
-
The documentation for this class was generated from the following file:
- /Users/peter/git/ai4games-repos/AI_4_2D_Games/src/game2dai/fsm/FiniteStateMachine.java