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); } }
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); } }
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); }
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);
public NodeState Tick(int index, INodeBlob blob, IBlackboard blackboard) { VirtualMachine.Reset(index, blob, blackboard, blob.GetEndIndex(index) - index); return(NodeState.Success); }
public static void Reset(INodeBlob blob, IBlackboard bb) { var count = blob.GetEndIndex(0); Reset(0, blob, bb, count); }