Exemplo n.º 1
0
        /// <summary>
        /// Swaps target state to current state
        /// </summary>
        /// <param name="obj">A reference to the object</param>
        void SwapStates(ref T obj)
        {   //Make sure we have a valid controller
            if (EqualityComparer <T> .Default.Equals(obj, default) || _target == _current || _target == null)
            {
                return;
            }
            //Call end on our current state
            _current.State_End(ref obj);
            //Swap our states around
#if PREVIOUS_STATE_MACHINE
            _previous = _current;
#endif
            _current = _target;
            _target  = null;
            //call state on our new state
            _current.State_Start(ref obj);
        }