Skip to content

Commit

Permalink
Preparing to release 0.1.9
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin.sciesinski committed Jan 20, 2021
1 parent 919f1fe commit 6104a87
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ allprojects {
apply plugin: "maven-publish"

group = "com.gempukku.libgdx.lib"
version = '0.1.8'
version = '0.1.9'
ext {
appName = "Libgdx Graph"
gdxVersion = '1.9.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectSet;

public class FiniteStateMachine {
private String currentState;
private ObjectMap<String, FiniteMachineState> states = new ObjectMap<>();
private ObjectSet<String> tmpSet = new ObjectSet<>();

public FiniteStateMachine(String initialState, MachineState machineState) {
this.currentState = initialState;
Expand All @@ -30,10 +32,13 @@ public void addStateTransition(String state, MachineStateTransition transition)
}

public void update(float delta) {
tmpSet.clear();
FiniteMachineState finiteMachineState = states.get(currentState);
while (true) {
tmpSet.add(currentState);
String newStateName = finiteMachineState.checkTransitions();
if (newStateName == null)
// Can't transition to a state the machine has been in, this frame already
if (newStateName == null || tmpSet.contains(newStateName))
break;
finiteMachineState.getMachineState().transitioningTo(newStateName);
finiteMachineState = states.get(newStateName);
Expand Down

0 comments on commit 6104a87

Please sign in to comment.