Пример #1
0
        public override NodeStatusEnum Action()
        {
            if (NodeStatus == NodeStatusEnum.Ready)
            {
                if (_whereFunc())
                {
                    Reset();
                    NodeStatus = _actionNode.Action();
                    return(NodeStatus);
                }
                else
                {
                    NodeStatus = NodeStatusEnum.Failure;
                    return(NodeStatus);
                }
            }

            if (NodeStatus == NodeStatusEnum.Running)
            {
                NodeStatus = _actionNode.Action();
                return(NodeStatus);
            }

            return(NodeStatus);
        }
        void Update()
        {
            if (_rootNode == null)
            {
                return;
            }

            if (_rootNode.NodeStatus != NodeStatusEnum.Ready &&
                _rootNode.NodeStatus != NodeStatusEnum.Running &&
                _autoReset)
            {
                Reset();
            }
            if (_rootNode.NodeStatus == NodeStatusEnum.Success ||
                _rootNode.NodeStatus == NodeStatusEnum.Failure)
            {
                return;
            }
            _rootNode.Action();
        }