Class StateMachine
- Namespace
- WitShells.DesignPatterns.Core
A simple, non-MonoBehaviour State Machine that drives an IState. Call ChangeState(IState) to transition and Update() each frame to tick the active state.
public class StateMachine
- Inheritance
-
StateMachine
- Inherited Members
Remarks
Attach the state machine as a field on a MonoBehaviour and call Update() from
MonoBehaviour.Update() to drive it. For hierarchical or concurrent states consider
extending this class.
Methods
ChangeState(IState)
Transitions to a new state: exits the current state (if any), then enters the new state.
public void ChangeState(IState newState)
Parameters
newStateIStateThe state to transition into. Pass
nullto leave no active state.
Update()
Ticks the currently active state by calling Execute().
Call this from MonoBehaviour.Update() every frame.
public void Update()