public static EmptyGrid ProcessMap(EmptyGrid map, RandomWormsSettings settings)
    {
        // Process Map
        //RandomWorms.map = new bool[width, height];
        //InitialFillMap();
        //FillMapWithFloor();

        FillMap(ref map.values, CellType.Floor, CellType.Wall);

        return(map);
    }
    public static TileMapSettings PreprocessMap(TileMapSettings mapSettings, RandomWormsSettings settings)
    {
        // Random Generator
        Random.State initialState = Random.state;
        if (settings.useFixedSeed)
        {
            Random.InitState(settings.seed.GetHashCode());
        }
        else
        {
            Random.InitState(Time.time.ToString().GetHashCode());
        }

        RandomWorms.settings         = settings;
        RandomWorms.worms            = new List <RandomWorm>();
        RandomWorms.cellsCoordinates = new List <Coordinate>(settings.cellsToCreateCount)
        {
            new Coordinate(0, 0) // Initial spawn cell
        };

        RandomWorms.maxX = RandomWorms.maxZ = RandomWorms.minX = RandomWorms.minZ = 0;

        RandomWorms.worms.Add(new RandomWorm(settings.chanceToTurnAround, settings.chanceToTurn, settings.allowTurnAround));

        for (int i = 1; i < settings.wormsCount; i++)
        {
            RandomWorms.worms.Add(new RandomWorm(RandomWorms.worms[0].GetCurrentCoord()));
        }
        RandomWorm.SetChanceToDie(settings.initialChanceToDie, settings.increaseDieChanceBy);

        RandomWorm.createRoomEvent += CreateRectangularRoom;

        MoveWorms();

        RandomWorm.createRoomEvent -= CreateRectangularRoom;

        RandomWorm.GetMaxCoord(ref RandomWorms.minX, ref RandomWorms.maxX, ref RandomWorms.minZ, ref RandomWorms.maxZ);
        mapSettings.mapWidth  = RandomWorms.width = maxX - minX + 1;  //+1 for zero tile
        mapSettings.mapHeight = RandomWorms.height = maxZ - minZ + 1; //+1 for zero tile

        Random.state = initialState;
        return(mapSettings);
    }