Пример #1
0
        public override void AutoTileArea(ulong randSeed, Loc rectStart, Loc rectSize, Loc totalSize, PlacementMethod placementMethod, QueryMethod presenceMethod, QueryMethod queryMethod)
        {
            for (int xx = 0; xx < rectSize.X; xx++)
            {
                for (int yy = 0; yy < rectSize.Y; yy++)
                {
                    int neighborCode = -1;
                    if (Collision.InBounds(totalSize.X, totalSize.Y, rectStart + new Loc(xx, yy)) && presenceMethod(xx + rectStart.X, yy + rectStart.Y))
                    {
                        neighborCode = textureWaterTile(xx + rectStart.X, yy + rectStart.Y, queryMethod);
                    }

                    if (neighborCode != -1)
                    {
                        placementMethod(rectStart.X + xx, rectStart.Y + yy, neighborCode);
                    }
                }
            }
        }
        public override void AutoTileArea(ulong randSeed, Loc rectStart, Loc rectSize, Loc totalSize, PlacementMethod placementMethod, QueryMethod presenceMethod, QueryMethod queryMethod)
        {
            int[][] mainArray = new int[rectSize.X + 2][];
            for (int ii = 0; ii < rectSize.X + 2; ii++)
            {
                mainArray[ii] = new int[rectSize.Y + 2];
                for (int jj = 0; jj < rectSize.Y + 2; jj++)
                {
                    mainArray[ii][jj] = -1;
                }
            }
            int[][] looseArray = new int[rectSize.X][];
            for (int ii = 0; ii < rectSize.X; ii++)
            {
                looseArray[ii] = new int[rectSize.Y];
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    looseArray[ii][jj] = -1;
                }
            }

            for (int xx = 0; xx < rectSize.X + 2; xx++)
            {
                for (int yy = 0; yy < rectSize.Y + 2; yy++)
                {
                    if (Collision.InBounds(totalSize.X, totalSize.Y, new Loc(rectStart.X + xx, rectStart.Y + yy)) && presenceMethod(rectStart.X + xx - 1, rectStart.Y + yy - 1))
                    {
                        textureMainBlock(mainArray, rectStart, rectStart.X + xx - 1, rectStart.Y + yy - 1, queryMethod);
                    }
                }
            }

            for (int xx = 0; xx < rectSize.X; xx++)
            {
                for (int yy = 0; yy < rectSize.Y; yy++)
                {
                    if (Collision.InBounds(totalSize.X, totalSize.Y, new Loc(rectStart.X + xx, rectStart.Y + yy)) && presenceMethod(rectStart.X + xx, rectStart.Y + yy) && mainArray[xx + 1][yy + 1] == -1)
                    {
                        textureLooseBlock(looseArray, mainArray, rectStart, rectStart.X + xx, rectStart.Y + yy, queryMethod);
                    }
                }
            }

            ReRandom rand = new ReRandom(randSeed);

            for (int xx = 0; xx < rectStart.X + rectSize.X; xx++)
            {
                int yy = 0;
                for (; yy < rectStart.Y + rectSize.Y; yy++)
                {
                    ulong subSeed = rand.NextUInt64();
                    if (xx >= rectStart.X && yy >= rectStart.Y)
                    {
                        int neighborCode = mainArray[xx + 1 - rectStart.X][yy + 1 - rectStart.Y];
                        if (looseArray[xx - rectStart.X][yy - rectStart.Y] != -1)
                        {
                            neighborCode = looseArray[xx - rectStart.X][yy - rectStart.Y];
                        }

                        if (neighborCode != -1)
                        {
                            placementMethod(xx, yy, GetVariantCode(new ReRandom(subSeed), neighborCode));
                        }
                    }
                }
                while (yy < totalSize.Y)
                {
                    rand.NextUInt64();
                    yy++;
                }
            }
        }
Пример #3
0
        public override void AutoTileArea(ulong randSeed, Loc rectStart, Loc rectSize, Loc totalSize, PlacementMethod placementMethod, QueryMethod presenceMethod, QueryMethod queryMethod)
        {
            ReRandom rand = new ReRandom(randSeed);

            for (int xx = 0; xx < rectStart.X + rectSize.X; xx++)
            {
                int yy = 0;
                for (; yy < rectStart.Y + rectSize.Y; yy++)
                {
                    ulong subSeed = rand.NextUInt64();
                    if (xx >= rectStart.X && yy >= rectStart.Y)
                    {
                        if (Collision.InBounds(totalSize.X, totalSize.Y, new Loc(xx, yy)) && presenceMethod(xx, yy))
                        {
                            placementMethod(xx, yy, GetVariantCode(new ReRandom(subSeed), 0));
                        }
                    }
                }
                while (yy < totalSize.Y)
                {
                    rand.NextUInt64();
                    yy++;
                }
            }
        }
Пример #4
0
        public override void AutoTileArea(ReRandom rand, Loc rectStart, Loc rectSize, PlacementMethod placementMethod, QueryMethod queryMethod)
        {
            for (int ii = 0; ii < rectSize.X; ii++)
            {
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    int neighborCode = -1;
                    if (queryMethod(ii + rectStart.X, jj + rectStart.Y))
                    {
                        neighborCode = textureWaterTile(ii + rectStart.X, jj + rectStart.Y, queryMethod);
                    }

                    if (neighborCode != -1)
                    {
                        placementMethod(rectStart.X + ii, rectStart.Y + jj, GetTile(rand, neighborCode));
                    }
                }
            }
        }
Пример #5
0
        public override void AutoTileArea(ulong randSeed, Loc rectStart, Loc rectSize, Loc totalSize, PlacementMethod placementMethod, QueryMethod presenceMethod, QueryMethod queryMethod)
        {
            int[][] pass1Array = new int[rectSize.X][];
            for (int ii = 0; ii < rectSize.X; ii++)
            {
                pass1Array[ii] = new int[rectSize.Y];
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    pass1Array[ii][jj] = -1;
                }
            }

            ReRandom rand = new ReRandom(randSeed);

            for (int xx = 0; xx < rectStart.X + rectSize.X; xx++)
            {
                int yy = 0;
                for (; yy < rectStart.Y + rectSize.Y; yy++)
                {
                    ulong subSeed = rand.NextUInt64();
                    if (xx >= rectStart.X && yy >= rectStart.Y)
                    {
                        int neighborCode = -1;
                        if (Collision.InBounds(totalSize.X, totalSize.Y, new Loc(xx, yy)) && presenceMethod(xx, yy))
                        {
                            neighborCode = textureBlock(xx, yy, queryMethod);
                        }

                        if (neighborCode != -1)
                        {
                            placementMethod(xx, yy, GetVariantCode(new ReRandom(subSeed), neighborCode));
                        }
                    }
                }
                while (yy < totalSize.Y)
                {
                    rand.NextUInt64();
                    yy++;
                }
            }
        }
Пример #6
0
        public override void AutoTileArea(ReRandom rand, Loc rectStart, Loc rectSize, PlacementMethod placementMethod, QueryMethod queryMethod)
        {
            int[][] pass1Array = new int[rectSize.X][];
            for (int ii = 0; ii < rectSize.X; ii++)
            {
                pass1Array[ii] = new int[rectSize.Y];
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    pass1Array[ii][jj] = -1;
                }
            }

            for (int x = 0; x < rectSize.X; x++)
            {
                for (int y = 0; y < rectSize.Y; y++)
                {
                    int neighborCode = -1;
                    if (queryMethod(rectStart.X + x, rectStart.Y + y))
                    {
                        neighborCode = textureBlock(rectStart.X + x, rectStart.Y + y, queryMethod);
                    }

                    if (neighborCode != -1)
                    {
                        placementMethod(rectStart.X + x, rectStart.Y + y, GetTile(rand, neighborCode));
                    }
                }
            }
        }
Пример #7
0
        public override void AutoTileArea(ulong randSeed, Loc rectStart, Loc rectSize, Loc totalSize, PlacementMethod placementMethod, QueryMethod presenceMethod, QueryMethod queryMethod)
        {
            int[][] mainArray = new int[rectSize.X][];
            for (int ii = 0; ii < rectSize.X; ii++)
            {
                mainArray[ii] = new int[rectSize.Y];
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    mainArray[ii][jj] = -1;
                }
            }

            for (int xx = 0; xx < rectSize.X; xx++)
            {
                for (int yy = 0; yy < rectSize.Y; yy++)
                {
                    if (Collision.InBounds(totalSize.X, totalSize.Y, new Loc(rectStart.X + xx, rectStart.Y + yy)) && presenceMethod(rectStart.X + xx, rectStart.Y + yy))
                    {
                        textureMainBlock(mainArray, rectStart, rectStart.X + xx, rectStart.Y + yy, queryMethod);
                    }
                }
            }

            ReRandom rand = new ReRandom(randSeed);

            //rand next is called for every tile up to the rectangle involved
            //there exists a jump function for rand, but not for arbitrary length
            //if the rand function changes to allow it, change this code block to jump directly to the correct values.
            for (int xx = 0; xx < rectStart.X + rectSize.X; xx++)
            {
                int yy = 0;
                for (; yy < rectStart.Y + rectSize.Y; yy++)
                {
                    ulong subSeed = rand.NextUInt64();
                    if (xx >= rectStart.X && yy >= rectStart.Y)
                    {
                        int neighborCode = mainArray[xx - rectStart.X][yy - rectStart.Y];
                        if (neighborCode != -1)
                        {
                            placementMethod(xx, yy, GetVariantCode(new ReRandom(subSeed), neighborCode));
                        }
                    }
                }
                while (yy < totalSize.Y)
                {
                    rand.NextUInt64();
                    yy++;
                }
            }
        }
Пример #8
0
 public override void AutoTileArea(ReRandom rand, Loc rectStart, Loc rectSize, PlacementMethod placementMethod, QueryMethod queryMethod)
 {
     for (int ii = 0; ii < rectSize.X; ii++)
     {
         for (int jj = 0; jj < rectSize.Y; jj++)
         {
             if (queryMethod(rectStart.X + ii, rectStart.Y + jj))
             {
                 placementMethod(rectStart.X + ii, rectStart.Y + jj, GetTile(rand));
             }
         }
     }
 }
Пример #9
0
 //TODO: pass a seed instead, and choose variation based on the static aspect of the seed
 public abstract void AutoTileArea(ulong randSeed, Loc rectStart, Loc rectSize, Loc totalSize, PlacementMethod placementMethod, QueryMethod presenceMethod, QueryMethod queryMethod);
Пример #10
0
 public abstract void AutoTileArea(ReRandom rand, Loc rectStart, Loc rectSize, PlacementMethod placementMethod, QueryMethod queryMethod);
Пример #11
0
        public override void AutoTileArea(ReRandom rand, Loc rectStart, Loc rectSize, PlacementMethod placementMethod, QueryMethod queryMethod)
        {
            int[][] mainArray = new int[rectSize.X + 2][];
            for (int ii = 0; ii < rectSize.X + 2; ii++)
            {
                mainArray[ii] = new int[rectSize.Y + 2];
                for (int jj = 0; jj < rectSize.Y + 2; jj++)
                {
                    mainArray[ii][jj] = -1;
                }
            }
            int[][] looseArray = new int[rectSize.X][];
            for (int ii = 0; ii < rectSize.X; ii++)
            {
                looseArray[ii] = new int[rectSize.Y];
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    looseArray[ii][jj] = -1;
                }
            }

            for (int x = 0; x < rectSize.X + 2; x++)
            {
                for (int y = 0; y < rectSize.Y + 2; y++)
                {
                    if (queryMethod(rectStart.X + x - 1, rectStart.Y + y - 1))
                    {
                        textureMainBlock(mainArray, rectStart, rectStart.X + x - 1, rectStart.Y + y - 1, queryMethod);
                    }
                }
            }

            for (int x = 0; x < rectSize.X; x++)
            {
                for (int y = 0; y < rectSize.Y; y++)
                {
                    if (queryMethod(rectStart.X + x, rectStart.Y + y) && mainArray[x + 1][y + 1] == -1)
                    {
                        textureLooseBlock(looseArray, mainArray, rectStart, rectStart.X + x, rectStart.Y + y, queryMethod);
                    }
                }
            }

            for (int ii = 0; ii < rectSize.X; ii++)
            {
                for (int jj = 0; jj < rectSize.Y; jj++)
                {
                    int neighborCode = mainArray[ii + 1][jj + 1];
                    if (looseArray[ii][jj] != -1)
                    {
                        neighborCode = looseArray[ii][jj];
                    }

                    if (neighborCode != -1)
                    {
                        placementMethod(rectStart.X + ii, rectStart.Y + jj, GetTile(rand, neighborCode));
                    }
                }
            }
        }