/// <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")); }
/// <summary> /// Unlocks the current State /// </summary> public void UnlockCurrentState(bool removeUnlockActions = true) { CurrentState.IsLocked = false; OnStateUnlocked.Invoke(this); if (removeUnlockActions) { OnStateUnlocked.RemoveAllListeners(); } }
/// <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)); }
/// <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); }
public void OnExecute(StateMachine machine) { OnExecuteEvent?.Invoke(this); }
private void RaiseStateMachineSystemCommand(string eventName, string eventInfo) => StateMachineEvent?.Invoke(this, new StateMachineEventArgs(eventName, eventInfo, StateMachineEventType.Command, "StateMachine"));