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); }
protected override void State(Expression <Func <State> > propertyExpression) { var state = propertyExpression.Compile().Invoke(); WhenEnter(state, x => x.Then(ctx => OnStateEnter.Invoke(this, new StateChangedData <TSagaData>(state, ctx.Instance)))); base.State(propertyExpression); }
/// <summary> /// この関数がキックされる度に登録されたイベントをコールする。 /// </summary> /// <remarks> /// Updateはインスタンスを持つMonoBehaviourで行う。 /// </remarks> public void Update() { if (!isCalledEnter) { OnStateEnter?.Invoke(CurrentState); isCalledEnter = true; } else { OnStateStay?.Invoke(CurrentState); } }
public void AddState(StateBase state) { var stateType = state.GetType(); Debug.Assert(!States.ContainsKey(stateType)); States.Add(stateType, state); state.Initialize(Context); state.OnEnter += (enterState) => { OnStateEnter?.Invoke(enterState); }; state.OnFinish += (finishState) => { OnStateFinish?.Invoke(finishState); }; }
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); }
internal void EnterState() { IsCurrentState = true; if (OnStateEnter != null) { OnStateEnter.Invoke(); } if (HasInnerState) { foreach (Orthogonal <S, T, G> ort in Orthogonals.Values) { ort.SM.Initialize(); } } }
private void HandleTransitionComplete(SkillFSMTransition transition) { CurrentTransition.OnComplete -= HandleTransitionComplete; PreviousState = CurrentState; CurrentState = transition.ToState; CurrentTransition = null; isInitialisingState = true; PreviousState.Exit(); OnStateChange?.Invoke(PreviousState, CurrentState); CurrentState.Enter(); OnStateEnter?.Invoke(CurrentState); isInitialisingState = false; }
protected virtual void EnterState(State targetState) { if (targetState == _currentState) { return; } _currentState = targetState; if (!_transitions.TryGetValue(_currentState.Id, out _currentStateTransitions)) { _currentStateTransitions = _S_EMPTY_TRANSITIONS; } _timeEnteredState = Time.time; _currentState.OnEnterInvoke(); _currentState.Enter(); OnStateEnter?.Invoke(_currentState); }
public Machine(SimpleState initial) : base() { _activeState = initial; OnStateEnter.Add(StateEntered); OnStateExit.Add(StateExited); }
public virtual void Enter() { OnStateEnter?.Invoke(); }
public string GetListeners() { return(OnStateEnter.GetInvocationList().Print()); }
public void Enter(object data, CancellationToken ct) { OnStateEnter?.Invoke(data, ct); }
protected virtual void OnEnter() { _active = true; OnStateEnter?.Invoke(); }