-
-
Notifications
You must be signed in to change notification settings - Fork 15
Transition
GMIKE edited this page Mar 13, 2020
·
30 revisions
You can add transition set states object or states name
//Throw exeption if state already exist
Transition transition1 = stateMachine.AddTransition("Transition1", state1, state2);
Transition transition1 = stateMachine.AddTransition("Transition1", "state1", state2);
Transition transition1 = stateMachine.AddTransition("Transition1", state1, "state2");
Transition transition1 = stateMachine.AddTransition("Transition1", "state1", "state2");
//Return null if state already exist
Transition transition1 = stateMachine.TryAddTransition(out bool result, "Transition1", state1, state2);
Transition transition1 = stateMachine.TryAddTransition(out bool result, "Transition1", "state1", state2);
Transition transition1 = stateMachine.TryAddTransition(out bool result, "Transition1", state1, "state2");
Transition transition1 = stateMachine.TryAddTransition(out bool result, "Transition1", "state1", "state2");
You can add transition from this state
//Throw exeption if state already exist
Transition transition1 = state1.AddTransitionFromThis("Transition1", state2);
Transition transition1 = state1.AddTransitionFromThis("Transition1", "state2");
//Return null if state already exist
Transition transition1 = state1.TryAddTransitionFromThis(out bool result, "Transition1", state2);
Transition transition1 = state1.TryAddTransitionFromThis(out bool result, "Transition1", "state2");
//Throw exeption if state not found
State state1 = stateMachine.GetState("State1");
//Return null if state not found
State state1 = stateMachine.TryGetState("State1", out bool result);
//Throw exeption if state not found
stateMachine.DeleteState("State1");
stateMachine.TryDeleteState("State1");
//Throw exeption if state not found
stateMachine.DeleteState(state1);
stateMachine.TryDeleteState(state1);
//Throw exeption if state already delete from state machine
state1.Delete();
state1.TryDelete(out bool result);
Triggered after invoke transition. You can set many action for one state, but transition will be invoke that was called last
void ActionOnEtnry(State state, Dictionary<string, object> parameters)
{
//you need invoke transition in entry or exit action, differently work state machine will be end
state.StateMachine.InvokeTransition("Transition1");
}
//you can set action with add. Throw exeption if ActionOnEtnry is null
State state1 = stateMachine.AddState("State1", actionOnEntry: ActionOnEtnry);
//you can set action after add. Throw exeption if ActionOnEtnry is null
State state1 = stateMachine.AddState("State1").OnEntry(ActionOnEtnry);
//Throw exeption ActionOnEtnry is null
state1.OnEntry(ActionOnEtnry);
Triggered after entry to state. You can set many action for one state, but transition will be invoke that was called last
void ActionOnExit(State state, Dictionary<string, object> parameters)
{
//you need invoke transition in entry or exit action, differently work state machine will be end
state.StateMachine.InvokeTransition("Transition1");
}
//you can set action with add. Throw exeption if ActionOnExitis null
State state1 = stateMachine.AddState("State1", actionOnExit: ActionOnExit);
//you can set action after add. Throw exeption if ActionOnExitis null
State state1 = stateMachine.AddState("State1").OnExit(ActionOnExit);
//Throw exeption ActionOnExitis null
state1.OnExit(ActionOnExit);