public bool?SetState(BasicState nextState) { if (nextState == currentState) { return(null); } if (nextState.CanEnter(owner)) { previousState = currentState; currentState = nextState; timeInState = 0.0f; if (previousState.OnExit != null) { previousState.OnExit(owner); } if (nextState.OnEnter != null) { nextState.OnEnter(owner); } if (OnChange != null) { OnChange(previousState.idx, currentState.idx); } return(true); } return(false); }
public bool?SetState(BasicState nextState, bool forced = false) { if (nextState == currentState) { return(null); } if (forced || nextState.CanEnter()) { failedState = null; previousState = currentState; currentState = nextState; if (previousState.OnExit != null) { previousState.OnExit(owner); } if (OnChange != null) { OnChange(previousState.idx); } if (nextState.OnEnter != null) { nextState.OnEnter(owner); } return(true); } failedState = nextState; return(false); }
public bool ForceReenterState() { previousState = currentState; if (currentState.OnEnter != null) { currentState.OnEnter(owner); } if (OnChange != null) { OnChange(previousState.idx, currentState.idx); } return(true); }