Exemplo n.º 1
0
        /// <summary>
        ///     Get neighbor blocks in given radius.
        /// </summary>
        /// <param name="slimBlock">The block used to find his neighbors.</param>
        /// <param name="radius">The radius used to search for neighbors.</param>
        /// <param name="slimBlocks">Found neighbors are stored here.</param>
        private static void GetNeighbors(IMySlimBlock slimBlock, int radius, ref HashSet <IMySlimBlock> slimBlocks)
        {
            var neighbors = new List <IMySlimBlock>();

            slimBlock.GetNeighbours(neighbors);
            foreach (var neighbor in neighbors)
            {
                if (slimBlocks.Contains(neighbor))
                {
                    continue;
                }

                slimBlocks.Add(neighbor);
                if (radius > 1)
                {
                    GetNeighbors(neighbor, radius - 1, ref slimBlocks);
                }
            }
        }