public virtual bool SetOrInitializeState(StateOld state) { bool success = false; if (state && state != currentState) { StateOld oldState = currentState; currentState = state; if (oldState) { oldState.ExitState(); } if (stateList.Contains(currentState)) { currentState.EnterState(); } else { currentState.Initialize(this); stateList.Add(currentState); } success = true; } return(success); }
public virtual bool SetState(StateOld state) { //print(state.name); bool success = false; if (state && state != currentState) { StateOld oldState = currentState; currentState = state; if (oldState) { oldState.ExitState(); } currentState.EnterState(); success = true; } return(success); }