private void SwitchToState(States state) { _errorProvider.DoWith(() => { DeactivateCurrent(); _currentState = _stateProvider(state); _currentState.Activate(_currentUser, _currentItem); RaiseStateChanged(); }); }
public void Start() { //Clean up activeStates.Clear(); //Set up activeStates.AddLast(startState); startState.Activate(); //invoke the OnStart event which allows the user to add more functionality to the Start method Starting?.Invoke(this, EventArgs.Empty); }
public void ChangeState(Squad squad, IState newState, bool rememberPrevious) { if (rememberPrevious) { previousState = currentState; } currentState?.Deactivate(squad); if (newState != null) { currentState = newState; } currentState?.Activate(squad); }
private void StartState(string stateName) { //deactivate the currently active state if (_activeState != null && _activeState.IsActive) { _activeState.Deactivate(); } _previousState = _activeState; //try activate desired one try { _activeState = _states[stateName]; _activeState.Activate(); } catch (Exception e) { Debug.LogException(e); } }
/// <summary> /// 激活使用,此时排除其他对象对该实例的使用 /// </summary> public virtual void Activate() { state.Activate(this); }
public void Activate(IAccountIdentity account) { state.Activate(this, account); }
/// <summary> /// Активирует состояние, принуждая к деактивации допустимые конфликтующие с ним. /// </summary> /// <param name="state"> Состояние. </param> public void ActivateState(IState state) { if (!current.Contains(state)) return; if (!current.Contains(state)) return; if (state.IsActivated()) return; if (state.IsCanActivate(this)) { ForceConflictResolvingFor(state); state.Activate(this); } }
public void SetState(IState state) { _currentState?.Deactivate(); _currentState = state; _currentState?.Activate(); }