Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 /// <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);
 }
Exemplo n.º 5
0
 public void Iterate(bool recursive, bool includeIONode, IteratorAction action)
 {
     Iterate(this, recursive, includeIONode, action);
 }
Exemplo n.º 6
0
        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);
                }
            }
        }
Exemplo n.º 7
0
 /// <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);
 }