示例#1
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y, false))
            {
                return(false);
            }
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(80), (GenCondition) new Conditions.IsSolid()), out result))
            {
                return(false);
            }
            result.Y += 2;
            Ref <int> count = new Ref <int>(0);

            WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count)));
            if (count.Value < 20 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16), 0))
            {
                return(false);
            }
            WorldUtils.Gen(result, (GenShape) new Shapes.Circle(8), Actions.Chain((GenAction) new Modifiers.RadialDither(0.0f, 10f), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.SetTile((ushort)229, true, true)));
            ShapeData data = new ShapeData();

            WorldUtils.Gen(result, (GenShape) new Shapes.Circle(4, 3), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.3), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.ClearTile(true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), (GenAction) new Actions.SetLiquid(2, byte.MaxValue)));
            WorldUtils.Gen(new Point(result.X, result.Y + 1), (GenShape) new ModShapes.InnerOutline(data, true), Actions.Chain((GenAction) new Modifiers.IsEmpty(), (GenAction) new Modifiers.RectangleMask(-6, 6, 1, 3), (GenAction) new Actions.SetTile((ushort)59, true, true)));
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(result.X - 8, result.Y - 8, 16, 16), 0);
            return(true);
        }
示例#2
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (GenBase._tiles[origin.X, origin.Y].active() && WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(80), new Conditions.IsSolid()), out var result))
            {
                return(false);
            }
            result.Y += 2;
            Ref <int> @ref = new Ref <int>(0);

            WorldUtils.Gen(result, new Shapes.Circle(8), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(@ref)));
            if (@ref.Value < 20)
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(result.X - 8, result.Y - 8, 16, 16)))
            {
                return(false);
            }
            WorldUtils.Gen(result, new Shapes.Circle(8), Actions.Chain(new Modifiers.RadialDither(0f, 10f), new Modifiers.IsSolid(), new Actions.SetTile(229, setSelfFrames: true)));
            ShapeData data = new ShapeData();

            WorldUtils.Gen(result, new Shapes.Circle(4, 3), Actions.Chain(new Modifiers.Blotches(), new Modifiers.IsSolid(), new Actions.ClearTile(frameNeighbors: true), new Modifiers.RectangleMask(-6, 6, 0, 3).Output(data), new Actions.SetLiquid(2)));
            WorldUtils.Gen(new Point(result.X, result.Y + 1), new ModShapes.InnerOutline(data), Actions.Chain(new Modifiers.IsEmpty(), new Modifiers.RectangleMask(-6, 6, 1, 3), new Actions.SetTile(59, setSelfFrames: true)));
            structures.AddProtectedStructure(new Rectangle(result.X - 8, result.Y - 8, 16, 16));
            return(true);
        }
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result;
            bool  flag = WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 100).Not()), out result);

            result.Y += 100;
            ShapeData data1     = new ShapeData();
            ShapeData shapeData = new ShapeData();
            Point     point1    = new Point(origin.X, origin.Y + 20);
            Point     point2    = new Point(origin.X, origin.Y + 30);

            bool[] validTiles = new bool[TileID.Sets.GeneralPlacementTiles.Length];
            for (int index = 0; index < validTiles.Length; ++index)
            {
                validTiles[index] = TileID.Sets.GeneralPlacementTiles[index];
            }
            validTiles[21]  = false;
            validTiles[467] = false;
            float xScale = (float)(0.800000011920929 + (double)GenBase._random.NextFloat() * 0.5);

            WorldUtils.Gen(point1, (GenShape) new Shapes.Slime(20, xScale, 1f), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(true).Output(data1)));
            WorldUtils.Gen(point2, (GenShape) new Shapes.Mound(14, 14), Actions.Chain((GenAction) new Modifiers.Blotches(2, 1, 0.8), (GenAction) new Actions.SetTile((ushort)0, false, true), new Actions.SetFrames(true).Output(shapeData)));
            data1.Subtract(shapeData, point1, point2);
            WorldUtils.Gen(point1, (GenShape) new ModShapes.InnerOutline(data1, true), Actions.Chain((GenAction) new Actions.SetTile((ushort)2, false, true), (GenAction) new Actions.SetFrames(true)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Modifiers.RectangleMask(-40, 40, 0, 40), (GenAction) new Modifiers.IsEmpty(), (GenAction) new Actions.SetLiquid(0, byte.MaxValue)));
            WorldUtils.Gen(point1, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.PlaceWall((ushort)68, true), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, 1), (GenAction) new ActionVines(3, 5, 382)));
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfEntrance)
            {
                ShapeData data2 = new ShapeData();
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain((GenAction) new Modifiers.Blotches(2, 0.2), (GenAction) new Modifiers.SkipTiles(new ushort[2]
                {
                    (ushort)191,
                    (ushort)192
                }), new Actions.ClearTile(false).Output(data2), (GenAction) new Modifiers.Expand(1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
                {
                    (ushort)53
                }), new Actions.SetTile((ushort)397, false, true).Output(data2)));
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), (GenShape) new ModShapes.All(data2), (GenAction) new Actions.SetFrames(true));
            }
            if ((double)GenBase._random.NextFloat() <= (double)this._chanceOfRealSword)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, true, false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, true, false, -1, 15);
            }
            WorldUtils.Gen(point2, (GenShape) new ModShapes.All(shapeData), Actions.Chain((GenAction) new Modifiers.Offset(0, -1), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)2
            }), (GenAction) new Modifiers.Offset(0, -1), (GenAction) new ActionGrass()));
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(point1.X - (int)(20.0 * (double)xScale), point1.Y - 20, (int)(40.0 * (double)xScale), 40), 10);
            return(true);
        }
示例#4
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y, false) && GenBase._tiles[origin.X, origin.Y].wall == (ushort)3)
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(100), (GenCondition) new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain((GenSearch) new Searches.Down(5), new Conditions.IsTile(new ushort[1]
            {
                (ushort)25
            }).AreaAnd(8, 1)), out Point _))
            {
                return(false);
            }
            ShapeData data1      = new ShapeData();
            ShapeData shapeData1 = new ShapeData();
            ShapeData shapeData2 = new ShapeData();

            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(10, 12) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 5 * index + 5), new Modifiers.Blotches(3, 0.3).Output(data1)));
            }
            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(5, 7) + index), Actions.Chain((GenAction) new Modifiers.Offset(0, 2 * index + 18), new Modifiers.Blotches(3, 0.3).Output(shapeData1)));
            }
            for (int index = 0; index < 6; ++index)
            {
                WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(GenBase._random.Next(4, 6) + index / 2), Actions.Chain((GenAction) new Modifiers.Offset(0, (int)(7.5 * (double)index) - 10), new Modifiers.Blotches(3, 0.3).Output(shapeData2)));
            }
            ShapeData data2 = new ShapeData(shapeData1);

            shapeData1.Subtract(shapeData2, origin, origin);
            data2.Subtract(shapeData1, origin, origin);
            Microsoft.Xna.Framework.Rectangle bounds = ShapeData.GetBounds(origin, data1, shapeData2);
            if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data1), Actions.Chain((GenAction) new Actions.SetTile((ushort)25, true, true), (GenAction) new Actions.PlaceWall((ushort)3, true)));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), (GenAction) new Actions.SetTile((ushort)0, true, true));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData2), (GenAction) new Actions.ClearTile(true));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(shapeData1), Actions.Chain((GenAction) new Modifiers.IsTouchingAir(true), (GenAction) new Modifiers.NotTouching(false, new ushort[1]
            {
                (ushort)25
            }), (GenAction) new Actions.SetTile((ushort)23, true, true)));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data2), (GenAction) new Actions.PlaceWall((ushort)69, true));
            structures.AddProtectedStructure(bounds, 2);
            return(true);
        }
示例#5
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(100), new Conditions.IsSolid()), out origin))
            {
                return(false);
            }
            if (!WorldUtils.Find(new Point(origin.X - 4, origin.Y), Searches.Chain(new Searches.Down(5), new Conditions.IsTile(25).AreaAnd(8, 1)), out var _))
            {
                return(false);
            }
            ShapeData shapeData  = new ShapeData();
            ShapeData shapeData2 = new ShapeData();
            ShapeData shapeData3 = new ShapeData();

            for (int i = 0; i < 6; i++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(10, 12) + i), Actions.Chain(new Modifiers.Offset(0, 5 * i + 5), new Modifiers.Blotches(3).Output(shapeData)));
            }
            for (int j = 0; j < 6; j++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(5, 7) + j), Actions.Chain(new Modifiers.Offset(0, 2 * j + 18), new Modifiers.Blotches(3).Output(shapeData2)));
            }
            for (int k = 0; k < 6; k++)
            {
                WorldUtils.Gen(origin, new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2), Actions.Chain(new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), new Modifiers.Blotches(3).Output(shapeData3)));
            }
            ShapeData shapeData4 = new ShapeData(shapeData2);

            shapeData2.Subtract(shapeData3, origin, origin);
            shapeData4.Subtract(shapeData2, origin, origin);
            Rectangle bounds = ShapeData.GetBounds(origin, shapeData, shapeData3);

            if (!structures.CanPlace(bounds, ValidTiles, 2))
            {
                return(false);
            }
            WorldUtils.Gen(origin, new ModShapes.All(shapeData), Actions.Chain(new Actions.SetTile(25, setSelfFrames: true), new Actions.PlaceWall(3)));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), new Actions.SetTile(0, setSelfFrames: true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData3), new Actions.ClearTile(frameNeighbors: true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.IsTouchingAir(useDiagonals: true), new Modifiers.NotTouching(false, 25), new Actions.SetTile(23, setSelfFrames: true)));
            WorldUtils.Gen(origin, new ModShapes.All(shapeData4), new Actions.PlaceWall(69));
            structures.AddProtectedStructure(bounds, 2);
            return(true);
        }
示例#6
0
 public void Place(HouseBuilderContext context, StructureMap structures)
 {
     this.PlaceEmptyRooms();
     foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
     {
         structures.AddProtectedStructure(room, 8);
     }
     this.PlaceStairs();
     this.PlaceDoors();
     this.PlacePlatforms();
     this.PlaceSupportBeams();
     this.FillRooms();
     foreach (Microsoft.Xna.Framework.Rectangle room in this.Rooms)
     {
         this.AgeRoom(room);
     }
     this.PlaceChests();
     this.PlaceBiomeSpecificTool(context);
 }
示例#7
0
 public void Place(HouseBuilderContext context, StructureMap structures)
 {
     PlaceEmptyRooms();
     foreach (Rectangle room in Rooms)
     {
         structures.AddProtectedStructure(room, 8);
     }
     PlaceStairs();
     PlaceDoors();
     PlacePlatforms();
     PlaceSupportBeams();
     FillRooms();
     foreach (Rectangle room2 in Rooms)
     {
         AgeRoom(room2);
     }
     PlaceChests();
     PlaceBiomeSpecificTool(context);
 }
示例#8
0
 public override bool Place(Point origin, StructureMap structures)
 {
     {
         int     index1    = 0;
         int[]   numArray1 = new int[1000];
         int[]   numArray2 = new int[1000];
         Vector2 position1 = origin.ToVector2();
         int     num1      = WorldGen.genRand.Next(2, 5);
         if (WorldGen.drunkWorldGen)
         {
             num1 += WorldGen.genRand.Next(7, 10);
         }
         for (int index2 = 0; index2 < num1; ++index2)
         {
             Vector2 vector2 = position1;
             int     num2    = WorldGen.genRand.Next(2, 5);
             for (int index3 = 0; index3 < num2; ++index3)
             {
                 vector2 = CreateHiveTunnel((int)position1.X, (int)position1.Y, WorldGen.genRand);
             }
             position1         = vector2;
             numArray1[index1] = (int)position1.X;
             numArray2[index1] = (int)position1.Y;
             ++index1;
         }
         FrameOutAllHiveContents(origin, 50);
         for (int index2 = 0; index2 < index1; ++index2)
         {
             int x1  = numArray1[index2];
             int y   = numArray2[index2];
             int dir = 1;
             if (WorldGen.genRand.Next(2) == 0)
             {
                 dir = -1;
             }
             bool flag = false;
             while (WorldGen.InWorld(x1, y, 10) && BadSpotForHoneyFall(x1, y))
             {
                 x1 += dir;
                 if (Math.Abs(x1 - numArray1[index2]) > 50)
                 {
                     flag = true;
                     break;
                 }
             }
             if (!flag)
             {
                 int x2 = x1 + dir;
                 if (!SpotActuallyNotInHive(x2, y))
                 {
                     CreateBlockedHoneyCube(x2, y);
                     CreateDentForHoneyFall(x2, y, dir);
                 }
             }
         }
         CreateStandForLarva(position1);
         WorldGen.PlaceTile((int)position1.X, (int)position1.Y, 231, true, false, -1, 0);
         if (WorldGen.drunkWorldGen)
         {
             for (int index2 = 0; index2 < 1000; ++index2)
             {
                 Vector2 position2 = position1;
                 position2.X += (float)WorldGen.genRand.Next(-50, 51);
                 position2.Y += (float)WorldGen.genRand.Next(-50, 51);
                 if (WorldGen.InWorld((int)position2.X, (int)position2.Y, 0) && (double)Vector2.Distance(position1, position2) > 10.0 && (!Main.tile[(int)position2.X, (int)position2.Y].active() && Main.tile[(int)position2.X, (int)position2.Y].wall == (ushort)86))
                 {
                     CreateStandForLarva(position2);
                     WorldGen.PlaceTile((int)position2.X, (int)position2.Y, 231, true, false, -1, 0);
                     break;
                 }
             }
         }
         structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
         return(true);
     }
 }
示例#9
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();

            WorldUtils.Gen(new Point(origin.X - 25, origin.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 1).Output(dictionary));
            if (dictionary[0] + dictionary[1] < 1250)
            {
                return(false);
            }
            Point result;
            bool  flag = WorldUtils.Find(origin, Searches.Chain(new Searches.Up(1000), new Conditions.IsSolid().AreaOr(1, 50).Not()), out result);

            if (WorldUtils.Find(origin, Searches.Chain(new Searches.Up(origin.Y - result.Y), new Conditions.IsTile(53)), out var _))
            {
                return(false);
            }
            if (!flag)
            {
                return(false);
            }
            result.Y += 50;
            ShapeData shapeData  = new ShapeData();
            ShapeData shapeData2 = new ShapeData();
            Point     point      = new Point(origin.X, origin.Y + 20);
            Point     point2     = new Point(origin.X, origin.Y + 30);

            bool[] array = new bool[TileID.Sets.GeneralPlacementTiles.Length];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = TileID.Sets.GeneralPlacementTiles[i];
            }
            array[21]  = false;
            array[467] = false;
            float num = 0.8f + GenBase._random.NextFloat() * 0.5f;

            if (!structures.CanPlace(new Rectangle(point.X - (int)(20f * num), point.Y - 20, (int)(40f * num), 40), array))
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(origin.X, result.Y + 10, 1, origin.Y - result.Y - 9), array, 2))
            {
                return(false);
            }
            WorldUtils.Gen(point, new Shapes.Slime(20, num, 1f), Actions.Chain(new Modifiers.Blotches(2, 0.4), new Actions.ClearTile(frameNeighbors: true).Output(shapeData)));
            WorldUtils.Gen(point2, new Shapes.Mound(14, 14), Actions.Chain(new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0), new Actions.SetFrames(frameNeighbors: true).Output(shapeData2)));
            shapeData.Subtract(shapeData2, point, point2);
            WorldUtils.Gen(point, new ModShapes.InnerOutline(shapeData), Actions.Chain(new Actions.SetTile(2), new Actions.SetFrames(frameNeighbors: true)));
            WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid()));
            WorldUtils.Gen(point, new ModShapes.All(shapeData), Actions.Chain(new Actions.PlaceWall(68), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, 1), new ActionVines(3, 5, 382)));
            if (GenBase._random.NextFloat() <= _chanceOfEntrance)
            {
                ShapeData data = new ShapeData();
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), new Shapes.Rectangle(1, origin.Y - result.Y - 9), Actions.Chain(new Modifiers.Blotches(2, 0.2), new Modifiers.SkipTiles(191, 192), new Actions.ClearTile().Output(data), new Modifiers.Expand(1), new Modifiers.OnlyTiles(53), new Actions.SetTile(397).Output(data)));
                WorldUtils.Gen(new Point(origin.X, result.Y + 10), new ModShapes.All(data), new Actions.SetFrames(frameNeighbors: true));
            }
            if (GenBase._random.NextFloat() <= _chanceOfRealSword)
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 187, mute: true, forced: false, -1, 17);
            }
            else
            {
                WorldGen.PlaceTile(point2.X, point2.Y - 15, 186, mute: true, forced: false, -1, 15);
            }
            WorldUtils.Gen(point2, new ModShapes.All(shapeData2), Actions.Chain(new Modifiers.Offset(0, -1), new Modifiers.OnlyTiles(2), new Modifiers.Offset(0, -1), new ActionGrass()));
            structures.AddProtectedStructure(new Rectangle(point.X - (int)(20f * num), point.Y - 20, (int)(40f * num), 40), 10);
            return(true);
        }
示例#10
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Ref <int> @ref = new Ref <int>(0);
            Ref <int> ref2 = new Ref <int>(0);

            WorldUtils.Gen(origin, new Shapes.Circle(10), Actions.Chain(new Actions.Scanner(ref2), new Modifiers.IsSolid(), new Actions.Scanner(@ref)));
            if (@ref.Value < ref2.Value - 5)
            {
                return(false);
            }
            int num  = GenBase._random.Next(6, 10);
            int num2 = GenBase._random.Next(5);

            if (!structures.CanPlace(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2)))
            {
                return(false);
            }
            ushort type = (byte)(196 + WorldGen.genRand.Next(4));

            for (int i = origin.X - num; i <= origin.X + num; i++)
            {
                for (int j = origin.Y - num; j <= origin.Y + num; j++)
                {
                    if (Main.tile[i, j].active())
                    {
                        int type2 = Main.tile[i, j].type;
                        if (type2 == 53 || type2 == 396 || type2 == 397 || type2 == 404)
                        {
                            type = 187;
                        }
                        if (type2 == 161 || type2 == 147)
                        {
                            type = 40;
                        }
                        if (type2 == 60)
                        {
                            type = (byte)(204 + WorldGen.genRand.Next(4));
                        }
                        if (type2 == 367)
                        {
                            type = 178;
                        }
                        if (type2 == 368)
                        {
                            type = 180;
                        }
                    }
                }
            }
            ShapeData data = new ShapeData();

            WorldUtils.Gen(origin, new Shapes.Slime(num), Actions.Chain(new Modifiers.Blotches(num2, num2, num2, 1).Output(data), new Modifiers.Offset(0, -2), new Modifiers.OnlyTiles(53), new Actions.SetTile(397, setSelfFrames: true), new Modifiers.OnlyWalls(default(ushort)), new Actions.PlaceWall(type)));
            WorldUtils.Gen(origin, new ModShapes.All(data), Actions.Chain(new Actions.ClearTile(), new Actions.SetLiquid(0, 0), new Actions.SetFrames(frameNeighbors: true), new Modifiers.OnlyWalls(default(ushort)), new Actions.PlaceWall(type)));
            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(10), new Conditions.IsSolid()), out Point result))
            {
                return(false);
            }
            int  num3 = result.Y - 1;
            bool flag = GenBase._random.Next() % 2 == 0;

            if (GenBase._random.Next() % 10 != 0)
            {
                int num4 = GenBase._random.Next(1, 4);
                int num5 = flag ? 4 : (-(num >> 1));
                for (int k = 0; k < num4; k++)
                {
                    int num6 = GenBase._random.Next(1, 3);
                    for (int l = 0; l < num6; l++)
                    {
                        WorldGen.PlaceTile(origin.X + num5 - k, num3 - l, 332, mute: true);
                    }
                }
            }
            int num7 = (num - 3) * ((!flag) ? 1 : (-1));

            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X + num7, num3, 186);
            }
            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X, num3, 215, mute: true);
                if (GenBase._tiles[origin.X, num3].active() && GenBase._tiles[origin.X, num3].type == 215)
                {
                    GenBase._tiles[origin.X, num3].frameY         += 36;
                    GenBase._tiles[origin.X - 1, num3].frameY     += 36;
                    GenBase._tiles[origin.X + 1, num3].frameY     += 36;
                    GenBase._tiles[origin.X, num3 - 1].frameY     += 36;
                    GenBase._tiles[origin.X - 1, num3 - 1].frameY += 36;
                    GenBase._tiles[origin.X + 1, num3 - 1].frameY += 36;
                }
            }
            structures.AddProtectedStructure(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 4);
            return(true);
        }
示例#11
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y))
            {
                return(false);
            }
            if (Main.tile[origin.X, origin.Y].wall == 216 || Main.tile[origin.X, origin.Y].wall == 187)
            {
                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, setSelfFrames: 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(frameNeighbors: true)));
            Point result;
            int   num2 = 1 & (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) ? 1 : 0);
            int   num3 = ((GenBase._random.Next(4) == 0) ? 3 : 7);

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

            tile.slope(0);
            tile.halfBrick(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(active: true);
                }
                tile2.slope(0);
                tile2.halfBrick(halfBrick: false);
                WorldUtils.TileFrame(result2.X + i, result2.Y + 1, frameNeighbors: true);
            }
            WorldGen.PlaceTile(result.X, result.Y, 141);
            WorldGen.PlaceTile(result2.X, result2.Y, 411, mute: true, forced: true);
            WorldUtils.WireLine(result, result2);
            structures.AddProtectedStructure(area, 5);
            return(true);
        }
示例#12
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (WorldGen.SolidTile(origin.X, origin.Y, false) || Main.tile[origin.X, origin.Y].wall == (ushort)216 || Main.tile[origin.X, origin.Y].wall == (ushort)187)
            {
                return(false);
            }
            ushort type = Utils.SelectRandom <ushort>(GenBase._random, 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;
            int   num2 = 1 & (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);
            int   num3 = GenBase._random.Next(4) == 0 ? 3 : 7;
            Point result2;
            int   num4 = WorldUtils.Find(new Point(origin.X - (num1 > 0.0 ? -num3 : num3), origin.Y - 3), Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result2) ? 1 : 0;

            if ((num2 & num4) == 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.AddProtectedStructure(area, 5);
            return(true);
        }
示例#13
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result1;

            if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain((GenSearch) new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out result1))
            {
                return(false);
            }
            Point result2;

            if (!WorldUtils.Find(new Point(result1.X, result1.Y - 5), Searches.Chain((GenSearch) new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out result2) || result1.Y - 5 - result2.Y > 60 || (result1.Y - result2.Y < 30 || !structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 60, 60, 90), 0)))
            {
                return(false);
            }
            if (!WorldGen.drunkWorldGen || WorldGen.genRand.Next(50) > 0)
            {
                Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>();
                WorldUtils.Gen(new Point(result1.X - 25, result1.Y - 25), (GenShape) new Shapes.Rectangle(50, 50), (GenAction) new Actions.TileScanner(new ushort[4]
                {
                    (ushort)0,
                    (ushort)59,
                    (ushort)147,
                    (ushort)1
                }).Output(resultsOutput));
                int num1 = resultsOutput[(ushort)0] + resultsOutput[(ushort)1];
                int num2 = resultsOutput[(ushort)59];
                if (resultsOutput[(ushort)147] > num2 || num1 > num2 || num2 < 50)
                {
                    return(false);
                }
            }
            int    num3 = (result1.Y - result2.Y - 9) / 5;
            int    num4 = num3 * 5;
            int    num5 = 0;
            double num6 = GenBase._random.NextDouble() + 1.0;
            double num7 = GenBase._random.NextDouble() + 2.0;

            if (GenBase._random.Next(2) == 0)
            {
                num7 = -num7;
            }
            for (int index = 0; index < num3; ++index)
            {
                int num1 = (int)(Math.Sin((double)(index + 1) / 12.0 * num6 * 3.14159274101257) * num7);
                int num2 = num1 < num5 ? num1 - num5 : 0;
                WorldUtils.Gen(new Point(result1.X + num5 + num2, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(6 + Math.Abs(num1 - num5), 7), Actions.Chain((GenAction) new Actions.RemoveWall(), (GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(false)));
                WorldUtils.Gen(new Point(result1.X + num5 + num2 + 2, result1.Y - (index + 1) * 5), (GenShape) new Shapes.Rectangle(2 + Math.Abs(num1 - num5), 5), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((ushort)78, true)));
                WorldUtils.Gen(new Point(result1.X + num5 + 2, result1.Y - index * 5), (GenShape) new Shapes.Rectangle(2, 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall((ushort)78, true)));
                num5 = num1;
            }
            int num8 = 6;

            if (num7 < 0.0)
            {
                num8 = 0;
            }
            List <Point> endpoints = new List <Point>();

            for (int index = 0; index < 2; ++index)
            {
                double num1  = ((double)index + 1.0) / 3.0;
                int    num2  = num8 + (int)(Math.Sin((double)num3 * num1 / 12.0 * num6 * 3.14159274101257) * num7);
                double angle = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232;
                if (num8 == 0)
                {
                    angle -= 1.57079637050629;
                }
                WorldUtils.Gen(new Point(result1.X + num2, result1.Y - (int)((double)(num3 * 5) * num1)), (GenShape) new ShapeBranch(angle, (double)GenBase._random.Next(12, 16)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(true)));
                num8 = 6 - num8;
            }
            int num9 = (int)(Math.Sin((double)num3 / 12.0 * num6 * 3.14159274101257) * num7);

            WorldUtils.Gen(new Point(result1.X + 6 + num9, result1.Y - num4), (GenShape) new ShapeBranch(-0.685398185253143, (double)GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(true)));
            WorldUtils.Gen(new Point(result1.X + num9, result1.Y - num4), (GenShape) new ShapeBranch(-2.45619449615479, (double)GenBase._random.Next(16, 22)).OutputEndpoints(endpoints), Actions.Chain((GenAction) new Actions.SetTile((ushort)383, false, true), (GenAction) new Actions.SetFrames(true)));
            foreach (Point origin1 in endpoints)
            {
                Shapes.Circle circle = new Shapes.Circle(4);
                GenAction     action = Actions.Chain((GenAction) new Modifiers.Blotches(4, 2, 0.3), (GenAction) new Modifiers.SkipTiles(new ushort[1]
                {
                    (ushort)383
                }), (GenAction) new Modifiers.SkipWalls(new ushort[1]
                {
                    (ushort)78
                }), (GenAction) new Actions.SetTile((ushort)384, false, true), (GenAction) new Actions.SetFrames(true));
                WorldUtils.Gen(origin1, (GenShape)circle, action);
            }
            for (int index = 0; index < 4; ++index)
            {
                float angle = (float)((double)index / 3.0 * 2.0 + 0.570749998092651);
                WorldUtils.Gen(result1, (GenShape) new ShapeRoot(angle, (float)GenBase._random.Next(40, 60), 4f, 1f), (GenAction) new Actions.SetTile((ushort)383, true, true));
            }
            WorldGen.AddBuriedChest(result1.X + 3, result1.Y - 1, GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem(), false, 10, false, (ushort)0);
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(result1.X - 30, result1.Y - 30, 60, 60), 0);
            return(true);
        }
示例#14
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100)))
            {
                return(false);
            }
            if (TooCloseToImportantLocations(origin))
            {
                return(false);
            }
            Ref <int> @ref = new Ref <int>(0);
            Ref <int> ref2 = new Ref <int>(0);
            Ref <int> ref3 = new Ref <int>(0);

            WorldUtils.Gen(origin, new Shapes.Circle(15), Actions.Chain(new Modifiers.IsSolid(), new Actions.Scanner(@ref), new Modifiers.OnlyTiles(60, 59), new Actions.Scanner(ref2), new Modifiers.OnlyTiles(60), new Actions.Scanner(ref3)));
            if ((float)ref2.Value / (float)@ref.Value < 0.75f || ref3.Value < 2)
            {
                return(false);
            }
            int num = 0;

            int[]   array  = new int[1000];
            int[]   array2 = new int[1000];
            Vector2 vector = origin.ToVector2();
            int     num2   = WorldGen.genRand.Next(2, 5);

            if (WorldGen.drunkWorldGen)
            {
                num2 += WorldGen.genRand.Next(7, 10);
            }
            for (int i = 0; i < num2; i++)
            {
                Vector2 vector2 = vector;
                int     num3    = WorldGen.genRand.Next(2, 5);
                for (int j = 0; j < num3; j++)
                {
                    vector2 = CreateHiveTunnel((int)vector.X, (int)vector.Y, WorldGen.genRand);
                }
                vector      = vector2;
                array[num]  = (int)vector.X;
                array2[num] = (int)vector.Y;
                num++;
            }
            FrameOutAllHiveContents(origin, 50);
            for (int k = 0; k < num; k++)
            {
                int num4 = array[k];
                int y    = array2[k];
                int num5 = 1;
                if (WorldGen.genRand.Next(2) == 0)
                {
                    num5 = -1;
                }
                bool flag = false;
                while (WorldGen.InWorld(num4, y, 10) && BadSpotForHoneyFall(num4, y))
                {
                    num4 += num5;
                    if (Math.Abs(num4 - array[k]) > 50)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    num4 += num5;
                    if (!SpotActuallyNotInHive(num4, y))
                    {
                        CreateBlockedHoneyCube(num4, y);
                        CreateDentForHoneyFall(num4, y, num5);
                    }
                }
            }
            CreateStandForLarva(vector);
            if (WorldGen.drunkWorldGen)
            {
                for (int l = 0; l < 1000; l++)
                {
                    Vector2 vector3 = vector;
                    vector3.X += WorldGen.genRand.Next(-50, 51);
                    vector3.Y += WorldGen.genRand.Next(-50, 51);
                    if (WorldGen.InWorld((int)vector3.X, (int)vector3.Y) && Vector2.Distance(vector, vector3) > 10f && !Main.tile[(int)vector3.X, (int)vector3.Y].active() && Main.tile[(int)vector3.X, (int)vector3.Y].wall == 86)
                    {
                        CreateStandForLarva(vector3);
                        break;
                    }
                }
            }
            structures.AddProtectedStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
            return(true);
        }
示例#15
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (!WorldUtils.Find(new Point(origin.X - 3, origin.Y), Searches.Chain(new Searches.Down(200), new Conditions.IsSolid().AreaAnd(6, 1)), out var result))
            {
                return(false);
            }
            if (!WorldUtils.Find(new Point(result.X, result.Y - 5), Searches.Chain(new Searches.Up(120), new Conditions.IsSolid().AreaOr(6, 1)), out var result2) || result.Y - 5 - result2.Y > 60)
            {
                return(false);
            }
            if (result.Y - result2.Y < 30)
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(result.X - 30, result.Y - 60, 60, 90)))
            {
                return(false);
            }
            if (!WorldGen.drunkWorldGen || WorldGen.genRand.Next(50) > 0)
            {
                Dictionary <ushort, int> dictionary = new Dictionary <ushort, int>();
                WorldUtils.Gen(new Point(result.X - 25, result.Y - 25), new Shapes.Rectangle(50, 50), new Actions.TileScanner(0, 59, 147, 1).Output(dictionary));
                int num  = dictionary[0] + dictionary[1];
                int num2 = dictionary[59];
                if (dictionary[147] > num2 || num > num2 || num2 < 50)
                {
                    return(false);
                }
            }
            int    num3 = (result.Y - result2.Y - 9) / 5;
            int    num4 = num3 * 5;
            int    num5 = 0;
            double num6 = GenBase._random.NextDouble() + 1.0;
            double num7 = GenBase._random.NextDouble() + 2.0;

            if (GenBase._random.Next(2) == 0)
            {
                num7 = 0.0 - num7;
            }
            for (int i = 0; i < num3; i++)
            {
                int num8 = (int)(Math.Sin((double)(i + 1) / 12.0 * num6 * 3.1415927410125732) * num7);
                int num9 = ((num8 < num5) ? (num8 - num5) : 0);
                WorldUtils.Gen(new Point(result.X + num5 + num9, result.Y - (i + 1) * 5), new Shapes.Rectangle(6 + Math.Abs(num8 - num5), 7), Actions.Chain(new Actions.RemoveWall(), new Actions.SetTile(383), new Actions.SetFrames()));
                WorldUtils.Gen(new Point(result.X + num5 + num9 + 2, result.Y - (i + 1) * 5), new Shapes.Rectangle(2 + Math.Abs(num8 - num5), 5), Actions.Chain(new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(78)));
                WorldUtils.Gen(new Point(result.X + num5 + 2, result.Y - i * 5), new Shapes.Rectangle(2, 2), Actions.Chain(new Actions.ClearTile(frameNeighbors: true), new Actions.PlaceWall(78)));
                num5 = num8;
            }
            int num10 = 6;

            if (num7 < 0.0)
            {
                num10 = 0;
            }
            List <Point> list = new List <Point>();

            for (int j = 0; j < 2; j++)
            {
                double num11 = ((double)j + 1.0) / 3.0;
                int    num12 = num10 + (int)(Math.Sin((double)num3 * num11 / 12.0 * num6 * 3.1415927410125732) * num7);
                double num13 = GenBase._random.NextDouble() * 0.78539818525314331 - 0.78539818525314331 - 0.20000000298023224;
                if (num10 == 0)
                {
                    num13 -= 1.5707963705062866;
                }
                WorldUtils.Gen(new Point(result.X + num12, result.Y - (int)((double)(num3 * 5) * num11)), new ShapeBranch(num13, GenBase._random.Next(12, 16)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true)));
                num10 = 6 - num10;
            }
            int num14 = (int)(Math.Sin((double)num3 / 12.0 * num6 * 3.1415927410125732) * num7);

            WorldUtils.Gen(new Point(result.X + 6 + num14, result.Y - num4), new ShapeBranch(-0.68539818525314333, GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true)));
            WorldUtils.Gen(new Point(result.X + num14, result.Y - num4), new ShapeBranch(-2.4561944961547852, GenBase._random.Next(16, 22)).OutputEndpoints(list), Actions.Chain(new Actions.SetTile(383), new Actions.SetFrames(frameNeighbors: true)));
            foreach (Point item in list)
            {
                WorldUtils.Gen(item, new Shapes.Circle(4), Actions.Chain(new Modifiers.Blotches(4, 2), new Modifiers.SkipTiles(383), new Modifiers.SkipWalls(78), new Actions.SetTile(384), new Actions.SetFrames(frameNeighbors: true)));
            }
            for (int k = 0; k < 4; k++)
            {
                float angle = (float)k / 3f * 2f + 0.57075f;
                WorldUtils.Gen(result, new ShapeRoot(angle, GenBase._random.Next(40, 60)), new Actions.SetTile(383, setSelfFrames: true));
            }
            WorldGen.AddBuriedChest(result.X + 3, result.Y - 1, (GenBase._random.Next(4) != 0) ? WorldGen.GetNextJungleChestItem() : 0, notNearOtherChests: false, 10, trySlope: false, 0);
            structures.AddProtectedStructure(new Rectangle(result.X - 30, result.Y - 30, 60, 60));
            return(true);
        }
示例#16
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Ref <int> count1 = new Ref <int>(0);
            Ref <int> count2 = new Ref <int>(0);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(10), Actions.Chain((GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1)));
            if (count1.Value < count2.Value - 5)
            {
                return(false);
            }
            int radius = GenBase._random.Next(6, 10);
            int num1   = GenBase._random.Next(5);

            if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 0))
            {
                return(false);
            }
            ushort type1 = (ushort)(byte)(196 + WorldGen.genRand.Next(4));

            for (int index1 = origin.X - radius; index1 <= origin.X + radius; ++index1)
            {
                for (int index2 = origin.Y - radius; index2 <= origin.Y + radius; ++index2)
                {
                    if (Main.tile[index1, index2].active())
                    {
                        int type2 = (int)Main.tile[index1, index2].type;
                        if (type2 == 53 || type2 == 396 || (type2 == 397 || type2 == 404))
                        {
                            type1 = (ushort)187;
                        }
                        if (type2 == 161 || type2 == 147)
                        {
                            type1 = (ushort)40;
                        }
                        if (type2 == 60)
                        {
                            type1 = (ushort)(byte)(204 + WorldGen.genRand.Next(4));
                        }
                        if (type2 == 367)
                        {
                            type1 = (ushort)178;
                        }
                        if (type2 == 368)
                        {
                            type1 = (ushort)180;
                        }
                    }
                }
            }
            ShapeData data = new ShapeData();

            WorldUtils.Gen(origin, (GenShape) new Shapes.Slime(radius), Actions.Chain(new Modifiers.Blotches(num1, num1, num1, 1, 0.3).Output(data), (GenAction) new Modifiers.Offset(0, -2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)53
            }), (GenAction) new Actions.SetTile((ushort)397, true, true), (GenAction) new Modifiers.OnlyWalls(new ushort[1]), (GenAction) new Actions.PlaceWall(type1, true)));
            WorldUtils.Gen(origin, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.ClearTile(false), (GenAction) new Actions.SetLiquid(0, (byte)0), (GenAction) new Actions.SetFrames(true), (GenAction) new Modifiers.OnlyWalls(new ushort[1]), (GenAction) new Actions.PlaceWall(type1, true)));
            Point result;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(10), (GenCondition) new Conditions.IsSolid()), out result))
            {
                return(false);
            }
            int  j    = result.Y - 1;
            bool flag = GenBase._random.Next() % 2 == 0;

            if (GenBase._random.Next() % 10 != 0)
            {
                int num2 = GenBase._random.Next(1, 4);
                int num3 = flag ? 4 : -(radius >> 1);
                for (int index1 = 0; index1 < num2; ++index1)
                {
                    int num4 = GenBase._random.Next(1, 3);
                    for (int index2 = 0; index2 < num4; ++index2)
                    {
                        WorldGen.PlaceTile(origin.X + num3 - index1, j - index2, 332, true, false, -1, 0);
                    }
                }
            }
            int num5 = (radius - 3) * (flag ? -1 : 1);

            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X + num5, j, 186, false, false, -1, 0);
            }
            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X, j, 215, true, false, -1, 0);
                if (GenBase._tiles[origin.X, j].active() && GenBase._tiles[origin.X, j].type == (ushort)215)
                {
                    GenBase._tiles[origin.X, j].frameY         += (short)36;
                    GenBase._tiles[origin.X - 1, j].frameY     += (short)36;
                    GenBase._tiles[origin.X + 1, j].frameY     += (short)36;
                    GenBase._tiles[origin.X, j - 1].frameY     += (short)36;
                    GenBase._tiles[origin.X - 1, j - 1].frameY += (short)36;
                    GenBase._tiles[origin.X + 1, j - 1].frameY += (short)36;
                }
            }
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - radius, origin.Y - radius, radius * 2, radius * 2), 4);
            return(true);
        }
示例#17
0
        public override bool Place(Point origin, StructureMap structures)
        {
            if (!structures.CanPlace(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 0) || HiveBiome.TooCloseToImportantLocations(origin))
            {
                return(false);
            }
            Ref <int> count1 = new Ref <int>(0);
            Ref <int> count2 = new Ref <int>(0);
            Ref <int> count3 = new Ref <int>(0);

            WorldUtils.Gen(origin, (GenShape) new Shapes.Circle(15), Actions.Chain((GenAction) new Modifiers.IsSolid(), (GenAction) new Actions.Scanner(count1), (GenAction) new Modifiers.OnlyTiles(new ushort[2]
            {
                (ushort)60,
                (ushort)59
            }), (GenAction) new Actions.Scanner(count2), (GenAction) new Modifiers.OnlyTiles(new ushort[1]
            {
                (ushort)60
            }), (GenAction) new Actions.Scanner(count3)));
            if ((double)count2.Value / (double)count1.Value < 0.75 || count3.Value < 2)
            {
                return(false);
            }
            int index1 = 0;

            int[]   numArray1 = new int[1000];
            int[]   numArray2 = new int[1000];
            Vector2 position1 = origin.ToVector2();
            int     num1      = WorldGen.genRand.Next(2, 5);

            if (WorldGen.drunkWorldGen)
            {
                num1 += WorldGen.genRand.Next(7, 10);
            }
            for (int index2 = 0; index2 < num1; ++index2)
            {
                Vector2 vector2 = position1;
                int     num2    = WorldGen.genRand.Next(2, 5);
                for (int index3 = 0; index3 < num2; ++index3)
                {
                    vector2 = HiveBiome.CreateHiveTunnel((int)position1.X, (int)position1.Y, WorldGen.genRand);
                }
                position1         = vector2;
                numArray1[index1] = (int)position1.X;
                numArray2[index1] = (int)position1.Y;
                ++index1;
            }
            HiveBiome.FrameOutAllHiveContents(origin, 50);
            for (int index2 = 0; index2 < index1; ++index2)
            {
                int x1  = numArray1[index2];
                int y   = numArray2[index2];
                int dir = 1;
                if (WorldGen.genRand.Next(2) == 0)
                {
                    dir = -1;
                }
                bool flag = false;
                while (WorldGen.InWorld(x1, y, 10) && HiveBiome.BadSpotForHoneyFall(x1, y))
                {
                    x1 += dir;
                    if (Math.Abs(x1 - numArray1[index2]) > 50)
                    {
                        flag = true;
                        break;
                    }
                }
                if (!flag)
                {
                    int x2 = x1 + dir;
                    if (!HiveBiome.SpotActuallyNotInHive(x2, y))
                    {
                        HiveBiome.CreateBlockedHoneyCube(x2, y);
                        HiveBiome.CreateDentForHoneyFall(x2, y, dir);
                    }
                }
            }
            HiveBiome.CreateStandForLarva(position1);
            if (WorldGen.drunkWorldGen)
            {
                for (int index2 = 0; index2 < 1000; ++index2)
                {
                    Vector2 position2 = position1;
                    position2.X += (float)WorldGen.genRand.Next(-50, 51);
                    position2.Y += (float)WorldGen.genRand.Next(-50, 51);
                    if (WorldGen.InWorld((int)position2.X, (int)position2.Y, 0) && (double)Vector2.Distance(position1, position2) > 10.0 && (!Main.tile[(int)position2.X, (int)position2.Y].active() && Main.tile[(int)position2.X, (int)position2.Y].wall == (ushort)86))
                    {
                        HiveBiome.CreateStandForLarva(position2);
                        break;
                    }
                }
            }
            structures.AddProtectedStructure(new Microsoft.Xna.Framework.Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
            return(true);
        }