// Exit this state private void ExitState() { Debug.Log("Exit Explosion State"); // Set which state to go. States stateToGo; if (isAnyExploded) { stateToGo = States.Reposition; } else { if (RotationManager.Instance.isOver) { stateToGo = States.Input; } else { stateToGo = States.Rotation; } } // Publish state exit OnStateExit?.Invoke(this, new OnStateExitEventArgs { stateToGo = stateToGo }); }
public void ChangeState(T nextState) { if (Equals(nextState, CurrentState)) { return; } HashSet <OnExit> exitCallbacks; if (OnStateExit.TryGetValue(CurrentState, out exitCallbacks)) { foreach (var callback in exitCallbacks) { callback(nextState); } } PreviousState = CurrentState; CurrentState = nextState; HashSet <OnEnter> enterCallbacks; if (OnStateEnter.TryGetValue(CurrentState, out enterCallbacks)) { foreach (var callback in enterCallbacks) { callback(PreviousState); } } StateEnterTime = TimeSlice.Create(); StateChanged.Publish(PreviousState, CurrentState); }
// Exit this state private void ExitState(bool isClockwise) { Debug.Log("Exit Input State"); isStateActive = false; OnStateExit?.Invoke(this, new OnStateExitEventArgs { isClockwise = isClockwise }); }
public void ChangeState(TEnum next) { if (isCalledEnter) { isCalledEnter = false; OnStateExit?.Invoke(CurrentState); previousState = CurrentState; } currentState = next; }
// Exit this state private void ExitState() { Debug.Log("Exit Reposition State"); // Set checkers to false isStateOver = true; // Clear target positions targetPositions.Clear(); // Publish exit event OnStateExit?.Invoke(this, EventArgs.Empty); }
protected virtual void ExitCurrentState() { if (_currentState == null) { return; } _currentState.OnExitInvoke(); _currentState.Exit(); OnStateExit?.Invoke(_currentState); _currentState = null; }
// Exit this state private void ExitState() { Debug.Log("Exit Rotation State"); isStepOver = true; counter++; if (counter == 3) { isOver = true; } OnStateExit?.Invoke(this, new OnStateExitEventArgs { isOver = isOver }); }
public void ChangeState(TKey key) { if (CurrentState != null) { OnStateExit?.Invoke(CurrentStateKey); } LogExtensions.Log($"State changed to <color=orange>{key}</color>"); CurrentState = states[key]; CurrentStateKey = key; OnStateEnter?.Invoke(key); }
/// <summary> /// Delete the current state, and activate the one bellow that. /// </summary> internal void PopState() { if (_states.Count < 2) { throw new StackOverflowException(); } _states.Peek().OnExit(); OnStateExit?.Invoke(_states.Peek()); _states.Pop(); var currentState = _states.Peek(); State.InitStateManager(this); currentState.OnEnter(); OnStateChanged?.Invoke(currentState); }
/// <summary> /// Calls OnExit on the current state (without Popping it), then Add a new one. /// </summary> internal void PushState(State state) { if (state == null) { Debug.LogWarning("[StateManager] Trying to Push a null state"); return; } if (_states.Count > 0) { _states.Peek().OnExit(); OnStateExit?.Invoke(_states.Peek()); } _states.Push(state); State.InitStateManager(this); _states.Peek().OnEnter(); OnStateChanged?.Invoke(state); }
public bool IssueCommand(IComparable command) { if (IsTransitioning) { return(false); } if (CurrentState == null) { return(false); } else { if (!_transitions.ContainsKey(CurrentState)) { return(false); } if (!_transitions[CurrentState].ContainsKey(command)) { return(false); } if (isInitialisingState) { Debug.LogWarning("Do not call IssueCommand from OnStateChange and OnStateEnter handlers"); return(false); } var transition = _transitions[CurrentState][command]; var ret1 = transition.TestCondition(); var ret2 = OnStateTransition == null || OnStateTransition.Invoke(transition); if (ret1 && ret2) { CurrentTransition = transition; transition.OnComplete += HandleTransitionComplete; OnStateExit?.Invoke(CurrentState); transition.Begin(); } return(true); } }
public virtual void Exit() { OnStateExit?.Invoke(); }
// Exit this state private void ExitState() { Debug.Log("Exit Game Over State"); OnStateExit?.Invoke(this, EventArgs.Empty); }
protected virtual void OnExit() { _active = false; OnStateExit?.Invoke(); }
protected void StateExit() { OnStateExit?.Invoke(Cell); }
public Machine(SimpleState initial) : base() { _activeState = initial; OnStateEnter.Add(StateEntered); OnStateExit.Add(StateExited); }
public virtual void ExitState(T owner) { OnStateExit?.Invoke(owner); OnStateExit = null; }
public void Exit(object data, CancellationToken ct) { OnStateExit?.Invoke(data, ct); }