示例#1
0
        /// <summary>
        /// Changes the current movement state to the one specified in the parameters, and triggers exit and enter events if needed
        /// </summary>
        /// <param name="newState">New state.</param>
        public virtual void ChangeState(T newState)
        {
            // if the "new state" is the current one, we do nothing and exit
            if (newState.Equals(CurrentState))
            {
                return;
            }

            // we store our previous character movement state
            PreviousState = CurrentState;
            CurrentState  = newState;

            OnStateChange?.Invoke();
        }
        /// <summary>
        /// Changes the current movement state to the one specified in the parameters, and triggers exit and enter events if needed
        /// </summary>
        /// <param name="newState">New state.</param>
        public virtual void ChangeState(T newState)
        {
            // if the "new state" is the current one, we do nothing and exit
            if (EqualityComparer <T> .Default.Equals(newState, CurrentState))
            {
                return;
            }

            // we store our previous character movement state
            PreviousState = CurrentState;
            CurrentState  = newState;

            OnStateChange?.Invoke();

            if (TriggerEvents)
            {
                MMEventManager.TriggerEvent(new MMStateChangeEvent <T> (this));
            }
        }