public override AIStatus OnProcess()
 {
     while (currentNodeIndex < nodes.Count) {
         NodePort port = GetOutputPort("nodes " + currentNodeIndex);
         if (port == null || !port.IsConnected) {
             currentNodeIndex++;
             continue;
         }
         AIBaseNode node = (port.Connection.node as AIBaseNode);
         if (node == null) {
             currentNodeIndex++;
             continue;
         }
         AIStatus status = (graph as AIGraph).Process(node);
         switch (status) {
             case AIStatus.Failure:
                 return status;
             case AIStatus.Success:
                 currentNodeIndex++;
                 continue;
             case AIStatus.Running:
                 return status;
         }
     }
     return AIStatus.Success;
 }
        public AIStatus Process(AIBaseNode node)
        {
            Load(node);
            if (node.AIInitialized == false)
            {
                node.OnInit();
                node.AIInitialized = true;
            }
            AIStatus status = node.OnProcess();

            switch (status)
            {
            case AIStatus.Running:
                Save(node);
                return(status);

            case AIStatus.Failure:
            case AIStatus.Success:
                node.AIInitialized = false;
                Save(node);
                return(status);
            }
            Save(node);
            return(status);
        }
 public void Tick(AIContext context)
 {
     if (startNode == null)
     {
         startNode = nodes.Find(x => x is AIBaseNode && x.Inputs.All(y => !y.IsConnected)) as AIBaseNode;
     }
     this.context = context;
     AIStatus status = Process(startNode);
 }
        public override AIStatus OnProcess()
        {
            while (currentNodeIndex < nodes.Count)
            {
                AIBaseNode node   = (GetOutputPort("nodes " + currentNodeIndex).Connection.node as AIBaseNode);
                AIStatus   status = (graph as AIGraph).Process(node);
                switch (status)
                {
                case AIStatus.Failure:
                    currentNodeIndex++;
                    continue;

                case AIStatus.Success:
                case AIStatus.Running:
                    return(status);
                }
            }
            return(AIStatus.Failure);
        }
Example #5
0
        public override AIStatus OnProcess()
        {
            for (int i = 0; i < nodes.Count; i++)
            {
                NodePort port = GetOutputPort("nodes " + i);
                if (port == null || !port.IsConnected)
                {
                    continue;
                }
                AIBaseNode node = (port.Connection.node as AIBaseNode);
                if (node == null)
                {
                    continue;
                }
                if (((1 << i) & successMask) == 1)
                {
                    continue;
                }
                AIStatus status = (graph as AIGraph).Process(node);
                switch (status)
                {
                case AIStatus.Failure:
                    Abort();
                    return(status);

                case AIStatus.Success:
                    successMask |= (1 << i);
                    continue;

                case AIStatus.Running:
                    continue;
                }
            }
            // See if we're all done.
            for (int i = 0; i < nodes.Count; i++)
            {
                if ((successMask & (1 << i)) == 0)
                {
                    return(AIStatus.Running);
                }
            }
            return(AIStatus.Success);
        }
        public override AIStatus OnProcess()
        {
            AIBaseNode node   = (GetOutputPort("output").Connection.node as AIBaseNode);
            AIStatus   status = (graph as AIGraph).Process(node);

            switch (status)
            {
            case AIStatus.Failure:
                return(AIStatus.Success);

            case AIStatus.Success:
                return(AIStatus.Success);

            case AIStatus.Running:
                return(status);

            default:
                return(status);
            }
        }
Example #7
0
        public override AIStatus OnProcess()
        {
            while (currentRepeat < repeats)
            {
                AIBaseNode node   = (GetOutputPort("output").Connection.node as AIBaseNode);
                AIStatus   status = (graph as AIGraph).Process(node);
                switch (status)
                {
                case AIStatus.Running:
                    return(status);

                case AIStatus.Success:
                    currentRepeat++;
                    continue;

                case AIStatus.Failure:
                    currentRepeat++;
                    hadFailure = true;
                    continue;
                }
            }
            return(hadFailure ? AIStatus.Failure : AIStatus.Success);
        }
Example #8
0
        public override AIStatus OnProcess()
        {
            NodePort p      = GetOutputPort("output");
            AIStatus status = AIStatus.Success;

            if (p.IsConnected)
            {
                if (!hasInitialized)
                {
                    (p.Connection.node as AIBaseNode).OnInit();
                    hasInitialized = true;
                }
                status = (graph as AIGraph).Process(p.Connection.node as AIBaseNode);
            }
            switch (status)
            {
            case AIStatus.Success:
            case AIStatus.Failure:
                hasInitialized = false;
                switch (variableType)
                {
                case VariableType.String: (graph as AIGraph).SetVariable(variableName, sVariable); break;

                case VariableType.Float: (graph as AIGraph).SetVariable(variableName, fVariable); break;

                case VariableType.UnityObject: (graph as AIGraph).SetVariable(variableName, uVariable); break;

                case VariableType.Int: (graph as AIGraph).SetVariable(variableName, iVariable); break;
                }
                return(status);

            case AIStatus.Running:
                return(status);
            }
            return(status);
        }