public void SwitchState(PawnState state) { LastState = CurrentState; if (LastState) { LastState.DoEnd(); } CurrentState = state; if (CurrentState) { CurrentState.DoStart(); } }
public void SwitchState(PawnState state) { if (state == null) { return; } if (state != CurrentState) { LastState = CurrentState; } if (LastState) { LastState.DoEnd(); } CurrentState = state; if (CurrentState) { CurrentState.DoStart(); } }