コード例 #1
0
        private void CleanupTiles(Point tileOrigin, Rectangle magmaMapArea)
        {
            ushort wall = 180;

            if (WorldGen.drunkWorldGen)
            {
                wall = 178;
            }
            List <Point16> list = new List <Point16>();

            for (int i = magmaMapArea.Left; i < magmaMapArea.Right; i++)
            {
                for (int j = magmaMapArea.Top; j < magmaMapArea.Bottom; j++)
                {
                    if (!_sourceMagmaMap[i, j].IsActive)
                    {
                        continue;
                    }
                    int num  = 0;
                    int num2 = i + tileOrigin.X;
                    int num3 = j + tileOrigin.Y;
                    if (!WorldGen.SolidTile(num2, num3))
                    {
                        continue;
                    }
                    for (int k = -1; k <= 1; k++)
                    {
                        for (int l = -1; l <= 1; l++)
                        {
                            if (WorldGen.SolidTile(num2 + k, num3 + l))
                            {
                                num++;
                            }
                        }
                    }
                    if (num < 3)
                    {
                        list.Add(new Point16(num2, num3));
                    }
                }
            }
            foreach (Point16 item in list)
            {
                int x = item.X;
                int y = item.Y;
                WorldUtils.ClearTile(x, y, frameNeighbors: true);
                GenBase._tiles[x, y].wall = wall;
            }
            list.Clear();
        }
コード例 #2
0
        private void CleanupTiles(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea)
        {
            ushort num1 = 180;

            if (WorldGen.drunkWorldGen)
            {
                num1 = (ushort)178;
            }
            List <Point16> point16List = new List <Point16>();

            for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left)
            {
                for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top)
                {
                    if (this._sourceMagmaMap[left, top].IsActive)
                    {
                        int num2 = 0;
                        int num3 = left + tileOrigin.X;
                        int num4 = top + tileOrigin.Y;
                        if (WorldGen.SolidTile(num3, num4, false))
                        {
                            for (int index1 = -1; index1 <= 1; ++index1)
                            {
                                for (int index2 = -1; index2 <= 1; ++index2)
                                {
                                    if (WorldGen.SolidTile(num3 + index1, num4 + index2, false))
                                    {
                                        ++num2;
                                    }
                                }
                            }
                            if (num2 < 3)
                            {
                                point16List.Add(new Point16(num3, num4));
                            }
                        }
                    }
                }
            }
            foreach (Point16 point16 in point16List)
            {
                int x = (int)point16.X;
                int y = (int)point16.Y;
                WorldUtils.ClearTile(x, y, true);
                GenBase._tiles[x, y].wall = num1;
            }
            point16List.Clear();
        }
コード例 #3
0
        private void PlaceGranite(Point tileOrigin, Rectangle magmaMapArea)
        {
            bool   flag = ShouldUseLava(tileOrigin);
            ushort type = 368;
            ushort wall = 180;

            if (WorldGen.drunkWorldGen)
            {
                type = 367;
                wall = 178;
            }
            for (int i = magmaMapArea.Left; i < magmaMapArea.Right; i++)
            {
                for (int j = magmaMapArea.Top; j < magmaMapArea.Bottom; j++)
                {
                    Magma magma = _sourceMagmaMap[i, j];
                    if (!magma.IsActive)
                    {
                        continue;
                    }
                    Tile  tile = GenBase._tiles[tileOrigin.X + i, tileOrigin.Y + j];
                    float num  = (float)Math.Sin((float)(tileOrigin.Y + j) * 0.4f) * 0.7f + 1.2f;
                    float num2 = 0.2f + 0.5f / (float)Math.Sqrt(Math.Max(0f, magma.Pressure - magma.Resistance));
                    if (Math.Max(1f - Math.Max(0f, num * num2), magma.Pressure / 15f) > 0.35f + (WorldGen.SolidTile(tileOrigin.X + i, tileOrigin.Y + j) ? 0f : 0.5f))
                    {
                        if (TileID.Sets.Ore[tile.type])
                        {
                            tile.ResetToType(tile.type);
                        }
                        else
                        {
                            tile.ResetToType(type);
                        }
                        tile.wall = wall;
                    }
                    else if (magma.Resistance < 0.01f)
                    {
                        WorldUtils.ClearTile(tileOrigin.X + i, tileOrigin.Y + j);
                        tile.wall = wall;
                    }
                    if (tile.liquid > 0 && flag)
                    {
                        tile.liquidType(1);
                    }
                }
            }
        }
コード例 #4
0
        private void PlaceGranite(Point tileOrigin, Microsoft.Xna.Framework.Rectangle magmaMapArea)
        {
            bool   flag = this.ShouldUseLava(tileOrigin);
            ushort type = 368;
            ushort num  = 180;

            if (WorldGen.drunkWorldGen)
            {
                type = (ushort)367;
                num  = (ushort)178;
            }
            for (int left = magmaMapArea.Left; left < magmaMapArea.Right; ++left)
            {
                for (int top = magmaMapArea.Top; top < magmaMapArea.Bottom; ++top)
                {
                    GraniteBiome.Magma sourceMagma = this._sourceMagmaMap[left, top];
                    if (sourceMagma.IsActive)
                    {
                        Tile tile = GenBase._tiles[tileOrigin.X + left, tileOrigin.Y + top];
                        if ((double)Math.Max(1f - Math.Max(0.0f, (float)(Math.Sin((double)(tileOrigin.Y + top) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float)(0.200000002980232 + 0.5 / Math.Sqrt((double)Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(tileOrigin.X + left, tileOrigin.Y + top, false) ? 0.0 : 0.5))
                        {
                            if (TileID.Sets.Ore[(int)tile.type])
                            {
                                tile.ResetToType(tile.type);
                            }
                            else
                            {
                                tile.ResetToType(type);
                            }
                            tile.wall = num;
                        }
                        else if ((double)sourceMagma.Resistance < 0.00999999977648258)
                        {
                            WorldUtils.ClearTile(tileOrigin.X + left, tileOrigin.Y + top, false);
                            tile.wall = num;
                        }
                        if (tile.liquid > (byte)0 & flag)
                        {
                            tile.liquidType(1);
                        }
                    }
                }
            }
        }
コード例 #5
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, new ushort[4]
            {
                WorldGen.goldBar == 19 ? (ushort)8 : (ushort)169,
                WorldGen.silverBar == 21 ? (ushort)9 : (ushort)168,
                WorldGen.ironBar == 22 ? (ushort)6 : (ushort)167,
                WorldGen.copperBar == 20 ? (ushort)7 : (ushort)166
            });
            double num1 = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain(num1 > 0.0 ? (GenSearch) new Searches.Right(40) : (GenSearch) new Searches.Left(40), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> count1    = new Ref <int>(0);
            Ref <int> count2    = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num1, 1f)).Output(shapeData), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count2)));
            if (count2.Value < count1.Value / 2)
            {
                return(false);
            }
            Microsoft.Xna.Framework.Rectangle area = new Microsoft.Xna.Framework.Rectangle(origin.X - 15, origin.Y - 10, 30, 20);
            if (!structures.CanPlace(area, 0))
            {
                return(false);
            }
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData), (GenAction) new Actions.SetTile(type, true, true));
            WorldUtils.Gen(new Point(origin.X - (int)(num1 * -5.0), origin.Y - 5), (GenShape) new Shapes.Circle(5), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Actions.ClearTile(true)));
            Point result1;
            bool  flag = ((true ? 1 : 0) & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? 3 : -3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result1) ? 1 : 0)) != 0;
            int   num2 = GenBase._random.Next(4) == 0 ? 3 : 7;
            Point result2;

            if (((flag ? 1 : 0) & (WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num2 : num2), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0)) == 0)
            {
                return(false);
            }
            --result1.Y;
            --result2.Y;
            Tile tile1 = GenBase._tiles[result1.X, result1.Y + 1];

            tile1.slope((byte)0);
            tile1.halfBrick(false);
            for (int index = -1; index <= 1; ++index)
            {
                WorldUtils.ClearTile(result2.X + index, result2.Y, false);
                Tile tile2 = GenBase._tiles[result2.X + index, result2.Y + 1];
                if (!WorldGen.SolidOrSlopedTile(tile2))
                {
                    tile2.ResetToType((ushort)1);
                    tile2.active(true);
                }
                tile2.slope((byte)0);
                tile2.halfBrick(false);
                WorldUtils.TileFrame(result2.X + index, result2.Y + 1, true);
            }
            WorldGen.PlaceTile(result1.X, result1.Y, 141, false, false, -1, 0);
            WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true, -1, 0);
            WorldUtils.WireLine(result1, result2);
            structures.AddStructure(area, 5);
            return(true);
        }
コード例 #6
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[(int)origin.X, (int)origin.Y].active())
            {
                return(false);
            }
            int length1 = GraniteBiome._sourceMagmaMap.GetLength(0);
            int length2 = GraniteBiome._sourceMagmaMap.GetLength(1);
            int index1  = length1 / 2;
            int index2  = length2 / 2;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Point& local1 = @origin;
            // ISSUE: explicit reference operation
            int num1 = (^ local1).X - index1;

            // ISSUE: explicit reference operation
            (^ local1).X = (__Null)num1;
            // ISSUE: explicit reference operation
            // ISSUE: variable of a reference type
            Point& local2 = @origin;
            // ISSUE: explicit reference operation
            int num2 = (^ local2).Y - index2;

            // ISSUE: explicit reference operation
            (^ local2).Y = (__Null)num2;
            for (int index3 = 0; index3 < length1; ++index3)
            {
                for (int index4 = 0; index4 < length2; ++index4)
                {
                    int i = index3 + origin.X;
                    int j = index4 + origin.Y;
                    GraniteBiome._sourceMagmaMap[index3, index4] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f);
                    GraniteBiome._targetMagmaMap[index3, index4] = GraniteBiome._sourceMagmaMap[index3, index4];
                }
            }
            int max1 = index1;
            int min1 = index1;
            int max2 = index2;
            int min2 = index2;

            for (int index3 = 0; index3 < 300; ++index3)
            {
                for (int index4 = max1; index4 <= min1; ++index4)
                {
                    for (int index5 = max2; index5 <= min2; ++index5)
                    {
                        GraniteBiome.Magma sourceMagma1 = GraniteBiome._sourceMagmaMap[index4, index5];
                        if (sourceMagma1.IsActive)
                        {
                            float   num3      = 0.0f;
                            Vector2 vector2_1 = Vector2.get_Zero();
                            for (int index6 = -1; index6 <= 1; ++index6)
                            {
                                for (int index7 = -1; index7 <= 1; ++index7)
                                {
                                    if (index6 != 0 || index7 != 0)
                                    {
                                        Vector2 vector2_2;
                                        // ISSUE: explicit reference operation
                                        ((Vector2)@vector2_2).\u002Ector((float)index6, (float)index7);
                                        // ISSUE: explicit reference operation
                                        ((Vector2)@vector2_2).Normalize();
                                        GraniteBiome.Magma sourceMagma2 = GraniteBiome._sourceMagmaMap[index4 + index6, index5 + index7];
                                        if ((double)sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive)
                                        {
                                            if (index6 == -1)
                                            {
                                                max1 = Utils.Clamp <int>(index4 + index6, 1, max1);
                                            }
                                            else
                                            {
                                                min1 = Utils.Clamp <int>(index4 + index6, min1, length1 - 2);
                                            }
                                            if (index7 == -1)
                                            {
                                                max2 = Utils.Clamp <int>(index5 + index7, 1, max2);
                                            }
                                            else
                                            {
                                                min2 = Utils.Clamp <int>(index5 + index7, min2, length2 - 2);
                                            }
                                            GraniteBiome._targetMagmaMap[index4 + index6, index5 + index7] = sourceMagma2.ToFlow();
                                        }
                                        float pressure = sourceMagma2.Pressure;
                                        num3     += pressure;
                                        vector2_1 = Vector2.op_Addition(vector2_1, Vector2.op_Multiply(pressure, vector2_2));
                                    }
                                }
                            }
                            float num4 = num3 / 8f;
                            if ((double)num4 > (double)sourceMagma1.Resistance)
                            {
                                // ISSUE: explicit reference operation
                                float num5     = ((Vector2)@vector2_1).Length() / 8f;
                                float pressure = Math.Max(0.0f, (float)((double)Math.Max(num4 - num5 - sourceMagma1.Pressure, 0.0f) + (double)num5 + (double)sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance);
                                GraniteBiome._targetMagmaMap[index4, index5] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f));
                            }
                        }
                    }
                }
                if (index3 < 2)
                {
                    GraniteBiome._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f, 0.0f);
                }
                Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap);
            }
            bool flag1 = origin.Y + index2 > WorldGen.lavaLine - 30;
            bool flag2 = false;

            for (int index3 = -50; index3 < 50 && !flag2; ++index3)
            {
                for (int index4 = -50; index4 < 50 && !flag2; ++index4)
                {
                    if (GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].active())
                    {
                        switch (GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].type)
                        {
                        case 147:
                        case 161:
                        case 162:
                        case 163:
                        case 200:
                            flag1 = false;
                            flag2 = true;
                            continue;

                        default:
                            continue;
                        }
                    }
                }
            }
            for (int index3 = max1; index3 <= min1; ++index3)
            {
                for (int index4 = max2; index4 <= min2; ++index4)
                {
                    GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4];
                    if (sourceMagma.IsActive)
                    {
                        Tile tile = GenBase._tiles[origin.X + index3, origin.Y + index4];
                        if ((double)Math.Max(1f - Math.Max(0.0f, (float)(Math.Sin((double)(origin.Y + index4) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float)(0.200000002980232 + 0.5 / Math.Sqrt((double)Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(origin.X + index3, origin.Y + index4) ? 0.0 : 0.5))
                        {
                            if (TileID.Sets.Ore[(int)tile.type])
                            {
                                tile.ResetToType(tile.type);
                            }
                            else
                            {
                                tile.ResetToType((ushort)368);
                            }
                            tile.wall = (byte)180;
                        }
                        else if ((double)sourceMagma.Resistance < 0.00999999977648258)
                        {
                            WorldUtils.ClearTile(origin.X + index3, origin.Y + index4, false);
                            tile.wall = (byte)180;
                        }
                        if ((int)tile.liquid > 0 && flag1)
                        {
                            tile.liquidType(1);
                        }
                    }
                }
            }
            List <Point16> point16List = new List <Point16>();

            for (int index3 = max1; index3 <= min1; ++index3)
            {
                for (int index4 = max2; index4 <= min2; ++index4)
                {
                    if (GraniteBiome._sourceMagmaMap[index3, index4].IsActive)
                    {
                        int num3 = 0;
                        int num4 = index3 + origin.X;
                        int num5 = index4 + origin.Y;
                        if (WorldGen.SolidTile(num4, num5))
                        {
                            for (int index5 = -1; index5 <= 1; ++index5)
                            {
                                for (int index6 = -1; index6 <= 1; ++index6)
                                {
                                    if (WorldGen.SolidTile(num4 + index5, num5 + index6))
                                    {
                                        ++num3;
                                    }
                                }
                            }
                            if (num3 < 3)
                            {
                                point16List.Add(new Point16(num4, num5));
                            }
                        }
                    }
                }
            }
            foreach (Point16 point16 in point16List)
            {
                int x = (int)point16.X;
                int y = (int)point16.Y;
                WorldUtils.ClearTile(x, y, true);
                GenBase._tiles[x, y].wall = (byte)180;
            }
            point16List.Clear();
            for (int index3 = max1; index3 <= min1; ++index3)
            {
                for (int index4 = max2; index4 <= min2; ++index4)
                {
                    GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4];
                    int index5 = index3 + origin.X;
                    int index6 = index4 + origin.Y;
                    if (sourceMagma.IsActive)
                    {
                        WorldUtils.TileFrame(index5, index6, false);
                        WorldGen.SquareWallFrame(index5, index6, true);
                        if (GenBase._random.Next(8) == 0 && GenBase._tiles[index5, index6].active())
                        {
                            if (!GenBase._tiles[index5, index6 + 1].active())
                            {
                                WorldGen.PlaceTight(index5, index6 + 1, (ushort)165, false);
                            }
                            if (!GenBase._tiles[index5, index6 - 1].active())
                            {
                                WorldGen.PlaceTight(index5, index6 - 1, (ushort)165, false);
                            }
                        }
                        if (GenBase._random.Next(2) == 0)
                        {
                            Tile.SmoothSlope(index5, index6, true);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #7
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active())
            {
                return(false);
            }
            int length  = GraniteBiome._sourceMagmaMap.GetLength(0);
            int length2 = GraniteBiome._sourceMagmaMap.GetLength(1);
            int num     = length / 2;
            int num2    = length2 / 2;

            origin.X -= num;
            origin.Y -= num2;
            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length2; j++)
                {
                    int i2 = i + origin.X;
                    int j2 = j + origin.Y;
                    GraniteBiome._sourceMagmaMap[i, j] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i2, j2) ? 4f : 1f);
                    GraniteBiome._targetMagmaMap[i, j] = GraniteBiome._sourceMagmaMap[i, j];
                }
            }
            int num3 = num;
            int num4 = num;
            int num5 = num2;
            int num6 = num2;

            for (int k = 0; k < 300; k++)
            {
                for (int l = num3; l <= num4; l++)
                {
                    for (int m = num5; m <= num6; m++)
                    {
                        GraniteBiome.Magma magma = GraniteBiome._sourceMagmaMap[l, m];
                        if (magma.IsActive)
                        {
                            float   num7  = 0f;
                            Vector2 value = Vector2.Zero;
                            for (int n = -1; n <= 1; n++)
                            {
                                for (int num8 = -1; num8 <= 1; num8++)
                                {
                                    if (n != 0 || num8 != 0)
                                    {
                                        Vector2 value2 = new Vector2((float)n, (float)num8);
                                        value2.Normalize();
                                        GraniteBiome.Magma magma2 = GraniteBiome._sourceMagmaMap[l + n, m + num8];
                                        if (magma.Pressure > 0.01f && !magma2.IsActive)
                                        {
                                            if (n == -1)
                                            {
                                                num3 = Utils.Clamp <int>(l + n, 1, num3);
                                            }
                                            else
                                            {
                                                num4 = Utils.Clamp <int>(l + n, num4, length - 2);
                                            }
                                            if (num8 == -1)
                                            {
                                                num5 = Utils.Clamp <int>(m + num8, 1, num5);
                                            }
                                            else
                                            {
                                                num6 = Utils.Clamp <int>(m + num8, num6, length2 - 2);
                                            }
                                            GraniteBiome._targetMagmaMap[l + n, m + num8] = magma2.ToFlow();
                                        }
                                        float pressure = magma2.Pressure;
                                        num7  += pressure;
                                        value += pressure * value2;
                                    }
                                }
                            }
                            num7 /= 8f;
                            if (num7 > magma.Resistance)
                            {
                                float num9  = value.Length() / 8f;
                                float num10 = Math.Max(num7 - num9 - magma.Pressure, 0f) + num9 + magma.Pressure * 0.875f - magma.Resistance;
                                num10 = Math.Max(0f, num10);
                                GraniteBiome._targetMagmaMap[l, m] = GraniteBiome.Magma.CreateFlow(num10, Math.Max(0f, magma.Resistance - num10 * 0.02f));
                            }
                        }
                    }
                }
                if (k < 2)
                {
                    GraniteBiome._targetMagmaMap[num, num2] = GraniteBiome.Magma.CreateFlow(25f, 0f);
                }
                Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap);
            }
            bool flag  = origin.Y + num2 > WorldGen.lavaLine - 30;
            bool flag2 = false;
            int  num11 = -50;

            while (num11 < 50 && !flag2)
            {
                int num12 = -50;
                while (num12 < 50 && !flag2)
                {
                    if (GenBase._tiles[origin.X + num + num11, origin.Y + num2 + num12].active())
                    {
                        ushort type = GenBase._tiles[origin.X + num + num11, origin.Y + num2 + num12].type;
                        if (type != 147)
                        {
                            switch (type)
                            {
                            case 161:
                            case 162:
                            case 163:
                                break;

                            default:
                                if (type != 200)
                                {
                                    goto IL_400;
                                }
                                break;
                            }
                        }
                        flag  = false;
                        flag2 = true;
                    }
IL_400:
                    num12++;
                }
                num11++;
            }
            for (int num13 = num3; num13 <= num4; num13++)
            {
                for (int num14 = num5; num14 <= num6; num14++)
                {
                    GraniteBiome.Magma magma3 = GraniteBiome._sourceMagmaMap[num13, num14];
                    if (magma3.IsActive)
                    {
                        Tile  tile  = GenBase._tiles[origin.X + num13, origin.Y + num14];
                        float num15 = (float)Math.Sin((double)((float)(origin.Y + num14) * 0.4f)) * 0.7f + 1.2f;
                        float num16 = 0.2f + 0.5f / (float)Math.Sqrt((double)Math.Max(0f, magma3.Pressure - magma3.Resistance));
                        float num17 = 1f - Math.Max(0f, num15 * num16);
                        num17 = Math.Max(num17, magma3.Pressure / 15f);
                        if (num17 > 0.35f + (WorldGen.SolidTile(origin.X + num13, origin.Y + num14) ? 0f : 0.5f))
                        {
                            if (TileID.Sets.Ore[(int)tile.type])
                            {
                                tile.ResetToType(tile.type);
                            }
                            else
                            {
                                tile.ResetToType(368);
                            }
                            tile.wall = 180;
                        }
                        else if (magma3.Resistance < 0.01f)
                        {
                            WorldUtils.ClearTile(origin.X + num13, origin.Y + num14, false);
                            tile.wall = 180;
                        }
                        if (tile.liquid > 0 && flag)
                        {
                            tile.liquidType(1);
                        }
                    }
                }
            }
            List <Point16> list = new List <Point16>();

            for (int num18 = num3; num18 <= num4; num18++)
            {
                for (int num19 = num5; num19 <= num6; num19++)
                {
                    GraniteBiome.Magma magma4 = GraniteBiome._sourceMagmaMap[num18, num19];
                    if (magma4.IsActive)
                    {
                        int num20 = 0;
                        int num21 = num18 + origin.X;
                        int num22 = num19 + origin.Y;
                        if (WorldGen.SolidTile(num21, num22))
                        {
                            for (int num23 = -1; num23 <= 1; num23++)
                            {
                                for (int num24 = -1; num24 <= 1; num24++)
                                {
                                    if (WorldGen.SolidTile(num21 + num23, num22 + num24))
                                    {
                                        num20++;
                                    }
                                }
                            }
                            if (num20 < 3)
                            {
                                list.Add(new Point16(num21, num22));
                            }
                        }
                    }
                }
            }
            foreach (Point16 current in list)
            {
                int x = (int)current.X;
                int y = (int)current.Y;
                WorldUtils.ClearTile(x, y, true);
                GenBase._tiles[x, y].wall = 180;
            }
            list.Clear();
            for (int num25 = num3; num25 <= num4; num25++)
            {
                for (int num26 = num5; num26 <= num6; num26++)
                {
                    GraniteBiome.Magma magma5 = GraniteBiome._sourceMagmaMap[num25, num26];
                    int num27 = num25 + origin.X;
                    int num28 = num26 + origin.Y;
                    if (magma5.IsActive)
                    {
                        WorldUtils.TileFrame(num27, num28, false);
                        WorldGen.SquareWallFrame(num27, num28, true);
                        if (GenBase._random.Next(8) == 0 && GenBase._tiles[num27, num28].active())
                        {
                            if (!GenBase._tiles[num27, num28 + 1].active())
                            {
                                WorldGen.PlaceTight(num27, num28 + 1, 165, false);
                            }
                            if (!GenBase._tiles[num27, num28 - 1].active())
                            {
                                WorldGen.PlaceTight(num27, num28 - 1, 165, false);
                            }
                        }
                        if (GenBase._random.Next(2) == 0)
                        {
                            Tile.SmoothSlope(num27, num28, true);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #8
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active())
            {
                return(false);
            }
            int length  = _sourceMagmaMap.GetLength(0);
            int length2 = _sourceMagmaMap.GetLength(1);
            int num     = length / 2;
            int num2    = length2 / 2;

            origin.X -= num;
            origin.Y -= num2;
            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < length2; j++)
                {
                    int i2 = i + origin.X;
                    int j2 = j + origin.Y;
                    _sourceMagmaMap[i, j] = Magma.CreateEmpty(WorldGen.SolidTile(i2, j2) ? 4f : 1f);
                    _targetMagmaMap[i, j] = _sourceMagmaMap[i, j];
                }
            }
            int num3 = num;
            int num4 = num;
            int num5 = num2;
            int num6 = num2;

            for (int k = 0; k < 300; k++)
            {
                for (int l = num3; l <= num4; l++)
                {
                    for (int m = num5; m <= num6; m++)
                    {
                        Magma magma = _sourceMagmaMap[l, m];
                        if (!magma.IsActive)
                        {
                            continue;
                        }
                        float   num7 = 0f;
                        Vector2 zero = Vector2.Zero;
                        for (int n = -1; n <= 1; n++)
                        {
                            for (int num8 = -1; num8 <= 1; num8++)
                            {
                                if (n == 0 && num8 == 0)
                                {
                                    continue;
                                }
                                Vector2 value = new Vector2(n, num8);
                                value.Normalize();
                                Magma magma2 = _sourceMagmaMap[l + n, m + num8];
                                if (magma.Pressure > 0.01f && !magma2.IsActive)
                                {
                                    if (n == -1)
                                    {
                                        num3 = Utils.Clamp(l + n, 1, num3);
                                    }
                                    else
                                    {
                                        num4 = Utils.Clamp(l + n, num4, length - 2);
                                    }
                                    if (num8 == -1)
                                    {
                                        num5 = Utils.Clamp(m + num8, 1, num5);
                                    }
                                    else
                                    {
                                        num6 = Utils.Clamp(m + num8, num6, length2 - 2);
                                    }
                                    _targetMagmaMap[l + n, m + num8] = magma2.ToFlow();
                                }
                                float pressure = magma2.Pressure;
                                num7 += pressure;
                                zero += pressure * value;
                            }
                        }
                        num7 /= 8f;
                        if (num7 > magma.Resistance)
                        {
                            float num9 = zero.Length() / 8f;
                            float val  = Math.Max(num7 - num9 - magma.Pressure, 0f) + num9 + magma.Pressure * 0.875f - magma.Resistance;
                            val = Math.Max(0f, val);
                            _targetMagmaMap[l, m] = Magma.CreateFlow(val, Math.Max(0f, magma.Resistance - val * 0.02f));
                        }
                    }
                }
                if (k < 2)
                {
                    _targetMagmaMap[num, num2] = Magma.CreateFlow(25f);
                }
                Utils.Swap(ref _sourceMagmaMap, ref _targetMagmaMap);
            }
            bool flag  = origin.Y + num2 > WorldGen.lavaLine - 30;
            bool flag2 = false;

            for (int num10 = -50; num10 < 50; num10++)
            {
                if (flag2)
                {
                    break;
                }
                for (int num11 = -50; num11 < 50; num11++)
                {
                    if (flag2)
                    {
                        break;
                    }
                    if (GenBase._tiles[origin.X + num + num10, origin.Y + num2 + num11].active())
                    {
                        switch (GenBase._tiles[origin.X + num + num10, origin.Y + num2 + num11].type)
                        {
                        case 147:
                        case 161:
                        case 162:
                        case 163:
                        case 200:
                            flag  = false;
                            flag2 = true;
                            break;
                        }
                    }
                }
            }
            for (int num12 = num3; num12 <= num4; num12++)
            {
                for (int num13 = num5; num13 <= num6; num13++)
                {
                    Magma magma3 = _sourceMagmaMap[num12, num13];
                    if (!magma3.IsActive)
                    {
                        continue;
                    }
                    Tile  tile  = GenBase._tiles[origin.X + num12, origin.Y + num13];
                    float num14 = (float)Math.Sin((float)(origin.Y + num13) * 0.4f) * 0.7f + 1.2f;
                    float num15 = 0.2f + 0.5f / (float)Math.Sqrt(Math.Max(0f, magma3.Pressure - magma3.Resistance));
                    float val2  = 1f - Math.Max(0f, num14 * num15);
                    val2 = Math.Max(val2, magma3.Pressure / 15f);
                    if (val2 > 0.35f + (WorldGen.SolidTile(origin.X + num12, origin.Y + num13) ? 0f : 0.5f))
                    {
                        if (TileID.Sets.Ore[tile.type])
                        {
                            tile.ResetToType(tile.type);
                        }
                        else
                        {
                            tile.ResetToType(368);
                        }
                        tile.wall = 180;
                    }
                    else if (magma3.Resistance < 0.01f)
                    {
                        WorldUtils.ClearTile(origin.X + num12, origin.Y + num13);
                        tile.wall = 180;
                    }
                    if (tile.liquid > 0 && flag)
                    {
                        tile.liquidType(1);
                    }
                }
            }
            List <Point16> list = new List <Point16>();

            for (int num16 = num3; num16 <= num4; num16++)
            {
                for (int num17 = num5; num17 <= num6; num17++)
                {
                    Magma magma4 = _sourceMagmaMap[num16, num17];
                    if (!magma4.IsActive)
                    {
                        continue;
                    }
                    int num18 = 0;
                    int num19 = num16 + origin.X;
                    int num20 = num17 + origin.Y;
                    if (!WorldGen.SolidTile(num19, num20))
                    {
                        continue;
                    }
                    for (int num21 = -1; num21 <= 1; num21++)
                    {
                        for (int num22 = -1; num22 <= 1; num22++)
                        {
                            if (WorldGen.SolidTile(num19 + num21, num20 + num22))
                            {
                                num18++;
                            }
                        }
                    }
                    if (num18 < 3)
                    {
                        list.Add(new Point16(num19, num20));
                    }
                }
            }
            foreach (Point16 item in list)
            {
                int x = item.X;
                int y = item.Y;
                WorldUtils.ClearTile(x, y, frameNeighbors: true);
                GenBase._tiles[x, y].wall = 180;
            }
            list.Clear();
            for (int num23 = num3; num23 <= num4; num23++)
            {
                for (int num24 = num5; num24 <= num6; num24++)
                {
                    Magma magma5 = _sourceMagmaMap[num23, num24];
                    int   num25  = num23 + origin.X;
                    int   num26  = num24 + origin.Y;
                    if (!magma5.IsActive)
                    {
                        continue;
                    }
                    WorldUtils.TileFrame(num25, num26);
                    WorldGen.SquareWallFrame(num25, num26);
                    if (GenBase._random.Next(8) == 0 && GenBase._tiles[num25, num26].active())
                    {
                        if (!GenBase._tiles[num25, num26 + 1].active())
                        {
                            WorldGen.PlaceTight(num25, num26 + 1, 165);
                        }
                        if (!GenBase._tiles[num25, num26 - 1].active())
                        {
                            WorldGen.PlaceTight(num25, num26 - 1, 165);
                        }
                    }
                    if (GenBase._random.Next(2) == 0)
                    {
                        Tile.SmoothSlope(num25, num26);
                    }
                }
            }
            return(true);
        }
コード例 #9
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (_tiles[origin.X, origin.Y].active())
            {
                return(false);
            }
            var length1 = _sourceMagmaMap.GetLength(0);
            var length2 = _sourceMagmaMap.GetLength(1);
            var index1  = length1 / 2;
            var index2  = length2 / 2;

            origin.X -= index1;
            origin.Y -= index2;
            for (var index3 = 0; index3 < length1; ++index3)
            {
                for (var index4 = 0; index4 < length2; ++index4)
                {
                    var i = index3 + origin.X;
                    var j = index4 + origin.Y;
                    _sourceMagmaMap[index3, index4] =
                        Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f);
                    _targetMagmaMap[index3, index4] = _sourceMagmaMap[index3, index4];
                }
            }

            var max1 = index1;
            var min1 = index1;
            var max2 = index2;
            var min2 = index2;

            for (var index3 = 0; index3 < 300; ++index3)
            {
                for (var index4 = max1; index4 <= min1; ++index4)
                {
                    for (var index5 = max2; index5 <= min2; ++index5)
                    {
                        var sourceMagma1 = _sourceMagmaMap[index4, index5];
                        if (sourceMagma1.IsActive)
                        {
                            var num1 = 0.0f;
                            var zero = Vector2.Zero;
                            for (var index6 = -1; index6 <= 1; ++index6)
                            {
                                for (var index7 = -1; index7 <= 1; ++index7)
                                {
                                    if (index6 != 0 || index7 != 0)
                                    {
                                        var vector2 = new Vector2(index6, index7);
                                        vector2.Normalize();
                                        var sourceMagma2 =
                                            _sourceMagmaMap[index4 + index6, index5 + index7];
                                        if (sourceMagma1.Pressure > 0.00999999977648258 &&
                                            !sourceMagma2.IsActive)
                                        {
                                            if (index6 == -1)
                                            {
                                                max1 = Utils.Clamp(index4 + index6, 1, max1);
                                            }
                                            else
                                            {
                                                min1 = Utils.Clamp(index4 + index6, min1, length1 - 2);
                                            }
                                            if (index7 == -1)
                                            {
                                                max2 = Utils.Clamp(index5 + index7, 1, max2);
                                            }
                                            else
                                            {
                                                min2 = Utils.Clamp(index5 + index7, min2, length2 - 2);
                                            }
                                            _targetMagmaMap[index4 + index6, index5 + index7] =
                                                sourceMagma2.ToFlow();
                                        }

                                        var pressure = sourceMagma2.Pressure;
                                        num1 += pressure;
                                        zero += pressure * vector2;
                                    }
                                }
                            }

                            var num2 = num1 / 8f;
                            if (num2 > (double)sourceMagma1.Resistance)
                            {
                                var num3     = zero.Length() / 8f;
                                var pressure = Math.Max(0.0f,
                                                        (float)(Math.Max(num2 - num3 - sourceMagma1.Pressure, 0.0f) +
                                                                (double)num3 + sourceMagma1.Pressure * 0.875) -
                                                        sourceMagma1.Resistance);
                                _targetMagmaMap[index4, index5] = Magma.CreateFlow(pressure,
                                                                                   Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f));
                            }
                        }
                    }
                }

                if (index3 < 2)
                {
                    _targetMagmaMap[index1, index2] = Magma.CreateFlow(25f, 0.0f);
                }
                Utils.Swap(ref _sourceMagmaMap, ref _targetMagmaMap);
            }

            var flag1 = origin.Y + index2 > WorldGen.lavaLine - 30;
            var flag2 = false;

            for (var index3 = -50; index3 < 50 && !flag2; ++index3)
            {
                for (var index4 = -50; index4 < 50 && !flag2; ++index4)
                {
                    if (_tiles[origin.X + index1 + index3, origin.Y + index2 + index4].active())
                    {
                        switch (_tiles[origin.X + index1 + index3, origin.Y + index2 + index4].type)
                        {
                        case 147:
                        case 161:
                        case 162:
                        case 163:
                        case 200:
                            flag1 = false;
                            flag2 = true;
                            continue;

                        default:
                            continue;
                        }
                    }
                }
            }

            for (var index3 = max1; index3 <= min1; ++index3)
            {
                for (var index4 = max2; index4 <= min2; ++index4)
                {
                    var sourceMagma = _sourceMagmaMap[index3, index4];
                    if (sourceMagma.IsActive)
                    {
                        var tile = _tiles[origin.X + index3, origin.Y + index4];
                        if (Math.Max(
                                1f - Math.Max(0.0f,
                                              (float)(Math.Sin((origin.Y + index4) * 0.400000005960464) *
                                                      0.699999988079071 + 1.20000004768372) *
                                              (float)(0.200000002980232 + 0.5 / Math.Sqrt(Math.Max(0.0f,
                                                                                                   sourceMagma.Pressure - sourceMagma.Resistance)))),
                                sourceMagma.Pressure / 15f) > 0.349999994039536 +
                            (WorldGen.SolidTile(origin.X + index3, origin.Y + index4) ? 0.0 : 0.5))
                        {
                            if (TileID.Sets.Ore[tile.type])
                            {
                                tile.ResetToType(tile.type);
                            }
                            else
                            {
                                tile.ResetToType(368);
                            }
                            tile.wall = 180;
                        }
                        else if (sourceMagma.Resistance < 0.00999999977648258)
                        {
                            WorldUtils.ClearTile(origin.X + index3, origin.Y + index4, false);
                            tile.wall = 180;
                        }

                        if (tile.liquid > 0 && flag1)
                        {
                            tile.liquidType(1);
                        }
                    }
                }
            }

            var point16List = new List <Point16>();

            for (var index3 = max1; index3 <= min1; ++index3)
            {
                for (var index4 = max2; index4 <= min2; ++index4)
                {
                    if (_sourceMagmaMap[index3, index4].IsActive)
                    {
                        var num1 = 0;
                        var num2 = index3 + origin.X;
                        var num3 = index4 + origin.Y;
                        if (WorldGen.SolidTile(num2, num3))
                        {
                            for (var index5 = -1; index5 <= 1; ++index5)
                            {
                                for (var index6 = -1; index6 <= 1; ++index6)
                                {
                                    if (WorldGen.SolidTile(num2 + index5, num3 + index6))
                                    {
                                        ++num1;
                                    }
                                }
                            }

                            if (num1 < 3)
                            {
                                point16List.Add(new Point16(num2, num3));
                            }
                        }
                    }
                }
            }

            foreach (var point16 in point16List)
            {
                var x = (int)point16.X;
                var y = (int)point16.Y;
                WorldUtils.ClearTile(x, y, true);
                _tiles[x, y].wall = 180;
            }

            point16List.Clear();
            for (var index3 = max1; index3 <= min1; ++index3)
            {
                for (var index4 = max2; index4 <= min2; ++index4)
                {
                    var sourceMagma = _sourceMagmaMap[index3, index4];
                    var index5      = index3 + origin.X;
                    var index6      = index4 + origin.Y;
                    if (sourceMagma.IsActive)
                    {
                        WorldUtils.TileFrame(index5, index6, false);
                        WorldGen.SquareWallFrame(index5, index6, true);
                        if (_random.Next(8) == 0 && _tiles[index5, index6].active())
                        {
                            if (!_tiles[index5, index6 + 1].active())
                            {
                                WorldGen.PlaceTight(index5, index6 + 1, 165, false);
                            }
                            if (!_tiles[index5, index6 - 1].active())
                            {
                                WorldGen.PlaceTight(index5, index6 - 1, 165, false);
                            }
                        }

                        if (_random.Next(2) == 0)
                        {
                            Tile.SmoothSlope(index5, index6, true);
                        }
                    }
                }
            }

            return(true);
        }
コード例 #10
0
ファイル: GraniteBiome.cs プロジェクト: woodcrafter123/place
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active())
            {
                return(false);
            }
            int length1 = GraniteBiome._sourceMagmaMap.GetLength(0);
            int length2 = GraniteBiome._sourceMagmaMap.GetLength(1);
            int index1  = length1 / 2;
            int index2  = length2 / 2;

            origin.X -= index1;
            origin.Y -= index2;
            for (int index3 = 0; index3 < length1; ++index3)
            {
                for (int index4 = 0; index4 < length2; ++index4)
                {
                    int i = index3 + origin.X;
                    int j = index4 + origin.Y;
                    GraniteBiome._sourceMagmaMap[index3, index4] = GraniteBiome.Magma.CreateEmpty(WorldGen.SolidTile(i, j) ? 4f : 1f);
                    GraniteBiome._targetMagmaMap[index3, index4] = GraniteBiome._sourceMagmaMap[index3, index4];
                }
            }
            int max1 = index1;
            int min1 = index1;
            int max2 = index2;
            int min2 = index2;

            for (int index3 = 0; index3 < 300; ++index3)
            {
                for (int index4 = max1; index4 <= min1; ++index4)
                {
                    for (int index5 = max2; index5 <= min2; ++index5)
                    {
                        GraniteBiome.Magma sourceMagma1 = GraniteBiome._sourceMagmaMap[index4, index5];
                        if (sourceMagma1.IsActive)
                        {
                            float   num1 = 0.0f;
                            Vector2 zero = Vector2.Zero;
                            for (int index6 = -1; index6 <= 1; ++index6)
                            {
                                for (int index7 = -1; index7 <= 1; ++index7)
                                {
                                    if (index6 != 0 || index7 != 0)
                                    {
                                        Vector2 vector2 = new Vector2((float)index6, (float)index7);
                                        vector2.Normalize();
                                        GraniteBiome.Magma sourceMagma2 = GraniteBiome._sourceMagmaMap[index4 + index6, index5 + index7];
                                        if ((double)sourceMagma1.Pressure > 0.00999999977648258 && !sourceMagma2.IsActive)
                                        {
                                            if (index6 == -1)
                                            {
                                                max1 = Utils.Clamp <int>(index4 + index6, 1, max1);
                                            }
                                            else
                                            {
                                                min1 = Utils.Clamp <int>(index4 + index6, min1, length1 - 2);
                                            }
                                            if (index7 == -1)
                                            {
                                                max2 = Utils.Clamp <int>(index5 + index7, 1, max2);
                                            }
                                            else
                                            {
                                                min2 = Utils.Clamp <int>(index5 + index7, min2, length2 - 2);
                                            }
                                            GraniteBiome._targetMagmaMap[index4 + index6, index5 + index7] = sourceMagma2.ToFlow();
                                        }
                                        float pressure = sourceMagma2.Pressure;
                                        num1 += pressure;
                                        zero += pressure * vector2;
                                    }
                                }
                            }
                            float num2 = num1 / 8f;
                            if ((double)num2 > (double)sourceMagma1.Resistance)
                            {
                                float num3     = zero.Length() / 8f;
                                float pressure = Math.Max(0.0f, (float)((double)Math.Max(num2 - num3 - sourceMagma1.Pressure, 0.0f) + (double)num3 + (double)sourceMagma1.Pressure * 0.875) - sourceMagma1.Resistance);
                                GraniteBiome._targetMagmaMap[index4, index5] = GraniteBiome.Magma.CreateFlow(pressure, Math.Max(0.0f, sourceMagma1.Resistance - pressure * 0.02f));
                            }
                        }
                    }
                }
                if (index3 < 2)
                {
                    GraniteBiome._targetMagmaMap[index1, index2] = GraniteBiome.Magma.CreateFlow(25f, 0.0f);
                }
                Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap);
            }
            bool flag1 = origin.Y + index2 > WorldGen.lavaLine - 30;
            bool flag2 = false;

            for (int index3 = -50; index3 < 50 && !flag2; ++index3)
            {
                for (int index4 = -50; index4 < 50 && !flag2; ++index4)
                {
                    if (GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].active())
                    {
                        ushort type = GenBase._tiles[origin.X + index1 + index3, origin.Y + index2 + index4].type;
                        if ((int)type == 147 || (uint)type - 161U <= 2U || (int)type == 200)
                        {
                            flag1 = false;
                            flag2 = true;
                        }
                    }
                }
            }
            for (int index3 = max1; index3 <= min1; ++index3)
            {
                for (int index4 = max2; index4 <= min2; ++index4)
                {
                    GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4];
                    if (sourceMagma.IsActive)
                    {
                        Tile tile = GenBase._tiles[origin.X + index3, origin.Y + index4];
                        if ((double)Math.Max(1f - Math.Max(0.0f, (float)(Math.Sin((double)(origin.Y + index4) * 0.400000005960464) * 0.699999988079071 + 1.20000004768372) * (float)(0.200000002980232 + 0.5 / Math.Sqrt((double)Math.Max(0.0f, sourceMagma.Pressure - sourceMagma.Resistance)))), sourceMagma.Pressure / 15f) > 0.349999994039536 + (WorldGen.SolidTile(origin.X + index3, origin.Y + index4) ? 0.0 : 0.5))
                        {
                            if (TileID.Sets.Ore[(int)tile.type])
                            {
                                tile.ResetToType(tile.type);
                            }
                            else
                            {
                                tile.ResetToType((ushort)368);
                            }
                            tile.wall = (byte)180;
                        }
                        else if ((double)sourceMagma.Resistance < 0.00999999977648258)
                        {
                            WorldUtils.ClearTile(origin.X + index3, origin.Y + index4, false);
                            tile.wall = (byte)180;
                        }
                        if ((int)tile.liquid > 0 & flag1)
                        {
                            tile.liquidType(1);
                        }
                    }
                }
            }
            List <Point16> point16List = new List <Point16>();

            for (int index3 = max1; index3 <= min1; ++index3)
            {
                for (int index4 = max2; index4 <= min2; ++index4)
                {
                    if (GraniteBiome._sourceMagmaMap[index3, index4].IsActive)
                    {
                        int num1 = 0;
                        int num2 = index3 + origin.X;
                        int num3 = index4 + origin.Y;
                        if (WorldGen.SolidTile(num2, num3))
                        {
                            for (int index5 = -1; index5 <= 1; ++index5)
                            {
                                for (int index6 = -1; index6 <= 1; ++index6)
                                {
                                    if (WorldGen.SolidTile(num2 + index5, num3 + index6))
                                    {
                                        ++num1;
                                    }
                                }
                            }
                            if (num1 < 3)
                            {
                                point16List.Add(new Point16(num2, num3));
                            }
                        }
                    }
                }
            }
            foreach (Point16 point16 in point16List)
            {
                int x = (int)point16.X;
                int y = (int)point16.Y;
                WorldUtils.ClearTile(x, y, true);
                GenBase._tiles[x, y].wall = (byte)180;
            }
            point16List.Clear();
            for (int index3 = max1; index3 <= min1; ++index3)
            {
                for (int index4 = max2; index4 <= min2; ++index4)
                {
                    GraniteBiome.Magma sourceMagma = GraniteBiome._sourceMagmaMap[index3, index4];
                    int index5 = index3 + origin.X;
                    int index6 = index4 + origin.Y;
                    if (sourceMagma.IsActive)
                    {
                        WorldUtils.TileFrame(index5, index6, false);
                        WorldGen.SquareWallFrame(index5, index6, true);
                        if (GenBase._random.Next(8) == 0 && GenBase._tiles[index5, index6].active())
                        {
                            if (!GenBase._tiles[index5, index6 + 1].active())
                            {
                                WorldGen.PlaceTight(index5, index6 + 1, (ushort)165, false);
                            }
                            if (!GenBase._tiles[index5, index6 - 1].active())
                            {
                                WorldGen.PlaceTight(index5, index6 - 1, (ushort)165, false);
                            }
                        }
                        if (GenBase._random.Next(2) == 0)
                        {
                            Tile.SmoothSlope(index5, index6, true);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #11
0
        // Token: 0x06000FD4 RID: 4052 RVA: 0x003FB3F4 File Offset: 0x003F95F4
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, new ushort[]
            {
                (ushort)((WorldGen.goldBar == 19) ? 8 : 169),
                (ushort)((WorldGen.silverBar == 21) ? 9 : 168),
                (ushort)((WorldGen.ironBar == 22) ? 6 : 167),
                (ushort)((WorldGen.copperBar == 20) ? 7 : 166)
            });
            double num = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain((num > 0.0) ? (GenSearch) new Searches.Right(40) : new Searches.Left(40), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> @ref      = new Ref <int>(0);
            Ref <int> ref2      = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num, 1f)).Output(shapeData), Actions.Chain(new GenAction[]
            {
                new Modifiers.Blotches(2, 0.3),
                new Actions.Scanner(@ref),
                new Modifiers.IsSolid(),
                new Actions.Scanner(ref2)
            }));
            if (ref2.Value < @ref.Value / 2)
            {
                return(false);
            }
            Rectangle area = new Rectangle(origin.X - 15, origin.Y - 10, 30, 20);

            if (!structures.CanPlace(area, 0))
            {
                return(false);
            }
            WorldUtils.Gen(origin, new ModShapes.All(shapeData), new Actions.SetTile(type, true, true));
            WorldUtils.Gen(new Point(origin.X - (int)(num * -5.0), origin.Y - 5), new Shapes.Circle(5), Actions.Chain(new GenAction[]
            {
                new Modifiers.Blotches(2, 0.3),
                new Actions.ClearTile(true)
            }));
            Point point;
            bool  arg_2B0_0 = true & WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? 3 : -3), origin.Y - 3), Searches.Chain(new Searches.Down(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point);
            int   num2 = (GenBase._random.Next(4) == 0) ? 3 : 7;
            Point point2;

            if (!(arg_2B0_0 & WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? (-num2) : num2), origin.Y - 3), Searches.Chain(new Searches.Down(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point2)))
            {
                return(false);
            }
            point.Y--;
            point2.Y--;
            Tile expr_2E7 = GenBase._tiles[point.X, point.Y + 1];

            expr_2E7.slope(0);
            expr_2E7.halfBrick(false);
            for (int i = -1; i <= 1; i++)
            {
                WorldUtils.ClearTile(point2.X + i, point2.Y, false);
                Tile tile = GenBase._tiles[point2.X + i, point2.Y + 1];
                if (!WorldGen.SolidOrSlopedTile(tile))
                {
                    tile.ResetToType(1);
                    tile.active(true);
                }
                tile.slope(0);
                tile.halfBrick(false);
                WorldUtils.TileFrame(point2.X + i, point2.Y + 1, true);
            }
            WorldGen.PlaceTile(point.X, point.Y, 141, false, false, -1, 0);
            WorldGen.PlaceTile(point2.X, point2.Y, 411, true, true, -1, 0);
            WorldUtils.WireLine(point, point2);
            structures.AddStructure(area, 5);
            return(true);
        }
コード例 #12
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active())
            {
                return(false);
            }
            int length = GraniteBiome._sourceMagmaMap.GetLength(0);
            int num    = GraniteBiome._sourceMagmaMap.GetLength(1);
            int num1   = length / 2;
            int num2   = num / 2;

            origin.X = origin.X - num1;
            origin.Y = origin.Y - num2;
            for (int i = 0; i < length; i++)
            {
                for (int j = 0; j < num; j++)
                {
                    GraniteBiome._sourceMagmaMap[i, j] = GraniteBiome.Magma.CreateEmpty((WorldGen.SolidTile(i + origin.X, j + origin.Y) ? 4f : 1f));
                    GraniteBiome._targetMagmaMap[i, j] = GraniteBiome._sourceMagmaMap[i, j];
                }
            }
            int num3 = num1;
            int num4 = num1;
            int num5 = num2;
            int num6 = num2;

            for (int k = 0; k < 300; k++)
            {
                for (int l = num3; l <= num4; l++)
                {
                    for (int m = num5; m <= num6; m++)
                    {
                        GraniteBiome.Magma magma = GraniteBiome._sourceMagmaMap[l, m];
                        if (magma.IsActive)
                        {
                            float   single = 0f;
                            Vector2 zero   = Vector2.Zero;
                            for (int n = -1; n <= 1; n++)
                            {
                                for (int o = -1; o <= 1; o++)
                                {
                                    if (n != 0 || o != 0)
                                    {
                                        Vector2 vector2 = new Vector2((float)n, (float)o);
                                        vector2.Normalize();
                                        GraniteBiome.Magma magma1 = GraniteBiome._sourceMagmaMap[l + n, m + o];
                                        if (magma.Pressure > 0.01f && !magma1.IsActive)
                                        {
                                            if (n != -1)
                                            {
                                                num4 = Utils.Clamp <int>(l + n, num4, length - 2);
                                            }
                                            else
                                            {
                                                num3 = Utils.Clamp <int>(l + n, 1, num3);
                                            }
                                            if (o != -1)
                                            {
                                                num6 = Utils.Clamp <int>(m + o, num6, num - 2);
                                            }
                                            else
                                            {
                                                num5 = Utils.Clamp <int>(m + o, 1, num5);
                                            }
                                            GraniteBiome._targetMagmaMap[l + n, m + o] = magma1.ToFlow();
                                        }
                                        float pressure = magma1.Pressure;
                                        single = single + pressure;
                                        zero   = zero + (pressure * vector2);
                                    }
                                }
                            }
                            single = single / 8f;
                            if (single > magma.Resistance)
                            {
                                float single1 = zero.Length() / 8f;
                                float single2 = Math.Max(single - single1 - magma.Pressure, 0f) + single1 + magma.Pressure * 0.875f - magma.Resistance;
                                single2 = Math.Max(0f, single2);
                                GraniteBiome._targetMagmaMap[l, m] = GraniteBiome.Magma.CreateFlow(single2, Math.Max(0f, magma.Resistance - single2 * 0.02f));
                            }
                        }
                    }
                }
                if (k < 2)
                {
                    GraniteBiome._targetMagmaMap[num1, num2] = GraniteBiome.Magma.CreateFlow(25f, 0f);
                }
                Utils.Swap <GraniteBiome.Magma[, ]>(ref GraniteBiome._sourceMagmaMap, ref GraniteBiome._targetMagmaMap);
            }
            bool y    = origin.Y + num2 > WorldGen.lavaLine - 30;
            bool flag = false;

            for (int p = -50; p < 50 && !flag; p++)
            {
                for (int q = -50; q < 50 && !flag; q++)
                {
                    if (GenBase._tiles[origin.X + num1 + p, origin.Y + num2 + q].active())
                    {
                        ushort num7 = GenBase._tiles[origin.X + num1 + p, origin.Y + num2 + q].type;
                        if (num7 != 147)
                        {
                            switch (num7)
                            {
                            case 161:
                            case 162:
                            case 163:
                            {
                                break;
                            }

                            default:
                            {
                                if (num7 != 200)
                                {
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            }
                        }
                        y    = false;
                        flag = true;
                    }
                }
            }
            for (int r = num3; r <= num4; r++)
            {
                for (int s = num5; s <= num6; s++)
                {
                    GraniteBiome.Magma magma2 = GraniteBiome._sourceMagmaMap[r, s];
                    if (magma2.IsActive)
                    {
                        Tile  tile    = GenBase._tiles[origin.X + r, origin.Y + s];
                        float single3 = (float)Math.Sin((double)((float)(origin.Y + s) * 0.4f)) * 0.7f + 1.2f;
                        float single4 = 0.2f + 0.5f / (float)Math.Sqrt((double)Math.Max(0f, magma2.Pressure - magma2.Resistance));
                        float single5 = 1f - Math.Max(0f, single3 * single4);
                        single5 = Math.Max(single5, magma2.Pressure / 15f);
                        if (single5 > 0.35f + (WorldGen.SolidTile(origin.X + r, origin.Y + s) ? 0f : 0.5f))
                        {
                            if (!TileID.Sets.Ore[tile.type])
                            {
                                tile.ResetToType(368);
                            }
                            else
                            {
                                tile.ResetToType(tile.type);
                            }
                            tile.wall = 180;
                        }
                        else if (magma2.Resistance < 0.01f)
                        {
                            WorldUtils.ClearTile(origin.X + r, origin.Y + s, false);
                            tile.wall = 180;
                        }
                        if (tile.liquid > 0 && y)
                        {
                            tile.liquidType(1);
                        }
                    }
                }
            }
            List <Point16> point16s = new List <Point16>();

            for (int t = num3; t <= num4; t++)
            {
                for (int u = num5; u <= num6; u++)
                {
                    if (GraniteBiome._sourceMagmaMap[t, u].IsActive)
                    {
                        int num8 = 0;
                        int x    = t + origin.X;
                        int y1   = u + origin.Y;
                        if (WorldGen.SolidTile(x, y1))
                        {
                            for (int v = -1; v <= 1; v++)
                            {
                                for (int w = -1; w <= 1; w++)
                                {
                                    if (WorldGen.SolidTile(x + v, y1 + w))
                                    {
                                        num8++;
                                    }
                                }
                            }
                            if (num8 < 3)
                            {
                                point16s.Add(new Point16(x, y1));
                            }
                        }
                    }
                }
            }
            foreach (Point16 point16 in point16s)
            {
                int x1 = point16.X;
                int y2 = point16.Y;
                WorldUtils.ClearTile(x1, y2, true);
                GenBase._tiles[x1, y2].wall = 180;
            }
            point16s.Clear();
            for (int x2 = num3; x2 <= num4; x2++)
            {
                for (int y3 = num5; y3 <= num6; y3++)
                {
                    GraniteBiome.Magma magma3 = GraniteBiome._sourceMagmaMap[x2, y3];
                    int x3 = x2 + origin.X;
                    int y4 = y3 + origin.Y;
                    if (magma3.IsActive)
                    {
                        WorldUtils.TileFrame(x3, y4, false);
                        WorldGen.SquareWallFrame(x3, y4, true);
                        if (GenBase._random.Next(8) == 0 && GenBase._tiles[x3, y4].active())
                        {
                            if (!GenBase._tiles[x3, y4 + 1].active())
                            {
                                WorldGen.PlaceTight(x3, y4 + 1, 165, false);
                            }
                            if (!GenBase._tiles[x3, y4 - 1].active())
                            {
                                WorldGen.PlaceTight(x3, y4 - 1, 165, false);
                            }
                        }
                        if (GenBase._random.Next(2) == 0)
                        {
                            Tile.SmoothSlope(x3, y4, true);
                        }
                    }
                }
            }
            return(true);
        }
コード例 #13
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, (ushort)((WorldGen.goldBar == 19) ? 8 : 169), (ushort)((WorldGen.silverBar == 21) ? 9 : 168), (ushort)((WorldGen.ironBar == 22) ? 6 : 167), (ushort)((WorldGen.copperBar == 20) ? 7 : 166));
            double num  = GenBase._random.NextDouble() * 2.0 - 1.0;

            if (!WorldUtils.Find(origin, Searches.Chain((num > 0.0) ? ((GenSearch) new Searches.Right(40)) : ((GenSearch) new Searches.Left(40)), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            ShapeData shapeData = new ShapeData();
            Ref <int> @ref      = new Ref <int>(0);
            Ref <int> ref2      = new Ref <int>(0);

            WorldUtils.Gen(origin, new ShapeRunner(10f, 20, new Vector2((float)num, 1f)).Output(shapeData), Actions.Chain(new Modifiers.Blotches(), new Actions.Scanner(@ref), new Modifiers.IsSolid(), new Actions.Scanner(ref2)));
            if (ref2.Value < @ref.Value / 2)
            {
                return(false);
            }
            Rectangle area = new Rectangle(origin.X - 15, origin.Y - 10, 30, 20);

            if (!structures.CanPlace(area))
            {
                return(false);
            }
            WorldUtils.Gen(origin, new ModShapes.All(shapeData), new Actions.SetTile(type, true));
            WorldUtils.Gen(new Point(origin.X - (int)(num * -5.0), origin.Y - 5), new Shapes.Circle(5), Actions.Chain(new Modifiers.Blotches(), new Actions.ClearTile(true)));
            bool  flag = true;
            Point result;

            flag &= WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? 3 : (-3)), origin.Y - 3), Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out result);
            Point result2;

            if (!(flag & WorldUtils.Find(new Point(origin.X - ((num > 0.0) ? (-3) : 3), origin.Y - 3), Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out result2)))
            {
                return(false);
            }
            result.Y--;
            result2.Y--;
            Tile tile = GenBase._tiles[result.X, result.Y + 1];

            tile.slope(0);
            tile.halfBrick(false);
            for (int i = -1; i <= 1; i++)
            {
                WorldUtils.ClearTile(result2.X + i, result2.Y);
                Tile tile2 = GenBase._tiles[result2.X + i, result2.Y + 1];
                if (!WorldGen.SolidOrSlopedTile(tile2))
                {
                    tile2.ResetToType(1);
                    tile2.active(true);
                }
                tile2.slope(0);
                tile2.halfBrick(false);
                WorldUtils.TileFrame(result2.X + i, result2.Y + 1, true);
            }
            WorldGen.PlaceTile(result.X, result.Y, 141);
            WorldGen.PlaceTile(result2.X, result2.Y, 411, true, true);
            WorldUtils.WireLine(result, result2);
            structures.AddStructure(area, 5);
            return(true);
        }