Exemplo n.º 1
0
        public static void ForEachChildrenIndices(this INodeBlob blob, int parentIndex, Action <int> action)
        {
            var endIndex   = blob.GetEndIndex(parentIndex);
            var childIndex = parentIndex + 1;

            while (childIndex < endIndex)
            {
                action(childIndex);
                childIndex = blob.GetEndIndex(childIndex);
            }
        }
Exemplo n.º 2
0
        public static IEnumerable <int> GetChildrenIndices(this INodeBlob blob, int parentIndex)
        {
            var endIndex   = blob.GetEndIndex(parentIndex);
            var childIndex = parentIndex + 1;

            while (childIndex < endIndex)
            {
                yield return(childIndex);

                childIndex = blob.GetEndIndex(childIndex);
            }
        }
Exemplo n.º 3
0
        public static int ParentIndex(this INodeBlob blob, int childIndex)
        {
            var endIndex = blob.GetEndIndex(childIndex);

            for (var i = childIndex - 1; i >= 0; i--)
            {
                if (blob.GetEndIndex(i) >= endIndex)
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemplo n.º 4
0
        public static int FirstOrDefaultChildIndex(this INodeBlob blob, int parentIndex, Predicate <NodeState> predicate)
        {
            var endIndex   = blob.GetEndIndex(parentIndex);
            var childIndex = parentIndex + 1;

            while (childIndex < endIndex)
            {
                if (predicate(blob.GetState(childIndex)))
                {
                    return(childIndex);
                }
                childIndex = blob.GetEndIndex(childIndex);
            }
            return(default);
Exemplo n.º 5
0
 public NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard)
 {
     VirtualMachine.Reset(index, blob, blackboard, blob.GetEndIndex(index) - index);
     return(NodeState.Success);
 }
Exemplo n.º 6
0
        public static void Reset(INodeBlob blob, IBlackboard bb)
        {
            var count = blob.GetEndIndex(0);

            Reset(0, blob, bb, count);
        }