Beispiel #1
0
        /// <summary>
        /// Set the state of the doors.
        /// </summary>
        public void SetState(DoorState state)
        {
            if (state == _state)
            {
                return;
            }

            _state = state;
            OnStateChanged.SafeInvoke(_state);
        }
Beispiel #2
0
        /// Performs the state transition
        ///
        /// @param nextStateID
        ///     The ID of the next state
        ///
        protected virtual void ChangeState(int nextStateID)
        {
            StateBinding nextState = m_stateBindings.TryGetValue(nextStateID);

            Debug.Assert(nextState != null, string.Format("Cannot find the desired state with id {0}", nextStateID));

            if (m_currentState != null)
            {
                m_currentState.m_exitStateFunc.SafeInvoke();
            }

            m_currentState = nextState;
            OnStateChanged.SafeInvoke();
            m_currentState.m_enterStateFunc.SafeInvoke();
        }