Example #1
0
#pragma warning restore 0649
        #endregion

        public override Queue <Vector3Int> Modify(Grid3D grid, Vector3Int index)
        {
            Core.Cell root;
            if ((root = grid.TryGetCellByIndex(ref index)) == null)
            {
                return(null);
            }

            Queue <Vector3Int> newIndexes = new Queue <Vector3Int>();
            List <Core.Cell>   neighb     = grid.GetNeighboursCell(ref index);

            foreach (Core.Cell cell in neighb)
            {
                newIndexes.Enqueue(cell.GetIndex());
            }

            //Modif
            Vector3Int upIndex = root.GetIndex() + grid.GetConnexAxes()[1];

            if (!grid.HaveCell(ref upIndex))
            {
                int        height = Random.Range(Min_Random, Max_Random);
                GameObject prefab = FuncEditor.GetPrefabFromInstance(root.gameObject);
                for (int i = 0; i < height; i++)
                {
                    if (!grid.HaveCell(ref upIndex))
                    {
                        FuncEditor.InstantiateCell(prefab, grid, upIndex);
                    }
                    upIndex += grid.GetConnexAxes()[1];
                }
            }
            return(newIndexes);
        }
Example #2
0
        public override Queue <Vector3Int> Modify(Grid3D grid, Vector3Int index)
        {
            Queue <Vector3Int> newIndexes = new Queue <Vector3Int>();

            Core.Cell  root    = grid.TryGetCellByIndex(ref index);
            Vector3Int upIndex = index + Vector3Int.up;

            Core.Cell up = grid.TryGetCellByIndex(ref upIndex);

            if (root == null)
            {
                return(null);
            }

            List <Core.Cell> neighb = grid.GetNeighboursCell(ref index);

            foreach (Core.Cell cell in neighb)
            {
                if (cell.GetIndex().y == index.y)
                {
                    newIndexes.Enqueue(cell.GetIndex());
                }
            }

            Vector3Int downIndex = index + Vector3Int.down;

            Core.Cell down = grid.TryGetCellByIndex(ref downIndex);

            int otherLayerCount = up != null ? down != null ? 2 : 1 : 0;

            int arity = (neighb.Count - otherLayerCount);

            if (_low_pass_arity < arity && arity <= _high_pass_arity)
            {
                return(newIndexes);
            }

            if (up != null)
            {
                _to_delete.Enqueue(root);
            }

            return(newIndexes);
        }
Example #3
0
 /// <summary>
 /// Gizmo for debuging the neighbours of a cell.
 /// </summary>
 /// <param name="index">The index of the cell.</param>
 /// <param name="grid">The grid it belongs</param>
 /// <param name="color">Color of the gizmo.</param>
 /// <param name="offsetSize"> The scale amount add to the grid size cell.</param>
 public static void DebugNeigbours(Vector3Int index, Grid3D grid, Color color, float offsetSize = 0.01f)
 {
     DebugCells(grid.GetNeighboursCell(ref index), color, offsetSize);
 }