Пример #1
0
            //in the state patten, this is used to execute the current state
            //not sure if this is relevant to this system???
            public void Update()
            {
                if ((currentState == null))
                {
                    throw new Exception("currentState state is null");
                }

                string buf = currentState.ToString();

                IemUtils.SLog(this.GetType().Name + ":Executing:" + buf);
                currentState.Execute(this);
                IemUtils.SLog(this.GetType().Name + ":Executed:" + buf);
            }
Пример #2
0
            public virtual void SubStateReturn()
            {
                if ((previousState == null))
                {
                    throw new Exception("previousState is null");
                }
                if ((currentState == null))
                {
                    throw new Exception("currentState state is null");
                }

                IemUtils.SLog(this.GetType().Name + ":ChangeState:PrevState:" + currentState);
                IemUtils.SLog(this.GetType().Name + ":ChangeState:Reverting:" + previousState);
                currentState.Exit(this);
                currentState = previousState;
            }
Пример #3
0
            public StateManager(IStateMachine initialState)
            {
                if ((initialState == null))
                {
                    throw new Exception("initialState cannot be null");
                }

                IemUtils.SLog(this.GetType().Name + ":CREATING");
                //set the initial state
                currentState = initialState;


                //@todo not sure if this is correct. should we enter the initial state?
                currentState.Enter(this);
                IemUtils.SLog(this.GetType().Name + ":initialstate:" +
                              currentState.ToString().Replace("Oxide.Plugins.", ""));
            }
Пример #4
0
            /// <summary>
            /// enter a substate, where you want to revert to the previous state
            /// </summary>
            /// <param name="newState"></param>
            public virtual void SubState(IStateMachine newState)
            {
                if ((currentState == null))
                {
                    throw new Exception("currentState state is null");
                }

                if ((newState == null))
                {
                    throw new Exception("newState is null");
                }


                IemUtils.SLog(this.GetType().Name + ":ChangeState:PrevState:" + currentState);
                previousState = currentState;
                currentState  = newState;
                currentState.Enter(this);
                IemUtils.SLog(this.GetType().Name + ":ChangeState:newstate:" + newState);
            }
Пример #5
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.", ""));
            }