예제 #1
0
파일: State.cs 프로젝트: uvbs/babbot
        /// <summary>
        /// Call this method when current state decide it need swith to different state,
        /// For ex travel state after it find destination coordinates switch to navigation
        /// state to actually start moving to destination
        /// </summary>
        /// <param name="Entity">Object this state interact with</param>
        /// <param name="NewState">New State</param>
        /// <param name="TrackPrevious">True if need track previous state
        /// (i.e state that calling change)</param>
        /// <param name="ExitPrevious">True if need exit previous
        /// (i.e state that calling change)</param>
        /// <returns>True if change accepted and false if not</returns>
        protected bool CallChangeStateEvent(T Entity, State <T> NewState,
                                            bool TrackPrevious, bool ExitPrevious)
        {
            if (HasChangeStateEventHookup)
            {
                ChangeStateRequest(this, ChangeStateEventArgs <T> .GetArgs(Entity,
                                                                           NewState, TrackPrevious, ExitPrevious));
                return(true);
            }

            return(false);
        }
예제 #2
0
파일: StateMachine.cs 프로젝트: uvbs/babbot
 private void CurrentState_ChangeStateRequest(object sender, ChangeStateEventArgs <T> e)
 {
     //when the currently running state requests a change request (either the global or CurrentState).
     // then pause currently running state and switch to the new one.
     ChangeState(e.NewState, e.TrackPrevious, e.ExitPrevious);
 }