コード例 #1
0
ファイル: Path.cs プロジェクト: suilevap/bt-tree
        internal NodeContext <TBlackboard> Push(Node <TBlackboard> node, Path <TBlackboard> runningPath)
        {
            NodeContext <TBlackboard> result;

            result = _nodeContextCreator.Get(node);

            int  currentLevel = Count;
            bool prevRunning  = currentLevel == 0 || _nodesContext[currentLevel - 1].IsRunning;

            //if previous node is last running path
            if (prevRunning && currentLevel < runningPath.Count)
            {
                var candidate = runningPath[currentLevel];
                if (candidate.Node == node)
                {
                    //if this node is on last running path
                    result.CopyFrom(candidate);
                    result.IsRunning = true;
                }
            }

            Add(result);
            return(result);
        }