-
-
Save xdegtyarev/a65e93205618a9aca3e5 to your computer and use it in GitHub Desktop.
FSM example: FSM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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