Beispiel #1
0
        /// <summary>
        /// Used to transition to another state
        /// </summary>
        /// <param name="stateName">The name of the state to transition too</param>
        /// <param name="args">The arguments that is needed to handle a command, like a point in world space or a transform to follow.</param>
        public bool TransitionToState(string stateName, params object[] args)
        {
            NextState = GetState(stateName);
            if (NextState == null)
            {
                return(false);
            }

            // TODO: handle better if the same state. Good for now.
            if (CurrentState == NextState)
            {
                CurrentState.Initialize(this, args);
                CurrentPhase = StatePhases.ENTER;
            }
            else
            {
                NextState.Initialize(this, args);
                CurrentPhase = StatePhases.EXIT;
            }

            return(true);
        }