private void Iterate(MyNodeGroup group, bool recursive, bool includeIONodes, IteratorAction action) { if (includeIONodes) { foreach (MyNode inputNode in group.GroupInputNodes) { action(inputNode); } foreach (MyNode outputNode in group.GroupOutputNodes) { action(outputNode); } } foreach (MyNode childNode in group.Children) { action(childNode); if (recursive && childNode is MyNodeGroup) { Iterate(childNode as MyNodeGroup, recursive, includeIONodes, action); } } }
private void Iterate(MyExecutionBlock block, bool recursive, IteratorAction action) { foreach (IMyExecutable executable in block.Children) { action(executable); if (recursive && executable is MyExecutionBlock) { Iterate(executable as MyExecutionBlock, recursive, action); } } }
public bool IteratorGrid(Vector3 pos, int range, IteratorAction action) { int centerX, centerY; if (PosToGridCoord(pos, out centerX, out centerY) == false) { return(false); } for (int i = -range; i <= range; i++) { for (int j = -range; j <= range; j++) { int curX = centerX + i; int curY = centerY + j; if (IsCoordValid(curX, curY) == false) { continue; } action.Invoke(Get(curX, curY), centerX, centerY, curX, curY); } } return(true); }
/// <summary> /// Iterates over all children and performs action on all of them /// </summary> /// <param name="recursive">Iterate recursively if set to true</param> /// <param name="action">Action to perform on iterated elements</param> public void Iterate(bool recursive, IteratorAction action) { Iterate(this, recursive, action); }
public void Iterate(bool recursive, bool includeIONode, IteratorAction action) { Iterate(this, recursive, includeIONode, action); }