Пример #1
0
        /// <summary>
        /// Adds the specified state.
        /// </summary>
        /// <param name="state">The state.</param>
        /// <returns>The newly created behaviour, so that it could be configured with a fluent-like syntax.</returns>
        public FsmStateBehaviour <T> Add(T state)
        {
            var behaviour = new FsmStateBehaviour <T>(state);

            m_StateBehaviours.Add(state, behaviour);
            return(behaviour);
        }
Пример #2
0
        private void InternalSetCurrentState(T value, bool executeSideEffects)
        {
            if (DebugLogHandler != null)
            {
                DebugLogHandler(string.Format("[FSM {0}] : Changing state from {1} to {2}", m_FsmName, m_CurrentState, value));
            }

            if (m_CurrentStateBehaviour != null && executeSideEffects)
            {
                m_CurrentStateBehaviour.TriggerLeave();
            }

            m_StateAge = -1f;

            m_CurrentStateBehaviour = m_StateBehaviours[value];
            m_CurrentState          = value;

            if (m_CurrentStateBehaviour != null && executeSideEffects)
            {
                m_CurrentStateBehaviour.TriggerEnter();
            }
        }