Skip to content

Instantly share code, notes, and snippets.

@xdegtyarev
Created August 5, 2014 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xdegtyarev/a65e93205618a9aca3e5 to your computer and use it in GitHub Desktop.
Save xdegtyarev/a65e93205618a9aca3e5 to your computer and use it in GitHub Desktop.
FSM example: FSM
public class FSM {
public Robot entity;
public State currentState;
public FSM( Robot entity ) {
this.entity = entity;
}
public void Update() {
if ( currentState != null ) {
currentState.Execute( entity );
}
}
public void ChangeState( Robot newState ) {
currentState.Exit( entity );
currentState = newState;
currentState.Enter( entity );
currentState.Execute( entity );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment