示例#1
0
 /// <summary>
 /// Raise an event of type command
 /// </summary>
 /// <param name="eventName"></param>
 /// <param name="eventInfo"></param>
 private void RaiseStateMachineSystemCommand(
     string eventName, string eventInfo)
 {
     // Raise event only, if subscriber exist.
     // Otherwise an exception occurs
     StateMachineEvent?.Invoke(this, new StateMachineEventArgs(
                                   eventName, eventInfo, StateMachineEventType.Command,
                                   "State machine"));
 }
示例#2
0
        /// <summary>
        /// Unlocks the current State
        /// </summary>
        public void UnlockCurrentState(bool removeUnlockActions = true)
        {
            CurrentState.IsLocked = false;
            OnStateUnlocked.Invoke(this);

            if (removeUnlockActions)
            {
                OnStateUnlocked.RemoveAllListeners();
            }
        }
示例#3
0
        /// <summary>
        /// Raises an event of type command
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="eventInfo"></param>
        private void RaiseStateMachineSystemCommand(string eventName, string eventInfo)
        {
            if (this.StateMachineEvent == null)
            {
                return;
            }

            StateMachineEvent.Invoke(
                this,
                new StateMachineEventArgs(eventName, eventInfo, "State machine", StateMachineEventType.Command));
        }
示例#4
0
 /// <summary>
 /// Performs the transition between current State and new State
 /// </summary>
 /// <param name="value">The new State</param>
 protected virtual void Transition(State value)
 {
     if (currentState == value || InTransition)
     {
         return;
     }
     InTransition = true;
     OnStateWillChange.Invoke(this);
     if (currentState != null)
     {
         currentState.Exit();
     }
     currentState = value;
     if (currentState != null)
     {
         currentState.Enter();
     }
     else
     {
         ClearState();
     }
     InTransition = false;
     OnStateChanged.Invoke(this);
 }
示例#5
0
 public void OnExecute(StateMachine machine)
 {
     OnExecuteEvent?.Invoke(this);
 }
示例#6
0
 private void RaiseStateMachineSystemCommand(string eventName, string eventInfo) =>
 StateMachineEvent?.Invoke(this, new StateMachineEventArgs(eventName, eventInfo, StateMachineEventType.Command, "StateMachine"));