internal bool AddTransition(Transition <S, T, G> transition, State <S, T, G> state) { if (StateTransitions.ContainsKey(transition)) { return(false); } StateTransitions.Add(transition, state); return(true); }
private static StateMachine TimerStateMachine() { var ready = new State("Ready"); var running = new State("Running"); var paused = new State("Paused"); var possibleStates = new StateList { ready, running, paused }; var possibleTransitions = new StateTransitions(); possibleTransitions.Add(new SimpleStateTransition(ready, "Start", running, 1, () => true)); return(new StateMachine(possibleStates, ready, possibleTransitions)); }
public TestWorkflowAdmin(xWorkflowAdmin wfa) { Description = wfa.Description; Permissions = new TestAccessControlList(wfa.Permissions); SemanticAliases = new SemanticAliases { Value = string.Join(";", wfa.SemanticAliases) }; States = new StatesAdmin(); foreach (xStateAdmin stateAdmin in wfa.States) { States.Add(-1, new TestStateAdmin(stateAdmin)); } StateTransitions = new StateTransitions(); foreach (xStateTransition transition in wfa.StateTransitions) { StateTransitions.Add(-1, new TestStateTransition(transition)); } Workflow = new TestWorkflow(wfa.Workflow); }
private void FindTransitions(SerializedObject _ownerObj, Dictionary <OTGCombatState, int> _stateRecord, int _currentLevel) { int amountOfTransitions = _ownerObj.FindProperty("m_stateTransitions").arraySize; for (int i = 0; i < amountOfTransitions; i++) { Object nextStateObj = _ownerObj.FindProperty("m_stateTransitions").GetArrayElementAtIndex(i).FindPropertyRelative("m_nextState").objectReferenceValue; if (nextStateObj != null) { OTGCombatState state = (OTGCombatState)nextStateObj; bool transitionRepeats = (_stateRecord.ContainsKey(state)) ? true : false; StateNode n = new StateNode(state, _currentLevel + 1, _stateRecord, i); StateNodeTransition nTrans = new StateNodeTransition(transitionRepeats, n); if (!StateTransitions.ContainsKey(state)) { StateTransitions.Add(state, nTrans); } } } }