예제 #1
0
        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;
                }
            }
        }
예제 #2
0
        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);
        }
예제 #3
0
        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
            }
        }
예제 #4
0
        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;
                }
            }
        }
예제 #5
0
        ///<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);
        }
예제 #6
0
 bool IsInstance(FSM fsm)
 {
     return(instances.Values.Contains(fsm));
 }
예제 #7
0
 bool IsInstance(FSM fsm)
 {
     return instances.Values.Contains(fsm);
 }
예제 #8
0
 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)"));
         }
     }
 }