예제 #1
0
            public virtual void ChangeState(IStateMachine newState)
            {
                //@todo probably want to throw exception instead
                if ((currentState == null) || (newState == null))
                {
                    throw new Exception("can't change from or to invalid state");
                }

                //IemUtils.SLog("stateManager:"+ this.GetType().Name);
                IemUtils.SLog(this.GetType().Name + ":ChangeState:oldstate:" +
                              currentState.ToString().Replace("Oxide.Plugins.", ""));

                currentState.Exit(this);
                previousState = currentState;
                currentState  = newState;
                currentState.Enter(this);
                IemUtils.SLog(this.GetType().Name + ":ChangeState:newstate:" +
                              newState.ToString().Replace("Oxide.Plugins.", ""));
            }
예제 #2
0
    public void ChangeState(IStateMachine newState)
    {
        if (currentState != null)
        {
            currentState.Exit();             //exit the old state & run whatever functionality is in the old state's exit
        }


        // enter the new state
        currentState = newState;
        currentState.Enter();
    }