public void GoToState(string targetStateName) { NodeCanvas.StateMachines.FSM rootFSM = uiGraph.behaviour; NodeCanvas.StateMachines.FSM graph = rootFSM; string[] targetStates = targetStateName.Split('/'); for (int i = 0; i < targetStates.Length; i++) { if (graph == null) { return; } if (i == targetStates.Length - 1) { graph.TriggerState(targetStates[i]); } else { var node = (NestedFSMState)graph.allNodes.Find(x => x is NestedFSMState && x.name.Equals(targetStates[i])); if (!node.nestedFSM.isRunning) { graph.TriggerState(targetStates[i]); } graph = node.nestedFSM; } } }
public void GoToState(UIBaseState targetState) { NodeCanvas.StateMachines.FSM fsm = uiGraph.behaviour; UIBaseState currState = null; if (uiStateStack.Count > 1) { currState = uiStateStack[uiStateStack.Count - 1]; } AppEventsManager.Publish_StateTransition(currState, targetState); //Debug.Log($"GOTO STATE {targetState.name} in [{fsm.name}]"); fsm.TriggerState(targetState.name); }
void IUpdatable.Update() { if (outConnections.Count == 0) { return; } status = Status.Running; for (var i = 0; i < outConnections.Count; i++) { var connection = (FSMConnection)outConnections[i]; var condition = connection.condition; if (!connection.isActive || condition == null) { continue; } if (dontRetriggerStates) { if (FSM.currentState == (FSMState)connection.targetNode && FSM.currentState.status == Status.Running) { continue; } } if (condition.Check(graphAgent, graphBlackboard)) { FSM.EnterState((FSMState)connection.targetNode, connection.transitionCallMode); connection.status = Status.Success; //editor vis return; } connection.status = Status.Failure; //editor vis } }
public void UpdateAnyState() { if (outConnections.Count == 0) { return; } status = Status.Running; for (int i = 0; i < outConnections.Count; i++) { var connection = outConnections[i] as FSMConnection; if (connection.condition == null) { continue; } if (connection.CheckCondition(graphAgent, graphBlackboard)) { FSM.EnterState(connection.targetNode as FSMState); return; } } }
///<summary>Returns true if a transitions was valid and thus made</summary> public bool CheckTransitions() { for (var i = 0; i < outConnections.Count; i++) { var connection = (FSMConnection)outConnections[i]; var condition = connection.condition; if (!connection.isActive) { continue; } if ((condition != null && condition.Check(graphAgent, graphBlackboard)) || (condition == null && status != Status.Running)) { FSM.EnterState((FSMState)connection.targetNode, connection.transitionCallMode); connection.status = Status.Success; //editor vis return(true); } connection.status = Status.Failure; //editor vis } return(false); }
bool IsInstance(FSM fsm) { return(instances.Values.Contains(fsm)); }
bool IsInstance(FSM fsm) { return instances.Values.Contains(fsm); }
protected override void OnContextMenu(GenericMenu menu) { if (allowAsPrime) { if (Application.isPlaying) { menu.AddItem(new GUIContent("Enter State (ALT+Click)"), false, delegate { FSM.EnterState(this); }); } else { menu.AddDisabledItem(new GUIContent("Enter State (ALT+Click)")); } } }