コード例 #1
0
ファイル: DesertBiome.cs プロジェクト: woodcrafter123/Sources
        public override bool Place(Point origin, StructureMap structures)
        {
            float   num1  = (float)Main.maxTilesX / 4200f;
            int     num2  = (int)(80.0 * (double)num1);
            int     num3  = (int)(((double)GenBase._random.NextFloat() + 1.0) * 80.0 * (double)num1);
            Vector2 scale = new Vector2(4f, 2f);
            Point   start;

            if (!this.FindStart(origin, scale, num2, num3, out start))
            {
                return(false);
            }
            DesertBiome.ClusterGroup clusters = new DesertBiome.ClusterGroup();
            clusters.Generate(num2, num3);
            this.PlaceSand(clusters, start, scale);
            this.PlaceClusters(clusters, start, scale);
            this.AddTileVariance(clusters, start, scale);
            int num4 = (int)((double)scale.X * (double)clusters.Width);
            int num5 = (int)((double)scale.Y * (double)clusters.Height);

            for (int index1 = -20; index1 < num4 + 20; ++index1)
            {
                for (int index2 = -20; index2 < num5 + 20; ++index2)
                {
                    if (index1 + start.X > 0 && index1 + start.X < Main.maxTilesX - 1 && (index2 + start.Y > 0 && index2 + start.Y < Main.maxTilesY - 1))
                    {
                        WorldGen.SquareWallFrame(index1 + start.X, index2 + start.Y, true);
                        WorldUtils.TileFrame(index1 + start.X, index2 + start.Y, true);
                    }
                }
            }
            return(true);
        }
コード例 #2
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point   point;
            float   single  = (float)Main.maxTilesX / 4200f;
            int     num     = (int)(80f * single);
            int     num1    = (int)((GenBase._random.NextFloat() + 1f) * 80f * single);
            Vector2 vector2 = new Vector2(4f, 2f);

            if (!this.FindStart(origin, vector2, num, num1, out point))
            {
                return(false);
            }
            DesertBiome.ClusterGroup clusterGroup = new DesertBiome.ClusterGroup();
            clusterGroup.Generate(num, num1);
            this.PlaceSand(clusterGroup, point, vector2);
            this.PlaceClusters(clusterGroup, point, vector2);
            this.AddTileVariance(clusterGroup, point, vector2);
            int x = (int)(vector2.X * (float)clusterGroup.Width);
            int y = (int)(vector2.Y * (float)clusterGroup.Height);

            for (int i = -20; i < x + 20; i++)
            {
                for (int j = -20; j < y + 20; j++)
                {
                    if (i + point.X > 0 && i + point.X < Main.maxTilesX - 1 && j + point.Y > 0 && j + point.Y < Main.maxTilesY - 1)
                    {
                        WorldGen.SquareWallFrame(i + point.X, j + point.Y, true);
                        WorldUtils.TileFrame(i + point.X, j + point.Y, true);
                    }
                }
            }
            return(true);
        }
コード例 #3
0
ファイル: DesertBiome.cs プロジェクト: PhelixSky/TeDW
        public override bool Place(Point origin, StructureMap structures)
        {
            float   num   = (float)Main.maxTilesX / 4200f;
            int     num2  = (int)(80f * num);
            int     num3  = (int)((GenBase._random.NextFloat() + 1f) * 80f * num);
            Vector2 scale = new Vector2(4f, 2f);
            Point   start;

            if (!this.FindStart(origin, scale, num2, num3, out start))
            {
                return(false);
            }
            DesertBiome.ClusterGroup clusterGroup = new DesertBiome.ClusterGroup();
            clusterGroup.Generate(num2, num3);
            this.PlaceSand(clusterGroup, start, scale);
            this.PlaceClusters(clusterGroup, start, scale);
            this.AddTileVariance(clusterGroup, start, scale);
            int num4 = (int)(scale.X * (float)clusterGroup.Width);
            int num5 = (int)(scale.Y * (float)clusterGroup.Height);

            for (int i = -20; i < num4 + 20; i++)
            {
                for (int j = -20; j < num5 + 20; j++)
                {
                    if (i + start.X > 0 && i + start.X < Main.maxTilesX - 1 && j + start.Y > 0 && j + start.Y < Main.maxTilesY - 1)
                    {
                        WorldGen.SquareWallFrame(i + start.X, j + start.Y, true);
                        WorldUtils.TileFrame(i + start.X, j + start.Y, true);
                    }
                }
            }
            return(true);
        }
コード例 #4
0
ファイル: DesertBiome.cs プロジェクト: xiongyaya/Terraria
        private void AddTileVariance(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int num1 = (int)(scale.X * (double)clusters.Width);
            int num2 = (int)(scale.Y * (double)clusters.Height);

            for (int index1 = -20; index1 < num1 + 20; ++index1)
            {
                for (int index2 = -20; index2 < num2 + 20; ++index2)
                {
                    int  index3 = index1 + start.X;
                    int  index4 = index2 + start.Y;
                    Tile tile1  = GenBase._tiles[index3, index4];
                    Tile tile2  = GenBase._tiles[index3, index4 + 1];
                    Tile tile3  = GenBase._tiles[index3, index4 + 2];
                    if ((int)tile1.type == 53 && (!WorldGen.SolidTile(tile2) || !WorldGen.SolidTile(tile3)))
                    {
                        tile1.type = (ushort)397;
                    }
                }
            }
            for (int index1 = -20; index1 < num1 + 20; ++index1)
            {
                for (int index2 = -20; index2 < num2 + 20; ++index2)
                {
                    int  i      = index1 + start.X;
                    int  index3 = index2 + start.Y;
                    Tile tile   = GenBase._tiles[i, index3];
                    if (tile.active() && (int)tile.type == 396)
                    {
                        bool flag1 = true;
                        for (int index4 = -1; index4 >= -3; --index4)
                        {
                            if (GenBase._tiles[i, index3 + index4].active())
                            {
                                flag1 = false;
                                break;
                            }
                        }
                        bool flag2 = true;
                        for (int index4 = 1; index4 <= 3; ++index4)
                        {
                            if (GenBase._tiles[i, index3 + index4].active())
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag1 ^ flag2 && GenBase._random.Next(5) == 0)
                        {
                            WorldGen.PlaceTile(i, index3 + (flag1 ? -1 : 1), 165, true, true, -1, 0);
                        }
                        else if (flag1 && GenBase._random.Next(5) == 0)
                        {
                            WorldGen.PlaceTile(i, index3 - 1, 187, true, true, -1, 29 + GenBase._random.Next(6));
                        }
                    }
                }
            }
        }
コード例 #5
0
        // Token: 0x06000FCA RID: 4042 RVA: 0x003FAFDC File Offset: 0x003F91DC
        private void AddTileVariance(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int num  = (int)(scale.X * (float)clusters.Width);
            int num2 = (int)(scale.Y * (float)clusters.Height);

            for (int i = -20; i < num + 20; i++)
            {
                for (int j = -20; j < num2 + 20; j++)
                {
                    int  num3      = i + start.X;
                    int  num4      = j + start.Y;
                    Tile tile      = GenBase._tiles[num3, num4];
                    Tile testTile  = GenBase._tiles[num3, num4 + 1];
                    Tile testTile2 = GenBase._tiles[num3, num4 + 2];
                    if (tile.type == 53 && (!WorldGen.SolidTile(testTile) || !WorldGen.SolidTile(testTile2)))
                    {
                        tile.type = 397;
                    }
                }
            }
            for (int k = -20; k < num + 20; k++)
            {
                for (int l = -20; l < num2 + 20; l++)
                {
                    int  num5  = k + start.X;
                    int  num6  = l + start.Y;
                    Tile tile2 = GenBase._tiles[num5, num6];
                    if (tile2.active() && tile2.type == 396)
                    {
                        bool flag = true;
                        for (int m = -1; m >= -3; m--)
                        {
                            if (GenBase._tiles[num5, num6 + m].active())
                            {
                                flag = false;
                                break;
                            }
                        }
                        bool flag2 = true;
                        for (int n = 1; n <= 3; n++)
                        {
                            if (GenBase._tiles[num5, num6 + n].active())
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if ((flag ^ flag2) && GenBase._random.Next(5) == 0)
                        {
                            WorldGen.PlaceTile(num5, num6 + (flag ? -1 : 1), 165, true, true, -1, 0);
                        }
                        else if (flag && GenBase._random.Next(5) == 0)
                        {
                            WorldGen.PlaceTile(num5, num6 - 1, 187, true, true, -1, 29 + GenBase._random.Next(6));
                        }
                    }
                }
            }
        }
コード例 #6
0
        private void PlaceSand(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int   x      = (int)(scale.X * (float)clusters.Width);
            int   y      = (int)(scale.Y * (float)clusters.Height);
            int   num    = 5;
            int   y1     = start.Y + (y >> 1);
            float single = 0f;

            short[] numArray = new short[x + num * 2];
            for (int i = -num; i < x + num; i++)
            {
                int num1 = 150;
                while (num1 < y1)
                {
                    if (!WorldGen.SolidOrSlopedTile(i + start.X, num1))
                    {
                        num1++;
                    }
                    else
                    {
                        single            = single + (float)(num1 - 1);
                        numArray[i + num] = (short)(num1 - 1);
                        break;
                    }
                }
            }
            float single1 = single / (float)(x + num * 2);
            int   num2    = 0;

            for (int j = -num; j < x + num; j++)
            {
                float single2 = Math.Abs((float)(j + num) / (float)(x + num * 2)) * 2f - 1f;
                single2 = MathHelper.Clamp(single2, -1f, 1f);
                if (j % 3 == 0)
                {
                    num2 = Utils.Clamp <int>(num2 + GenBase._random.Next(-1, 2), -10, 10);
                }
                float single3 = (float)Math.Sqrt((double)(1f - single2 * single2 * single2 * single2));
                int   num3    = y1 - (int)(single3 * (float)((float)y1 - single1)) + num2;
                int   num4    = y1 - (int)((float)((float)y1 - single1) * (single3 - 0.15f / (float)Math.Sqrt(Math.Max(0.01, (double)Math.Abs(8f * single2) - 0.1)) + 0.25f));
                num4 = Math.Min(y1, num4);
                int num5 = (int)(70f - Utils.SmoothStep(0.5f, 0.8f, Math.Abs(single2)) * 70f);
                if (num3 - numArray[j + num] < num5)
                {
                    for (int k = 0; k < num5; k++)
                    {
                        int x1   = j + start.X;
                        int num6 = k + num3 - 70;
                        GenBase._tiles[x1, num6].active(false);
                        GenBase._tiles[x1, num6].wall = 0;
                    }
                    numArray[j + num] = (short)Utils.Clamp <int>(num5 + num3 - 70, num3, numArray[j + num]);
                }
                for (int l = y1 - 1; l >= num3; l--)
                {
                    int  x2   = j + start.X;
                    int  num7 = l;
                    Tile tile = GenBase._tiles[x2, num7];
                    tile.liquid = 0;
                    Tile tile1 = GenBase._tiles[x2, num7 + 1];
                    Tile tile2 = GenBase._tiles[x2, num7 + 2];
                    tile.type = (ushort)((!WorldGen.SolidTile(tile1) || !WorldGen.SolidTile(tile2) ? 397 : 53));
                    if (l > num3 + 5)
                    {
                        tile.wall = 187;
                    }
                    tile.active(true);
                    if (tile.wall != 187)
                    {
                        tile.wall = 0;
                    }
                    if (l < num4)
                    {
                        if (l > num3 + 5)
                        {
                            tile.wall = 187;
                        }
                        tile.active(false);
                    }
                    WorldGen.SquareWallFrame(x2, num7, true);
                }
            }
        }
コード例 #7
0
        private void PlaceClusters(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int     x        = (int)(scale.X * (float)clusters.Width);
            int     y        = (int)(scale.Y * (float)clusters.Height);
            Vector2 vector2  = new Vector2((float)x, (float)y);
            Vector2 vector21 = new Vector2((float)clusters.Width, (float)clusters.Height);

            for (int i = -20; i < x + 20; i++)
            {
                for (int j = -20; j < y + 20; j++)
                {
                    float   single   = 0f;
                    int     num      = -1;
                    float   single1  = 0f;
                    int     x1       = i + start.X;
                    int     y1       = j + start.Y;
                    Vector2 vector22 = (new Vector2((float)i, (float)j) / vector2) * vector21;
                    Vector2 vector23 = ((new Vector2((float)i, (float)j) / vector2) * 2f) - Vector2.One;
                    float   single2  = vector23.Length();
                    for (int k = 0; k < clusters.Count; k++)
                    {
                        DesertBiome.Cluster item = clusters[k];
                        if (Math.Abs(item[0].Position.X - vector22.X) <= 10f && Math.Abs(item[0].Position.Y - vector22.Y) <= 10f)
                        {
                            float single3 = 0f;
                            foreach (DesertBiome.Hub hub in item)
                            {
                                single3 = single3 + 1f / Vector2.DistanceSquared(hub.Position, vector22);
                            }
                            if (single3 > single)
                            {
                                if (single > single1)
                                {
                                    single1 = single;
                                }
                                single = single3;
                                num    = k;
                            }
                            else if (single3 > single1)
                            {
                                single1 = single3;
                            }
                        }
                    }
                    float single4 = single + single1;
                    Tile  tile    = GenBase._tiles[x1, y1];
                    bool  flag    = single2 >= 0.8f;
                    if (single4 > 3.5f)
                    {
                        tile.ClearEverything();
                        tile.wall   = 187;
                        tile.liquid = 0;
                        if (num % 15 == 2)
                        {
                            tile.ResetToType(404);
                            tile.wall = 187;
                            tile.active(true);
                        }
                        Tile.SmoothSlope(x1, y1, true);
                    }
                    else if (single4 > 1.8f)
                    {
                        tile.wall = 187;
                        if (!flag || tile.active())
                        {
                            tile.ResetToType(396);
                            tile.wall = 187;
                            tile.active(true);
                            Tile.SmoothSlope(x1, y1, true);
                        }
                        tile.liquid = 0;
                    }
                    else if (single4 > 0.7f || !flag)
                    {
                        if (!flag || tile.active())
                        {
                            tile.ResetToType(397);
                            tile.active(true);
                            Tile.SmoothSlope(x1, y1, true);
                        }
                        tile.liquid = 0;
                        tile.wall   = 216;
                    }
                    else if (single4 > 0.25f)
                    {
                        float single5 = (single4 - 0.25f) / 0.45f;
                        if (GenBase._random.NextFloat() < single5)
                        {
                            if (tile.active())
                            {
                                tile.ResetToType(397);
                                tile.active(true);
                                Tile.SmoothSlope(x1, y1, true);
                                tile.wall = 216;
                            }
                            tile.liquid = 0;
                            tile.wall   = 187;
                        }
                    }
                }
            }
        }
コード例 #8
0
        private void AddTileVariance(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int x = (int)(scale.X * (float)clusters.Width);
            int y = (int)(scale.Y * (float)clusters.Height);

            for (int i = -20; i < x + 20; i++)
            {
                for (int j = -20; j < y + 20; j++)
                {
                    int  num   = i + start.X;
                    int  y1    = j + start.Y;
                    Tile tile  = GenBase._tiles[num, y1];
                    Tile tile1 = GenBase._tiles[num, y1 + 1];
                    Tile tile2 = GenBase._tiles[num, y1 + 2];
                    if (tile.type == 53 && (!WorldGen.SolidTile(tile1) || !WorldGen.SolidTile(tile2)))
                    {
                        tile.type = 397;
                    }
                }
            }
            for (int k = -20; k < x + 20; k++)
            {
                for (int l = -20; l < y + 20; l++)
                {
                    int  x1    = k + start.X;
                    int  num1  = l + start.Y;
                    Tile tile3 = GenBase._tiles[x1, num1];
                    if (tile3.active() && tile3.type == 396)
                    {
                        bool flag = true;
                        int  num2 = -1;
                        while (num2 >= -3)
                        {
                            if (!GenBase._tiles[x1, num1 + num2].active())
                            {
                                num2--;
                            }
                            else
                            {
                                flag = false;
                                break;
                            }
                        }
                        bool flag1 = true;
                        int  num3  = 1;
                        while (num3 <= 3)
                        {
                            if (!GenBase._tiles[x1, num1 + num3].active())
                            {
                                num3++;
                            }
                            else
                            {
                                flag1 = false;
                                break;
                            }
                        }
                        if (flag ^ flag1 && GenBase._random.Next(5) == 0)
                        {
                            WorldGen.PlaceTile(x1, num1 + (flag ? -1 : 1), 165, true, true, -1, 0);
                        }
                        else if (flag && GenBase._random.Next(5) == 0)
                        {
                            WorldGen.PlaceTile(x1, num1 - 1, 187, true, true, -1, 29 + GenBase._random.Next(6));
                        }
                    }
                }
            }
        }
コード例 #9
0
ファイル: DesertBiome.cs プロジェクト: xiongyaya/Terraria
        private void PlaceSand(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int   num1 = (int)(scale.X * (double)clusters.Width);
            int   num2 = (int)(scale.Y * (double)clusters.Height);
            int   num3 = 5;
            int   val1 = start.Y + (num2 >> 1);
            float num4 = 0.0f;

            short[] numArray = new short[num1 + num3 * 2];
            for (int index = -num3; index < num1 + num3; ++index)
            {
                for (int y = 150; y < val1; ++y)
                {
                    if (WorldGen.SolidOrSlopedTile(index + start.X, y))
                    {
                        num4 += (float)(y - 1);
                        numArray[index + num3] = (short)(y - 1);
                        break;
                    }
                }
            }
            float num5 = num4 / (float)(num1 + num3 * 2);
            int   num6 = 0;

            for (int index1 = -num3; index1 < num1 + num3; ++index1)
            {
                float num7 = MathHelper.Clamp((float)((double)Math.Abs((float)(index1 + num3) / (float)(num1 + num3 * 2)) * 2.0 - 1.0), -1f, 1f);
                if (index1 % 3 == 0)
                {
                    num6 = Utils.Clamp <int>(num6 + GenBase._random.Next(-1, 2), -10, 10);
                }
                float num8   = (float)Math.Sqrt(1.0 - (double)num7 * (double)num7 * (double)num7 * (double)num7);
                int   val2_1 = val1 - (int)((double)num8 * (double)((float)val1 - num5)) + num6;
                int   val2_2 = val1 - (int)((double)((float)val1 - num5) * ((double)num8 - 0.150000005960464 / Math.Sqrt(Math.Max(0.01, (double)Math.Abs(8f * num7) - 0.1)) + 0.25));
                int   num9   = Math.Min(val1, val2_2);
                if ((double)Math.Abs(num7) < 0.800000011920929)
                {
                    float num10 = Utils.SmoothStep(0.5f, 0.8f, Math.Abs(num7));
                    float num11 = num10 * num10 * num10;
                    int   num12 = Math.Min(10 + (int)((double)num5 - (double)num11 * 20.0) + num6, val2_1);
                    int   num13 = 50;
                    for (int index2 = num13; (double)index2 < (double)num5; ++index2)
                    {
                        int index3 = index1 + start.X;
                        if (GenBase._tiles[index3, index2].active() && ((int)GenBase._tiles[index3, index2].type == 189 || (int)GenBase._tiles[index3, index2].type == 196))
                        {
                            num13 = index2 + 5;
                        }
                    }
                    for (int index2 = num13; index2 < num12; ++index2)
                    {
                        int index3 = index1 + start.X;
                        int index4 = index2;
                        GenBase._tiles[index3, index4].active(false);
                        GenBase._tiles[index3, index4].wall = (byte)0;
                    }
                    numArray[index1 + num3] = (short)num12;
                }
                for (int index2 = val1 - 1; index2 >= val2_1; --index2)
                {
                    int  i     = index1 + start.X;
                    int  j     = index2;
                    Tile tile1 = GenBase._tiles[i, j];
                    tile1.liquid = (byte)0;
                    Tile tile2 = GenBase._tiles[i, j + 1];
                    Tile tile3 = GenBase._tiles[i, j + 2];
                    tile1.type = !WorldGen.SolidTile(tile2) || !WorldGen.SolidTile(tile3) ? (ushort)397 : (ushort)53;
                    if (index2 > val2_1 + 5)
                    {
                        tile1.wall = (byte)187;
                    }
                    tile1.active(true);
                    if ((int)tile1.wall != 187)
                    {
                        tile1.wall = (byte)0;
                    }
                    if (index2 < num9)
                    {
                        if (index2 > val2_1 + 5)
                        {
                            tile1.wall = (byte)187;
                        }
                        tile1.active(false);
                    }
                    WorldGen.SquareWallFrame(i, j, true);
                }
            }
        }
コード例 #10
0
ファイル: DesertBiome.cs プロジェクト: xiongyaya/Terraria
        private void PlaceClusters(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int     num1 = (int)(scale.X * (double)clusters.Width);
            int     num2 = (int)(scale.Y * (double)clusters.Height);
            Vector2 vector2_1;

            // ISSUE: explicit reference operation
            ((Vector2)@vector2_1).\u002Ector((float)num1, (float)num2);
            Vector2 vector2_2;

            // ISSUE: explicit reference operation
            ((Vector2)@vector2_2).\u002Ector((float)clusters.Width, (float)clusters.Height);
            for (int index1 = -20; index1 < num1 + 20; ++index1)
            {
                for (int index2 = -20; index2 < num2 + 20; ++index2)
                {
                    float   num3      = 0.0f;
                    int     num4      = -1;
                    float   num5      = 0.0f;
                    int     x         = index1 + start.X;
                    int     y         = index2 + start.Y;
                    Vector2 vector2_3 = Vector2.op_Multiply(Vector2.op_Division(new Vector2((float)index1, (float)index2), vector2_1), vector2_2);
                    Vector2 vector2_4 = Vector2.op_Subtraction(Vector2.op_Multiply(Vector2.op_Division(new Vector2((float)index1, (float)index2), vector2_1), 2f), Vector2.get_One());
                    // ISSUE: explicit reference operation
                    float num6 = ((Vector2)@vector2_4).Length();
                    for (int index3 = 0; index3 < clusters.Count; ++index3)
                    {
                        DesertBiome.Cluster cluster = clusters[index3];
                        if ((double)Math.Abs((float)(cluster[0].Position.X - vector2_3.X)) <= 10.0 && (double)Math.Abs((float)(cluster[0].Position.Y - vector2_3.Y)) <= 10.0)
                        {
                            float num7 = 0.0f;
                            foreach (DesertBiome.Hub hub in (List <DesertBiome.Hub>)cluster)
                            {
                                num7 += 1f / Vector2.DistanceSquared(hub.Position, vector2_3);
                            }
                            if ((double)num7 > (double)num3)
                            {
                                if ((double)num3 > (double)num5)
                                {
                                    num5 = num3;
                                }
                                num3 = num7;
                                num4 = index3;
                            }
                            else if ((double)num7 > (double)num5)
                            {
                                num5 = num7;
                            }
                        }
                    }
                    float num8 = num3 + num5;
                    Tile  tile = GenBase._tiles[x, y];
                    bool  flag = (double)num6 >= 0.800000011920929;
                    if ((double)num8 > 3.5)
                    {
                        tile.ClearEverything();
                        tile.wall   = (byte)187;
                        tile.liquid = (byte)0;
                        if (num4 % 15 == 2)
                        {
                            tile.ResetToType((ushort)404);
                            tile.wall = (byte)187;
                            tile.active(true);
                        }
                        Tile.SmoothSlope(x, y, true);
                    }
                    else if ((double)num8 > 1.79999995231628)
                    {
                        tile.wall = (byte)187;
                        if (!flag || tile.active())
                        {
                            tile.ResetToType((ushort)396);
                            tile.wall = (byte)187;
                            tile.active(true);
                            Tile.SmoothSlope(x, y, true);
                        }
                        tile.liquid = (byte)0;
                    }
                    else if ((double)num8 > 0.699999988079071 || !flag)
                    {
                        if (!flag || tile.active())
                        {
                            tile.ResetToType((ushort)397);
                            tile.active(true);
                            Tile.SmoothSlope(x, y, true);
                        }
                        tile.liquid = (byte)0;
                        tile.wall   = (byte)216;
                    }
                    else if ((double)num8 > 0.25 && (double)GenBase._random.NextFloat() < ((double)num8 - 0.25) / 0.449999988079071)
                    {
                        if (tile.active())
                        {
                            tile.ResetToType((ushort)397);
                            tile.active(true);
                            Tile.SmoothSlope(x, y, true);
                            tile.wall = (byte)216;
                        }
                        tile.liquid = (byte)0;
                        tile.wall   = (byte)187;
                    }
                }
            }
        }
コード例 #11
0
        // Token: 0x06000FC8 RID: 4040 RVA: 0x003FA8D0 File Offset: 0x003F8AD0
        private void PlaceSand(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int   num  = (int)(scale.X * (float)clusters.Width);
            int   num2 = (int)(scale.Y * (float)clusters.Height);
            int   num3 = 5;
            int   num4 = start.Y + (num2 >> 1);
            float num5 = 0f;

            short[] array = new short[num + num3 * 2];
            for (int i = -num3; i < num + num3; i++)
            {
                for (int j = 150; j < num4; j++)
                {
                    if (WorldGen.SolidOrSlopedTile(i + start.X, j))
                    {
                        num5           += (float)(j - 1);
                        array[i + num3] = (short)(j - 1);
                        break;
                    }
                }
            }
            float num6 = num5 / (float)(num + num3 * 2);
            int   num7 = 0;

            for (int k = -num3; k < num + num3; k++)
            {
                float num8 = Math.Abs((float)(k + num3) / (float)(num + num3 * 2)) * 2f - 1f;
                num8 = MathHelper.Clamp(num8, -1f, 1f);
                if (k % 3 == 0)
                {
                    num7 = Utils.Clamp <int>(num7 + GenBase._random.Next(-1, 2), -10, 10);
                }
                float num9  = (float)Math.Sqrt((double)(1f - num8 * num8 * num8 * num8));
                int   num10 = num4 - (int)(num9 * ((float)num4 - num6)) + num7;
                int   num11 = num4 - (int)(((float)num4 - num6) * (num9 - 0.15f / (float)Math.Sqrt(Math.Max(0.01, (double)Math.Abs(8f * num8) - 0.1)) + 0.25f));
                num11 = Math.Min(num4, num11);
                if (Math.Abs(num8) < 0.8f)
                {
                    float num12 = Utils.SmoothStep(0.5f, 0.8f, Math.Abs(num8));
                    num12 = num12 * num12 * num12;
                    int num13 = 10 + (int)(num6 - num12 * 20f) + num7;
                    num13 = Math.Min(num13, num10);
                    int num14 = 50;
                    int num15 = num14;
                    while ((float)num15 < num6)
                    {
                        int num16 = k + start.X;
                        if (GenBase._tiles[num16, num15].active() && (GenBase._tiles[num16, num15].type == 189 || GenBase._tiles[num16, num15].type == 196))
                        {
                            num14 = num15 + 5;
                        }
                        num15++;
                    }
                    for (int l = num14; l < num13; l++)
                    {
                        int num17 = k + start.X;
                        int num18 = l;
                        GenBase._tiles[num17, num18].active(false);
                        GenBase._tiles[num17, num18].wall = 0;
                    }
                    array[k + num3] = (short)num13;
                }
                for (int m = num4 - 1; m >= num10; m--)
                {
                    int  num19 = k + start.X;
                    int  num20 = m;
                    Tile tile  = GenBase._tiles[num19, num20];
                    tile.liquid = 0;
                    Tile testTile  = GenBase._tiles[num19, num20 + 1];
                    Tile testTile2 = GenBase._tiles[num19, num20 + 2];
                    tile.type = (ushort)((WorldGen.SolidTile(testTile) && WorldGen.SolidTile(testTile2)) ? 53 : 397);
                    if (m > num10 + 5)
                    {
                        tile.wall = 187;
                    }
                    tile.active(true);
                    if (tile.wall != 187)
                    {
                        tile.wall = 0;
                    }
                    if (m < num11)
                    {
                        if (m > num10 + 5)
                        {
                            tile.wall = 187;
                        }
                        tile.active(false);
                    }
                    WorldGen.SquareWallFrame(num19, num20, true);
                }
            }
        }
コード例 #12
0
        // Token: 0x06000FC9 RID: 4041 RVA: 0x003FAC60 File Offset: 0x003F8E60
        private void PlaceClusters(DesertBiome.ClusterGroup clusters, Point start, Vector2 scale)
        {
            int     num    = (int)(scale.X * (float)clusters.Width);
            int     num2   = (int)(scale.Y * (float)clusters.Height);
            Vector2 value  = new Vector2((float)num, (float)num2);
            Vector2 value2 = new Vector2((float)clusters.Width, (float)clusters.Height);

            for (int i = -20; i < num + 20; i++)
            {
                for (int j = -20; j < num2 + 20; j++)
                {
                    float   num3   = 0f;
                    int     num4   = -1;
                    float   num5   = 0f;
                    int     num6   = i + start.X;
                    int     num7   = j + start.Y;
                    Vector2 vector = new Vector2((float)i, (float)j) / value * value2;
                    float   num8   = (new Vector2((float)i, (float)j) / value * 2f - Vector2.One).Length();
                    for (int k = 0; k < clusters.Count; k++)
                    {
                        DesertBiome.Cluster cluster = clusters[k];
                        if (Math.Abs(cluster[0].Position.X - vector.X) <= 10f && Math.Abs(cluster[0].Position.Y - vector.Y) <= 10f)
                        {
                            float num9 = 0f;
                            foreach (DesertBiome.Hub current in cluster)
                            {
                                num9 += 1f / Vector2.DistanceSquared(current.Position, vector);
                            }
                            if (num9 > num3)
                            {
                                if (num3 > num5)
                                {
                                    num5 = num3;
                                }
                                num3 = num9;
                                num4 = k;
                            }
                            else if (num9 > num5)
                            {
                                num5 = num9;
                            }
                        }
                    }
                    float num10 = num3 + num5;
                    Tile  tile  = GenBase._tiles[num6, num7];
                    bool  flag  = num8 >= 0.8f;
                    if (num10 > 3.5f)
                    {
                        tile.ClearEverything();
                        tile.wall   = 187;
                        tile.liquid = 0;
                        if (num4 % 15 == 2)
                        {
                            tile.ResetToType(404);
                            tile.wall = 187;
                            tile.active(true);
                        }
                        Tile.SmoothSlope(num6, num7, true);
                    }
                    else if (num10 > 1.8f)
                    {
                        tile.wall = 187;
                        if (!flag || tile.active())
                        {
                            tile.ResetToType(396);
                            tile.wall = 187;
                            tile.active(true);
                            Tile.SmoothSlope(num6, num7, true);
                        }
                        tile.liquid = 0;
                    }
                    else if (num10 > 0.7f || !flag)
                    {
                        if (!flag || tile.active())
                        {
                            tile.ResetToType(397);
                            tile.active(true);
                            Tile.SmoothSlope(num6, num7, true);
                        }
                        tile.liquid = 0;
                        tile.wall   = 216;
                    }
                    else if (num10 > 0.25f)
                    {
                        float num11 = (num10 - 0.25f) / 0.45f;
                        if (GenBase._random.NextFloat() < num11)
                        {
                            if (tile.active())
                            {
                                tile.ResetToType(397);
                                tile.active(true);
                                Tile.SmoothSlope(num6, num7, true);
                                tile.wall = 216;
                            }
                            tile.liquid = 0;
                            tile.wall   = 187;
                        }
                    }
                }
            }
        }