JojikYT

StateMachine

Dec 18th, 2021 (edited)
4,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.35 KB | None | 0 0
  1. public class StateMachine
  2. {
  3.     public State currentState;
  4.  
  5.     public void Initialize(State startingState)
  6.     {
  7.         currentState = startingState;
  8.         startingState.Enter();
  9.     }
  10.  
  11.     public void ChangeState(State newState)
  12.     {
  13.         currentState.Exit();
  14.  
  15.         currentState = newState;
  16.         newState.Enter();
  17.     }
  18.  
  19.    
  20. }
  21.  
Add Comment
Please, Sign In to add comment