コード例 #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);
                }
            }
        }
コード例 #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);
                }
            }
        }
コード例 #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);
        }
コード例 #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);
 }
コード例 #5
0
 public void Iterate(bool recursive, bool includeIONode, IteratorAction action)
 {
     Iterate(this, recursive, includeIONode, action);
 }
コード例 #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);
                }
            }
        }
コード例 #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);
 }