/// <summary> /// Makes the state machine go into another state. /// </summary> public void TransitionToNewState(StateBase newState, TriggerBase causedByTrigger) { // exit the current state if (this.CurrentState != null) { this.CurrentState.OnExit(causedByTrigger); } this.CurrentState = newState; UpdateEntityState(); // enter the new state if (this.CurrentState != null) { this.CurrentState.OnEntry(causedByTrigger); } }
/// <summary> /// Makes the state machine go into another state. /// </summary> public async Task TransitionToNewStateAsync(StateBase newState, TriggerBase causedByTrigger) { // exit the current state if (this.CurrentState != null) { await this.CurrentState.OnExitAsync(causedByTrigger); } this.CurrentState = newState; UpdateEntityState(); // enter the new state if (this.CurrentState != null) { await this.CurrentState.OnEntryAsync(causedByTrigger); } }
/// <summary> /// Makes the state machine recive a command. Depending on its current state /// and the designed transitions the machine reacts to the trigger. /// </summary> public abstract void ProcessTrigger(TriggerBase trigger);
/// <summary> /// Is executed when the state machine leaves this state. /// </summary> public virtual void OnExit(TriggerBase trigger) { }
/// <summary> /// Is executed when the state machine enters this state. /// </summary> public virtual void OnEntry(TriggerBase trigger) { trigger.UpdateEntity(this.StateMachine.CurrentEntity); }
public virtual async Task OnExitAsync(TriggerBase trigger) { }
public virtual async Task OnEntryAsync(TriggerBase trigger) { trigger.UpdateEntity(this.StateMachine.CurrentEntity); }
/// <summary> /// Makes the state machine recive a command. Depending on its current state /// and the designed transitions the machine reacts to the trigger. /// </summary> public virtual void ProcessTrigger(TriggerBase trigger) { throw new NotImplementedException(); }
/// <summary> /// Makes the state machine recive a command. Depending on its current state /// and the designed transitions the machine reacts to the trigger. /// </summary> public virtual Task ProcessTriggerAsync(TriggerBase trigger) { throw new NotImplementedException(); }