コード例 #1
0
        public static BusinessFlow ConvertSeleniumScript(string FileName)
        {
            //TODO: move code from here to converter/import class
            var      doc    = new HtmlDocument();
            Activity result = new Activity()
            {
                Active = true
            };

            BusinessFlow  bf = new BusinessFlow("");
            ePlatformType actionsPlatform = ePlatformType.Web;

            try
            {
                //get the required platform for actions
                string selectedPlatform = "";
                if (InputBoxWindow.OpenDialog("Required Platform", "Required platform (set 'Web' or 'Mobile'):", ref selectedPlatform))
                {
                    if (selectedPlatform.Trim().ToUpper() == "MOBILE")
                    {
                        actionsPlatform = ePlatformType.Mobile;
                    }
                }

                doc.Load(FileName);

                result.ActivityName = doc.DocumentNode.Descendants("title").FirstOrDefault().InnerText;
                bf.Name             = doc.DocumentNode.Descendants("title").FirstOrDefault().InnerText;

                List <HtmlNode> rows = doc.DocumentNode.Descendants("tbody").FirstOrDefault().Descendants()
                                       .Where(o => o.Name.StartsWith("tr")).ToList();
                bf.Activities.Add(result);
                string action      = "";
                string locatevalue = "";
                string value       = "";
                // string locby = "";
                ActGenElement.eGenElementAction GenAction;
                eLocateBy locType = eLocateBy.ByXPath;

                foreach (HtmlNode row in rows)
                {
                    if (row.Descendants("title").Count() > 0)
                    {
                        if (bf != null)
                        {
                            WorkSpace.Instance.SolutionRepository.AddRepositoryItem(bf);
                        }
                        bf     = new BusinessFlow(row.Descendants("title").FirstOrDefault().InnerText);
                        result = new Activity()
                        {
                            Active = true
                        };
                        result.ActivityName = row.Descendants("title").FirstOrDefault().InnerText;
                        bf.Activities.Add(result);
                    }
                    else
                    {
                        action      = row.Descendants("td").ToList()[0].InnerText;
                        locatevalue = row.Descendants("td").ToList()[1].InnerText.Replace("&amp;", "&").Replace("&gt;", ">");
                        value       = row.Descendants("td").ToList()[2].InnerText;

                        if (locatevalue.Trim().IndexOf("id=", StringComparison.CurrentCultureIgnoreCase) == 0 ||
                            locatevalue.Trim().IndexOf("id:=", StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            locType     = eLocateBy.ByID;
                            locatevalue = locatevalue.Replace("id=", "").Replace("id:=", "");;
                        }

                        if (locatevalue.Trim().IndexOf("link=", StringComparison.CurrentCultureIgnoreCase) == 0 ||
                            locatevalue.Trim().IndexOf("LinkText:=", StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            locType     = eLocateBy.ByLinkText;
                            locatevalue = locatevalue.Replace("link=", "").Replace("LinkText:=", "");
                        }
                        if (locatevalue.Trim().IndexOf("css=", StringComparison.CurrentCultureIgnoreCase) == 0 ||
                            locatevalue.Trim().IndexOf("cssselector:=", StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            locType     = eLocateBy.ByCSS;
                            locatevalue = locatevalue.Replace("css=", "").Replace("cssselector:=", "");
                        }
                        if (locatevalue.Trim().IndexOf("/") == 0 || locatevalue.Trim().IndexOf("xpath", StringComparison.CurrentCultureIgnoreCase) == 0)
                        {
                            locType     = eLocateBy.ByXPath;
                            locatevalue = locatevalue.Replace("xpath=", "").Replace("xpath:=", "").Replace("xpath:", "").Trim();
                        }

                        switch (action.ToUpper().Trim())
                        {
                        case "OPEN":
                            GenAction   = ActGenElement.eGenElementAction.GotoURL;
                            locType     = eLocateBy.NA;
                            locatevalue = "";
                            break;

                        case "FCOMMONLAUNCHENVIRONMENT":
                            GenAction   = ActGenElement.eGenElementAction.GotoURL;
                            locType     = eLocateBy.NA;
                            value       = locatevalue;
                            locatevalue = "";
                            break;

                        case "TYPE":
                        case "FCOMMONSETVALUEEDITBOX":
                            GenAction = ActGenElement.eGenElementAction.SetValue;
                            break;

                        case "SELECT":
                        case "FCOMMONSELECTIONOPTIONFROMLIST":
                            GenAction = ActGenElement.eGenElementAction.SelectFromDropDown;
                            break;

                        case "FCOMMONJAVASCRIPTCLICK":
                            GenAction = ActGenElement.eGenElementAction.Click;
                            break;

                        case "CLICKANDWAIT":
                        case "CLICK":
                        default:
                            GenAction = ActGenElement.eGenElementAction.Click;
                            break;
                        }

                        result.Acts.Add(new ActGenElement()
                        {
                            Active = true, Description = GenAction.ToString(), LocateBy = locType, LocateValue = locatevalue, GenElementAction = GenAction, Value = value, Platform = actionsPlatform
                        });
                    }
                }
                if (bf != null)
                {
                    return(bf);
                }
            }
            catch (Exception)
            {
                Reporter.ToUser(eUserMsgKeys.ImportSeleniumScriptError);
            }
            return(null);
        }
コード例 #2
0
ファイル: ShapeRoot.cs プロジェクト: PhelixSky/TeDW
 public override bool Perform(Point origin, GenAction action)
 {
     return(this.DoRoot(origin, action, this._angle, this._distance, this._startingSize));
 }
コード例 #3
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);
        }
コード例 #4
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point point;

            if (WorldGen.SolidTile(origin.X, origin.Y) && GenBase._tiles[origin.X, origin.Y].wall == 3)
            {
                return(false);
            }
            Searches.Down  down    = new Searches.Down(100);
            GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() };
            if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out origin))
            {
                return(false);
            }
            Point point1 = new Point(origin.X - 4, origin.Y);

            Searches.Down  down1             = new Searches.Down(5);
            GenCondition[] genConditionArray = new GenCondition[1];
            ushort[]       numArray          = new ushort[] { 25 };
            genConditionArray[0] = (new Conditions.IsTile(numArray)).AreaAnd(8, 1);
            if (!WorldUtils.Find(point1, Searches.Chain(down1, genConditionArray), out point))
            {
                return(false);
            }
            ShapeData shapeDatum  = new ShapeData();
            ShapeData shapeDatum1 = new ShapeData();
            ShapeData shapeDatum2 = new ShapeData();

            for (int i = 0; i < 6; i++)
            {
                Shapes.Circle circle = new Shapes.Circle(GenBase._random.Next(10, 12) + i);
                GenAction[]   offset = new GenAction[] { new Modifiers.Offset(0, 5 * i + 5), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum) };
                WorldUtils.Gen(origin, circle, Actions.Chain(offset));
            }
            for (int j = 0; j < 6; j++)
            {
                Shapes.Circle circle1        = new Shapes.Circle(GenBase._random.Next(5, 7) + j);
                GenAction[]   genActionArray = new GenAction[] { new Modifiers.Offset(0, 2 * j + 18), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum1) };
                WorldUtils.Gen(origin, circle1, Actions.Chain(genActionArray));
            }
            for (int k = 0; k < 6; k++)
            {
                Shapes.Circle circle2 = new Shapes.Circle(GenBase._random.Next(4, 6) + k / 2);
                GenAction[]   offset1 = new GenAction[] { new Modifiers.Offset(0, (int)(7.5f * (float)k) - 10), (new Modifiers.Blotches(3, 0.3)).Output(shapeDatum2) };
                WorldUtils.Gen(origin, circle2, Actions.Chain(offset1));
            }
            ShapeData shapeDatum3 = new ShapeData(shapeDatum1);

            shapeDatum1.Subtract(shapeDatum2, origin, origin);
            shapeDatum3.Subtract(shapeDatum1, origin, origin);
            ShapeData[] shapeDataArray = new ShapeData[] { shapeDatum, shapeDatum2 };
            Rectangle   bounds         = ShapeData.GetBounds(origin, shapeDataArray);

            if (!structures.CanPlace(bounds, CorruptionPitBiome.ValidTiles, 2))
            {
                return(false);
            }
            ModShapes.All all     = new ModShapes.All(shapeDatum);
            GenAction[]   setTile = new GenAction[] { new Actions.SetTile(25, true, true), new Actions.PlaceWall(3, true) };
            WorldUtils.Gen(origin, all, Actions.Chain(setTile));
            WorldUtils.Gen(origin, new ModShapes.All(shapeDatum1), new Actions.SetTile(0, true, true));
            WorldUtils.Gen(origin, new ModShapes.All(shapeDatum2), new Actions.ClearTile(true));
            ModShapes.All all1          = new ModShapes.All(shapeDatum1);
            GenAction[]   isTouchingAir = new GenAction[] { new Modifiers.IsTouchingAir(true), null, null };
            ushort[]      numArray1     = new ushort[] { 25 };
            isTouchingAir[1] = new Modifiers.NotTouching(false, numArray1);
            isTouchingAir[2] = new Actions.SetTile(23, true, true);
            WorldUtils.Gen(origin, all1, Actions.Chain(isTouchingAir));
            WorldUtils.Gen(origin, new ModShapes.All(shapeDatum3), new Actions.PlaceWall(69, true));
            structures.AddStructure(bounds, 2);
            return(true);
        }
コード例 #5
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point point;
            Point point1;
            Point point2 = new Point(origin.X - 3, origin.Y);

            Searches.Down  down = new Searches.Down(200);
            GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaAnd(6, 1) };
            if (!WorldUtils.Find(point2, Searches.Chain(down, genConditionArray), out point))
            {
                return(false);
            }
            Point point3 = new Point(point.X, point.Y - 5);

            Searches.Up    up = new Searches.Up(120);
            GenCondition[] genConditionArray1 = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(6, 1) };
            if (!WorldUtils.Find(point3, Searches.Chain(up, genConditionArray1), out point1) || point.Y - 5 - point1.Y > 60)
            {
                return(false);
            }
            if (point.Y - point1.Y < 30)
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(point.X - 30, point.Y - 60, 60, 90), 0))
            {
                return(false);
            }
            Dictionary <ushort, int> nums = new Dictionary <ushort, int>();
            Point point4 = new Point(point.X - 25, point.Y - 25);

            Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50);
            ushort[]         numArray  = new ushort[] { 0, 59, 147, 1 };
            WorldUtils.Gen(point4, rectangle, (new Actions.TileScanner(numArray)).Output(nums));
            int item = nums[0] + nums[1];
            int num  = nums[59];

            if (nums[147] > num || item > num || num < 50)
            {
                return(false);
            }
            int    y    = (point.Y - point1.Y - 9) / 5;
            int    num1 = y * 5;
            int    num2 = 0;
            double num3 = GenBase._random.NextDouble() + 1;
            double num4 = GenBase._random.NextDouble() + 2;

            if (GenBase._random.Next(2) == 0)
            {
                num4 = -num4;
            }
            for (int i = 0; i < y; i++)
            {
                double           num5       = (double)(i + 1) / 12;
                int              num6       = (int)(Math.Sin(num5 * num3 * 3.14159274101257) * num4);
                int              num7       = (num6 < num2 ? num6 - num2 : 0);
                Point            point5     = new Point(point.X + num2 + num7, point.Y - (i + 1) * 5);
                Shapes.Rectangle rectangle1 = new Shapes.Rectangle(6 + Math.Abs(num6 - num2), 7);
                GenAction[]      removeWall = new GenAction[] { new Actions.RemoveWall(), new Actions.SetTile(383, false, true), new Actions.SetFrames(false) };
                WorldUtils.Gen(point5, rectangle1, Actions.Chain(removeWall));
                Point            point6     = new Point(point.X + num2 + num7 + 2, point.Y - (i + 1) * 5);
                Shapes.Rectangle rectangle2 = new Shapes.Rectangle(2 + Math.Abs(num6 - num2), 5);
                GenAction[]      clearTile  = new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) };
                WorldUtils.Gen(point6, rectangle2, Actions.Chain(clearTile));
                Point            point7         = new Point(point.X + num2 + 2, point.Y - i * 5);
                Shapes.Rectangle rectangle3     = new Shapes.Rectangle(2, 2);
                GenAction[]      genActionArray = new GenAction[] { new Actions.ClearTile(true), new Actions.PlaceWall(78, true) };
                WorldUtils.Gen(point7, rectangle3, Actions.Chain(genActionArray));
                num2 = num6;
            }
            int num8 = 6;

            if (num4 < 0)
            {
                num8 = 0;
            }
            List <Point> points = new List <Point>();

            for (int j = 0; j < 2; j++)
            {
                double num9  = ((double)j + 1) / 3;
                int    num10 = num8 + (int)(Math.Sin((double)y * num9 / 12 * num3 * 3.14159274101257) * num4);
                double num11 = GenBase._random.NextDouble() * 0.785398185253143 - 0.785398185253143 - 0.200000002980232;
                if (num8 == 0)
                {
                    num11 = num11 - 1.57079637050629;
                }
                Point       point8      = new Point(point.X + num10, point.Y - (int)((double)(y * 5) * num9));
                ShapeBranch shapeBranch = (new ShapeBranch(num11, (double)GenBase._random.Next(12, 16))).OutputEndpoints(points);
                GenAction[] setTile     = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) };
                WorldUtils.Gen(point8, shapeBranch, Actions.Chain(setTile));
                num8 = 6 - num8;
            }
            int         num12        = (int)(Math.Sin((double)y / 12 * num3 * 3.14159274101257) * num4);
            Point       point9       = new Point(point.X + 6 + num12, point.Y - num1);
            ShapeBranch shapeBranch1 = (new ShapeBranch(-0.685398185253143, (double)GenBase._random.Next(16, 22))).OutputEndpoints(points);

            GenAction[] setTile1 = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) };
            WorldUtils.Gen(point9, shapeBranch1, Actions.Chain(setTile1));
            Point       point10      = new Point(point.X + num12, point.Y - num1);
            ShapeBranch shapeBranch2 = (new ShapeBranch(-2.45619455575943, (double)GenBase._random.Next(16, 22))).OutputEndpoints(points);

            GenAction[] genActionArray1 = new GenAction[] { new Actions.SetTile(383, false, true), new Actions.SetFrames(true) };
            WorldUtils.Gen(point10, shapeBranch2, Actions.Chain(genActionArray1));
            foreach (Point point11 in points)
            {
                Shapes.Circle circle    = new Shapes.Circle(4);
                GenAction[]   blotch    = new GenAction[] { new Modifiers.Blotches(4, 2, 0.3), null, null, null, null };
                ushort[]      numArray1 = new ushort[] { 383 };
                blotch[1] = new Modifiers.SkipTiles(numArray1);
                byte[] numArray2 = new byte[] { 78 };
                blotch[2] = new Modifiers.SkipWalls(numArray2);
                blotch[3] = new Actions.SetTile(384, false, true);
                blotch[4] = new Actions.SetFrames(true);
                WorldUtils.Gen(point11, circle, Actions.Chain(blotch));
            }
            for (int k = 0; k < 4; k++)
            {
                float single = (float)k / 3f * 2f + 0.57075f;
                WorldUtils.Gen(point, new ShapeRoot(single, (float)GenBase._random.Next(40, 60), 4f, 1f), new Actions.SetTile(383, true, true));
            }
            WorldGen.AddBuriedChest(point.X + 3, point.Y - 1, (GenBase._random.Next(4) == 0 ? 0 : WorldGen.GetNextJungleChestItem()), false, 10);
            structures.AddStructure(new Rectangle(point.X - 30, point.Y - 30, 60, 60), 0);
            return(true);
        }
コード例 #6
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point result1;

            if (!WorldUtils.Find(origin, Searches.Chain((GenSearch) new Searches.Down(200), (GenCondition) new Conditions.IsSolid()), out result1) || result1 == origin)
            {
                return(false);
            }
            Microsoft.Xna.Framework.Rectangle room1 = this.GetRoom(result1);
            Microsoft.Xna.Framework.Rectangle room2 = this.GetRoom(new Point(room1.Center.X, room1.Y + 1));
            Microsoft.Xna.Framework.Rectangle room3 = this.GetRoom(new Point(room1.Center.X, room1.Y + room1.Height + 10));
            room3.Y = room1.Y + room1.Height - 1;
            float num1 = this.RoomSolidPrecentage(room2);
            float num2 = this.RoomSolidPrecentage(room3);

            room1.Y += 3;
            room2.Y += 3;
            room3.Y += 3;
            List <Microsoft.Xna.Framework.Rectangle> rectangleList1 = new List <Microsoft.Xna.Framework.Rectangle>();

            if ((double)GenBase._random.NextFloat() > (double)num1 + 0.200000002980232)
            {
                rectangleList1.Add(room2);
            }
            else
            {
                room2 = room1;
            }
            rectangleList1.Add(room1);
            if ((double)GenBase._random.NextFloat() > (double)num2 + 0.200000002980232)
            {
                rectangleList1.Add(room3);
            }
            else
            {
                room3 = room1;
            }
            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                if (rectangle.Y + rectangle.Height > Main.maxTilesY - 220)
                {
                    return(false);
                }
            }
            Dictionary <ushort, int> resultsOutput = new Dictionary <ushort, int>();

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                WorldUtils.Gen(new Point(rectangle.X - 10, rectangle.Y - 10), (GenShape) new Shapes.Rectangle(rectangle.Width + 20, rectangle.Height + 20), (GenAction) new Actions.TileScanner(new ushort[12]
                {
                    (ushort)0,
                    (ushort)59,
                    (ushort)147,
                    (ushort)1,
                    (ushort)161,
                    (ushort)53,
                    (ushort)396,
                    (ushort)397,
                    (ushort)368,
                    (ushort)367,
                    (ushort)60,
                    (ushort)70
                }).Output(resultsOutput));
            }
            List <Tuple <CaveHouseBiome.BuildData, int> > tupleList1 = new List <Tuple <CaveHouseBiome.BuildData, int> >();

            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Default, resultsOutput[(ushort)0] + resultsOutput[(ushort)1]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Jungle, resultsOutput[(ushort)59] + resultsOutput[(ushort)60] * 10));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Mushroom, resultsOutput[(ushort)59] + resultsOutput[(ushort)70] * 10));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Snow, resultsOutput[(ushort)147] + resultsOutput[(ushort)161]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Desert, resultsOutput[(ushort)397] + resultsOutput[(ushort)396] + resultsOutput[(ushort)53]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Granite, resultsOutput[(ushort)368]));
            tupleList1.Add(Tuple.Create <CaveHouseBiome.BuildData, int>(CaveHouseBiome.BuildData.Marble, resultsOutput[(ushort)367]));
            tupleList1.Sort(new Comparison <Tuple <CaveHouseBiome.BuildData, int> >(this.SortBiomeResults));
            CaveHouseBiome.BuildData buildData = tupleList1[0].Item1;
            foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
            {
                if (buildData != CaveHouseBiome.BuildData.Granite)
                {
                    Point result2;
                    if (WorldUtils.Find(new Point(area.X - 2, area.Y - 2), Searches.Chain(new Searches.Rectangle(area.Width + 4, area.Height + 4).RequireAll(false), (GenCondition) new Conditions.HasLava()), out result2))
                    {
                        return(false);
                    }
                }
                if (!structures.CanPlace(area, CaveHouseBiome._blacklistedTiles, 5))
                {
                    return(false);
                }
            }
            int val1_1 = room1.X;
            int val1_2 = room1.X + room1.Width - 1;
            List <Microsoft.Xna.Framework.Rectangle> rectangleList2 = new List <Microsoft.Xna.Framework.Rectangle>();

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                val1_1 = Math.Min(val1_1, rectangle.X);
                val1_2 = Math.Max(val1_2, rectangle.X + rectangle.Width - 1);
            }
            int num3 = 6;

            while (num3 > 4 && (val1_2 - val1_1) % num3 != 0)
            {
                --num3;
            }
            int x1 = val1_1;

            while (x1 <= val1_2)
            {
                for (int index1 = 0; index1 < rectangleList1.Count; ++index1)
                {
                    Microsoft.Xna.Framework.Rectangle rectangle = rectangleList1[index1];
                    if (x1 >= rectangle.X && x1 < rectangle.X + rectangle.Width)
                    {
                        int y    = rectangle.Y + rectangle.Height;
                        int num4 = 50;
                        for (int index2 = index1 + 1; index2 < rectangleList1.Count; ++index2)
                        {
                            if (x1 >= rectangleList1[index2].X && x1 < rectangleList1[index2].X + rectangleList1[index2].Width)
                            {
                                num4 = Math.Min(num4, rectangleList1[index2].Y - y);
                            }
                        }
                        if (num4 > 0)
                        {
                            Point result2;
                            bool  flag = WorldUtils.Find(new Point(x1, y), Searches.Chain((GenSearch) new Searches.Down(num4), (GenCondition) new Conditions.IsSolid()), out result2);
                            if (num4 < 50)
                            {
                                flag    = true;
                                result2 = new Point(x1, y + num4);
                            }
                            if (flag)
                            {
                                rectangleList2.Add(new Microsoft.Xna.Framework.Rectangle(x1, y, 1, result2.Y - y));
                            }
                        }
                    }
                }
                x1 += num3;
            }
            List <Point> pointList1 = new List <Point>();

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                int exitY;
                if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X + rectangle.Width, rectangle.Y + 1, 1, rectangle.Height - 2), false, out exitY))
                {
                    pointList1.Add(new Point(rectangle.X + rectangle.Width - 1, exitY));
                }
                if (this.FindSideExit(new Microsoft.Xna.Framework.Rectangle(rectangle.X, rectangle.Y + 1, 1, rectangle.Height - 2), true, out exitY))
                {
                    pointList1.Add(new Point(rectangle.X, exitY));
                }
            }
            List <Tuple <Point, Point> > tupleList2 = new List <Tuple <Point, Point> >();

            for (int index = 1; index < rectangleList1.Count; ++index)
            {
                Microsoft.Xna.Framework.Rectangle rectangle1 = rectangleList1[index];
                Microsoft.Xna.Framework.Rectangle rectangle2 = rectangleList1[index - 1];
                if (rectangle2.X - rectangle1.X > rectangle1.X + rectangle1.Width - (rectangle2.X + rectangle2.Width))
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X + rectangle1.Width - 1, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Width - rectangle1.Height + 1, rectangle1.Y + rectangle1.Height - 1)));
                }
                else
                {
                    tupleList2.Add(new Tuple <Point, Point>(new Point(rectangle1.X, rectangle1.Y + 1), new Point(rectangle1.X + rectangle1.Height - 1, rectangle1.Y + rectangle1.Height - 1)));
                }
            }
            List <Point> pointList2 = new List <Point>();
            int          exitX;

            if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room2.X + 2, room2.Y, room2.Width - 4, 1), true, out exitX))
            {
                pointList2.Add(new Point(exitX, room2.Y));
            }
            if (this.FindVerticalExit(new Microsoft.Xna.Framework.Rectangle(room3.X + 2, room3.Y + room3.Height - 1, room3.Width - 4, 1), false, out exitX))
            {
                pointList2.Add(new Point(exitX, room3.Y + room3.Height - 1));
            }
            foreach (Microsoft.Xna.Framework.Rectangle area in rectangleList1)
            {
                WorldUtils.Gen(new Point(area.X, area.Y), (GenShape) new Shapes.Rectangle(area.Width, area.Height), Actions.Chain((GenAction) new Actions.SetTile(buildData.Tile, false, true), (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(area.X + 1, area.Y + 1), (GenShape) new Shapes.Rectangle(area.Width - 2, area.Height - 2), Actions.Chain((GenAction) new Actions.ClearTile(true), (GenAction) new Actions.PlaceWall(buildData.Wall, true)));
                structures.AddStructure(area, 8);
            }
            foreach (Tuple <Point, Point> tuple in tupleList2)
            {
                Point     origin1 = tuple.Item1;
                Point     point   = tuple.Item2;
                int       num4    = point.X > origin1.X ? 1 : -1;
                ShapeData data    = new ShapeData();
                for (int y = 0; y < point.Y - origin1.Y; ++y)
                {
                    data.Add(num4 * (y + 1), y);
                }
                WorldUtils.Gen(origin1, (GenShape) new ModShapes.All(data), Actions.Chain((GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetSlope(num4 == 1 ? 1 : 2), (GenAction) new Actions.SetFrames(true)));
                WorldUtils.Gen(new Point(origin1.X + (num4 == 1 ? 1 : -4), origin1.Y - 1), (GenShape) new Shapes.Rectangle(4, 1), Actions.Chain((GenAction) new Actions.Clear(), (GenAction) new Actions.PlaceWall(buildData.Wall, true), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true)));
            }
            foreach (Point origin1 in pointList1)
            {
                WorldUtils.Gen(origin1, (GenShape) new Shapes.Rectangle(1, 3), (GenAction) new Actions.ClearTile(true));
                WorldGen.PlaceTile(origin1.X, origin1.Y, 10, true, true, -1, buildData.DoorStyle);
            }
            foreach (Point origin1 in pointList2)
            {
                Shapes.Rectangle rectangle = new Shapes.Rectangle(3, 1);
                GenAction        action    = Actions.Chain((GenAction) new Actions.ClearMetadata(), (GenAction) new Actions.PlaceTile((ushort)19, buildData.PlatformStyle), (GenAction) new Actions.SetFrames(true));
                WorldUtils.Gen(origin1, (GenShape)rectangle, action);
            }
            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList2)
            {
                if (rectangle.Height > 1 && (int)GenBase._tiles[rectangle.X, rectangle.Y - 1].type != 19)
                {
                    WorldUtils.Gen(new Point(rectangle.X, rectangle.Y), (GenShape) new Shapes.Rectangle(rectangle.Width, rectangle.Height), Actions.Chain((GenAction) new Actions.SetTile((ushort)124, false, true), (GenAction) new Actions.SetFrames(true)));
                    Tile tile = GenBase._tiles[rectangle.X, rectangle.Y + rectangle.Height];
                    tile.slope((byte)0);
                    tile.halfBrick(false);
                }
            }
            Point[] pointArray = new Point[7]
            {
                new Point(14, buildData.TableStyle),
                new Point(16, 0),
                new Point(18, buildData.WorkbenchStyle),
                new Point(86, 0),
                new Point(87, buildData.PianoStyle),
                new Point(94, 0),
                new Point(101, buildData.BookcaseStyle)
            };
            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                int num4 = rectangle.Width / 8;
                int num5 = rectangle.Width / (num4 + 1);
                int num6 = GenBase._random.Next(2);
                for (int index1 = 0; index1 < num4; ++index1)
                {
                    int num7 = (index1 + 1) * num5 + rectangle.X;
                    switch (index1 + num6 % 2)
                    {
                    case 0:
                        int     num8    = rectangle.Y + Math.Min(rectangle.Height / 2, rectangle.Height - 5);
                        Vector2 vector2 = WorldGen.randHousePicture();
                        int     x2      = (int)vector2.X;
                        int     y       = (int)vector2.Y;
                        if (!WorldGen.nearPicture(num7, num8))
                        {
                            WorldGen.PlaceTile(num7, num8, x2, true, false, -1, y);
                            break;
                        }
                        break;

                    case 1:
                        int j = rectangle.Y + 1;
                        WorldGen.PlaceTile(num7, j, 34, true, false, -1, GenBase._random.Next(6));
                        for (int index2 = -1; index2 < 2; ++index2)
                        {
                            for (int index3 = 0; index3 < 3; ++index3)
                            {
                                GenBase._tiles[index2 + num7, index3 + j].frameX += (short)54;
                            }
                        }
                        break;
                    }
                }
                int num9 = rectangle.Width / 8 + 3;
                WorldGen.SetupStatueList();
                for (; num9 > 0; --num9)
                {
                    int num7 = GenBase._random.Next(rectangle.Width - 3) + 1 + rectangle.X;
                    int num8 = rectangle.Y + rectangle.Height - 2;
                    switch (GenBase._random.Next(4))
                    {
                    case 0:
                        WorldGen.PlaceSmallPile(num7, num8, GenBase._random.Next(31, 34), 1, (ushort)185);
                        break;

                    case 1:
                        WorldGen.PlaceTile(num7, num8, 186, true, false, -1, GenBase._random.Next(22, 26));
                        break;

                    case 2:
                        int index = GenBase._random.Next(2, WorldGen.statueList.Length);
                        WorldGen.PlaceTile(num7, num8, (int)WorldGen.statueList[index].X, true, false, -1, (int)WorldGen.statueList[index].Y);
                        if (WorldGen.StatuesWithTraps.Contains(index))
                        {
                            WorldGen.PlaceStatueTrap(num7, num8);
                            break;
                        }
                        break;

                    case 3:
                        Point point = Utils.SelectRandom <Point>(GenBase._random, pointArray);
                        WorldGen.PlaceTile(num7, num8, point.X, true, false, -1, point.Y);
                        break;
                    }
                }
            }
            foreach (Microsoft.Xna.Framework.Rectangle room4 in rectangleList1)
            {
                buildData.ProcessRoom(room4);
            }
            bool flag1 = false;

            foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
            {
                int j     = rectangle.Height - 1 + rectangle.Y;
                int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                int num4  = 0;
                while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style)))
                {
                    ++num4;
                }
                if (!flag1)
                {
                    int i = rectangle.X + 2;
                    while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                    {
                        ++i;
                    }
                    if (flag1)
                    {
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
            if (!flag1)
            {
                foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
                {
                    int j     = rectangle.Y - 1;
                    int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    int num4  = 0;
                    while (num4 < 10 && !(flag1 = WorldGen.AddBuriedChest(GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X, j, 0, false, Style)))
                    {
                        ++num4;
                    }
                    if (!flag1)
                    {
                        int i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 && !(flag1 = WorldGen.AddBuriedChest(i, j, 0, false, Style)))
                        {
                            ++i;
                        }
                        if (flag1)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            if (!flag1)
            {
                for (int index = 0; index < 1000; ++index)
                {
                    int i     = GenBase._random.Next(rectangleList1[0].X - 30, rectangleList1[0].X + 30);
                    int j     = GenBase._random.Next(rectangleList1[0].Y - 30, rectangleList1[0].Y + 30);
                    int Style = j > (int)Main.worldSurface ? buildData.ChestStyle : 0;
                    if (WorldGen.AddBuriedChest(i, j, 0, false, Style))
                    {
                        break;
                    }
                }
            }
            if (buildData == CaveHouseBiome.BuildData.Jungle && this._sharpenerCount < GenBase._random.Next(2, 5))
            {
                bool flag2 = false;
                foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
                {
                    int j = rectangle.Height - 2 + rectangle.Y;
                    for (int index = 0; index < 10; ++index)
                    {
                        int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 377, true, true, -1, 0);
                        if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 377)
                        {
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        int i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 377, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (flag2)
                {
                    ++this._sharpenerCount;
                }
            }
            if (buildData == CaveHouseBiome.BuildData.Desert && this._extractinatorCount < GenBase._random.Next(2, 5))
            {
                bool flag2 = false;
                foreach (Microsoft.Xna.Framework.Rectangle rectangle in rectangleList1)
                {
                    int j = rectangle.Height - 2 + rectangle.Y;
                    for (int index = 0; index < 10; ++index)
                    {
                        int i = GenBase._random.Next(2, rectangle.Width - 2) + rectangle.X;
                        WorldGen.PlaceTile(i, j, 219, true, true, -1, 0);
                        if (flag2 = GenBase._tiles[i, j].active() && (int)GenBase._tiles[i, j].type == 219)
                        {
                            break;
                        }
                    }
                    if (!flag2)
                    {
                        int i = rectangle.X + 2;
                        while (i <= rectangle.X + rectangle.Width - 2 && !(flag2 = WorldGen.PlaceTile(i, j, 219, true, true, -1, 0)))
                        {
                            ++i;
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (flag2)
                {
                    ++this._extractinatorCount;
                }
            }
            return(true);
        }
コード例 #7
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point y;
            Point point;
            Dictionary <ushort, int> nums = new Dictionary <ushort, int>();
            Point point1 = new Point(origin.X - 25, origin.Y - 25);

            Shapes.Rectangle rectangle = new Shapes.Rectangle(50, 50);
            ushort[]         numArray  = new ushort[] { 0, 1 };
            WorldUtils.Gen(point1, rectangle, (new Actions.TileScanner(numArray)).Output(nums));
            if (nums[0] + nums[1] < 1250)
            {
                return(false);
            }
            Searches.Up    up = new Searches.Up(1000);
            GenCondition[] genConditionArray = new GenCondition[] { (new Conditions.IsSolid()).AreaOr(1, 50).Not() };
            bool           flag   = WorldUtils.Find(origin, Searches.Chain(up, genConditionArray), out y);
            Point          point2 = origin;

            Searches.Up    up1       = new Searches.Up(origin.Y - y.Y);
            GenCondition[] isTile    = new GenCondition[1];
            ushort[]       numArray1 = new ushort[] { 53 };
            isTile[0] = new Conditions.IsTile(numArray1);
            if (WorldUtils.Find(point2, Searches.Chain(up1, isTile), out point))
            {
                return(false);
            }
            if (!flag)
            {
                return(false);
            }
            y.Y = y.Y + 50;
            ShapeData shapeDatum  = new ShapeData();
            ShapeData shapeDatum1 = new ShapeData();
            Point     point3      = new Point(origin.X, origin.Y + 20);
            Point     point4      = new Point(origin.X, origin.Y + 30);
            float     single      = 0.8f + GenBase._random.NextFloat() * 0.5f;

            if (!structures.CanPlace(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 0))
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(origin.X, y.Y + 10, 1, origin.Y - y.Y - 9), 2))
            {
                return(false);
            }
            Shapes.Slime slime  = new Shapes.Slime(20, single, 1f);
            GenAction[]  blotch = new GenAction[] { new Modifiers.Blotches(2, 0.4), (new Actions.ClearTile(true)).Output(shapeDatum) };
            WorldUtils.Gen(point3, slime, Actions.Chain(blotch));
            Shapes.Mound mound          = new Shapes.Mound(14, 14);
            GenAction[]  genActionArray = new GenAction[] { new Modifiers.Blotches(2, 1, 0.8), new Actions.SetTile(0, false, true), (new Actions.SetFrames(true)).Output(shapeDatum1) };
            WorldUtils.Gen(point4, mound, Actions.Chain(genActionArray));
            shapeDatum.Subtract(shapeDatum1, point3, point4);
            ModShapes.InnerOutline innerOutline = new ModShapes.InnerOutline(shapeDatum, true);
            GenAction[]            setTile      = new GenAction[] { new Actions.SetTile(2, false, true), new Actions.SetFrames(true) };
            WorldUtils.Gen(point3, innerOutline, Actions.Chain(setTile));
            ModShapes.All all           = new ModShapes.All(shapeDatum);
            GenAction[]   rectangleMask = new GenAction[] { new Modifiers.RectangleMask(-40, 40, 0, 40), new Modifiers.IsEmpty(), new Actions.SetLiquid(0, 255) };
            WorldUtils.Gen(point3, all, Actions.Chain(rectangleMask));
            ModShapes.All all1      = new ModShapes.All(shapeDatum);
            GenAction[]   placeWall = new GenAction[] { new Actions.PlaceWall(68, true), null, null, null };
            ushort[]      numArray2 = new ushort[] { 2 };
            placeWall[1] = new Modifiers.OnlyTiles(numArray2);
            placeWall[2] = new Modifiers.Offset(0, 1);
            placeWall[3] = new ActionVines(3, 5, 52);
            WorldUtils.Gen(point3, all1, Actions.Chain(placeWall));
            ShapeData shapeDatum2 = new ShapeData();
            Point     point5      = new Point(origin.X, y.Y + 10);

            Shapes.Rectangle rectangle1 = new Shapes.Rectangle(1, origin.Y - y.Y - 9);
            GenAction[]      onlyTile   = new GenAction[] { new Modifiers.Blotches(2, 0.2), (new Actions.ClearTile(false)).Output(shapeDatum2), new Modifiers.Expand(1), null, null };
            ushort[]         numArray3  = new ushort[] { 53 };
            onlyTile[3] = new Modifiers.OnlyTiles(numArray3);
            onlyTile[4] = (new Actions.SetTile(397, false, true)).Output(shapeDatum2);
            WorldUtils.Gen(point5, rectangle1, Actions.Chain(onlyTile));
            WorldUtils.Gen(new Point(origin.X, y.Y + 10), new ModShapes.All(shapeDatum2), new Actions.SetFrames(true));
            if (GenBase._random.Next(3) != 0)
            {
                WorldGen.PlaceTile(point4.X, point4.Y - 15, 186, true, false, -1, 15);
            }
            else
            {
                WorldGen.PlaceTile(point4.X, point4.Y - 15, 187, true, false, -1, 17);
            }
            ModShapes.All all2      = new ModShapes.All(shapeDatum1);
            GenAction[]   offset    = new GenAction[] { new Modifiers.Offset(0, -1), null, null, null };
            ushort[]      numArray4 = new ushort[] { 2 };
            offset[1] = new Modifiers.OnlyTiles(numArray4);
            offset[2] = new Modifiers.Offset(0, -1);
            offset[3] = new ActionGrass();
            WorldUtils.Gen(point4, all2, Actions.Chain(offset));
            structures.AddStructure(new Rectangle(point3.X - (int)(20f * single), point3.Y - 20, (int)(40f * single), 40), 4);
            return(true);
        }
コード例 #8
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Point     point;
            Ref <int> @ref = new Ref <int>(0);
            Ref <int> ref1 = new Ref <int>(0);

            Shapes.Circle circle  = new Shapes.Circle(10);
            GenAction[]   scanner = new GenAction[] { new Actions.Scanner(ref1), new Modifiers.IsSolid(), new Actions.Scanner(@ref) };
            WorldUtils.Gen(origin, circle, Actions.Chain(scanner));
            if (@ref.Value < ref1.Value - 5)
            {
                return(false);
            }
            int num  = GenBase._random.Next(6, 10);
            int num1 = GenBase._random.Next(5);

            if (!structures.CanPlace(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 0))
            {
                return(false);
            }
            ShapeData shapeDatum = new ShapeData();

            Shapes.Slime slime    = new Shapes.Slime(num);
            GenAction[]  onlyTile = new GenAction[] { (new Modifiers.Blotches(num1, num1, num1, 1, 0.3)).Output(shapeDatum), new Modifiers.Offset(0, -2), null, null, null, null };
            ushort[]     numArray = new ushort[] { 53 };
            onlyTile[2] = new Modifiers.OnlyTiles(numArray);
            onlyTile[3] = new Actions.SetTile(397, true, true);
            onlyTile[4] = new Modifiers.OnlyWalls(new byte[1]);
            onlyTile[5] = new Actions.PlaceWall(16, true);
            WorldUtils.Gen(origin, slime, Actions.Chain(onlyTile));
            ModShapes.All all       = new ModShapes.All(shapeDatum);
            GenAction[]   clearTile = new GenAction[] { new Actions.ClearTile(false), new Actions.SetLiquid(0, 0), new Actions.SetFrames(true), new Modifiers.OnlyWalls(new byte[1]), new Actions.PlaceWall(16, true) };
            WorldUtils.Gen(origin, all, Actions.Chain(clearTile));
            Searches.Down  down    = new Searches.Down(10);
            GenCondition[] isSolid = new GenCondition[] { new Conditions.IsSolid() };
            if (!WorldUtils.Find(origin, Searches.Chain(down, isSolid), out point))
            {
                return(false);
            }
            int  y    = point.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 : -(num >> 1));
                for (int i = 0; i < num2; i++)
                {
                    int num4 = GenBase._random.Next(1, 3);
                    for (int j = 0; j < num4; j++)
                    {
                        WorldGen.PlaceTile(origin.X + num3 - i, y - j, 331, false, false, -1, 0);
                    }
                }
            }
            int num5 = (num - 3) * (flag ? -1 : 1);

            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X + num5, y, 186, false, false, -1, 0);
            }
            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X, y, 215, true, false, -1, 0);
                if (GenBase._tiles[origin.X, y].active() && GenBase._tiles[origin.X, y].type == 215)
                {
                    Tile tile = GenBase._tiles[origin.X, y];
                    tile.frameY = (short)(tile.frameY + 36);
                    Tile tile1 = GenBase._tiles[origin.X - 1, y];
                    tile1.frameY = (short)(tile1.frameY + 36);
                    Tile tile2 = GenBase._tiles[origin.X + 1, y];
                    tile2.frameY = (short)(tile2.frameY + 36);
                    Tile tile3 = GenBase._tiles[origin.X, y - 1];
                    tile3.frameY = (short)(tile3.frameY + 36);
                    Tile tile4 = GenBase._tiles[origin.X - 1, y - 1];
                    tile4.frameY = (short)(tile4.frameY + 36);
                    Tile tile5 = GenBase._tiles[origin.X + 1, y - 1];
                    tile5.frameY = (short)(tile5.frameY + 36);
                }
            }
            structures.AddStructure(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 4);
            return(true);
        }
コード例 #9
0
        public override bool Place(Point origin, StructureMap structures)
        {
            Ref <int> @ref = new Ref <int>(0);
            Ref <int> ref1 = new Ref <int>(0);
            Ref <int> ref2 = new Ref <int>(0);
            Ref <int> ref3 = new Ref <int>(0);

            Shapes.Circle circle   = new Shapes.Circle(15);
            GenAction[]   scanner  = new GenAction[] { new Actions.Scanner(ref2), new Modifiers.IsSolid(), new Actions.Scanner(@ref), null, null, null, null };
            ushort[]      numArray = new ushort[] { 60, 59 };
            scanner[3] = new Modifiers.OnlyTiles(numArray);
            scanner[4] = new Actions.Scanner(ref1);
            ushort[] numArray1 = new ushort[] { 60 };
            scanner[5] = new Modifiers.OnlyTiles(numArray1);
            scanner[6] = new Actions.Scanner(ref3);
            WorldUtils.Gen(origin, circle, Actions.Chain(scanner));
            if ((float)ref1.Value / (float)@ref.Value < 0.75f || ref3.Value < 2)
            {
                return(false);
            }
            if (!structures.CanPlace(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 0))
            {
                return(false);
            }
            int x   = origin.X;
            int y   = origin.Y;
            int num = 150;

            for (int i = x - num; i < x + num; i = i + 10)
            {
                if (i > 0 && i <= Main.maxTilesX - 1)
                {
                    for (int j = y - num; j < y + num; j = j + 10)
                    {
                        if (j > 0 && j <= Main.maxTilesY - 1)
                        {
                            if (Main.tile[i, j].active() && Main.tile[i, j].type == 226)
                            {
                                return(false);
                            }
                            if (Main.tile[i, j].wall == 87 || Main.tile[i, j].wall == 3 || Main.tile[i, j].wall == 83)
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
            int x1   = origin.X;
            int y1   = origin.Y;
            int num1 = 0;

            int[]   x2       = new int[10];
            int[]   y2       = new int[10];
            Vector2 vector2  = new Vector2((float)x1, (float)y1);
            Vector2 vector21 = vector2;
            int     num2     = WorldGen.genRand.Next(2, 5);

            for (int k = 0; k < num2; k++)
            {
                int num3 = WorldGen.genRand.Next(2, 5);
                for (int l = 0; l < num3; l++)
                {
                    vector21 = WorldGen.Hive((int)vector2.X, (int)vector2.Y);
                }
                vector2  = vector21;
                x2[num1] = (int)vector2.X;
                y2[num1] = (int)vector2.Y;
                num1++;
            }
            for (int m = 0; m < num1; m++)
            {
                int  num4 = x2[m];
                int  num5 = y2[m];
                bool flag = false;
                int  num6 = 1;
                if (WorldGen.genRand.Next(2) == 0)
                {
                    num6 = -1;
                }
                while (num4 > 10 && num4 < Main.maxTilesX - 10 && num5 > 10 && num5 < Main.maxTilesY - 10 && (!Main.tile[num4, num5].active() || !Main.tile[num4, num5 + 1].active() || !Main.tile[num4 + 1, num5].active() || !Main.tile[num4 + 1, num5 + 1].active()))
                {
                    num4 = num4 + num6;
                    if (Math.Abs(num4 - x2[m]) <= 50)
                    {
                        continue;
                    }
                    flag = true;
                    break;
                }
                if (!flag)
                {
                    num4 = num4 + num6;
                    for (int n = num4 - 1; n <= num4 + 2; n++)
                    {
                        for (int o = num5 - 1; o <= num5 + 2; o++)
                        {
                            if (n < 10 || n > Main.maxTilesX - 10)
                            {
                                flag = true;
                            }
                            else if (Main.tile[n, o].active() && Main.tile[n, o].type != 225)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    if (!flag)
                    {
                        for (int p = num4 - 1; p <= num4 + 2; p++)
                        {
                            for (int q = num5 - 1; q <= num5 + 2; q++)
                            {
                                if (p < num4 || p > num4 + 1 || q < num5 || q > num5 + 1)
                                {
                                    Main.tile[p, q].active(true);
                                    Main.tile[p, q].type = 225;
                                }
                                else
                                {
                                    Main.tile[p, q].active(false);
                                    Main.tile[p, q].liquid = 255;
                                    Main.tile[p, q].honey(true);
                                }
                            }
                        }
                        num6 = num6 * -1;
                        num5++;
                        int num7 = 0;
                        while ((num7 < 4 || WorldGen.SolidTile(num4, num5)) && num4 > 10 && num4 < Main.maxTilesX - 10)
                        {
                            num7++;
                            num4 = num4 + num6;
                            if (!WorldGen.SolidTile(num4, num5))
                            {
                                continue;
                            }
                            WorldGen.PoundTile(num4, num5);
                            if (Main.tile[num4, num5 + 1].active())
                            {
                                continue;
                            }
                            Main.tile[num4, num5 + 1].active(true);
                            Main.tile[num4, num5 + 1].type = 225;
                        }
                    }
                }
            }
            WorldGen.larvaX[WorldGen.numLarva] = Utils.Clamp <int>((int)vector2.X, 5, Main.maxTilesX - 5);
            WorldGen.larvaY[WorldGen.numLarva] = Utils.Clamp <int>((int)vector2.Y, 5, Main.maxTilesY - 5);
            WorldGen.numLarva = WorldGen.numLarva + 1;
            int x3 = (int)vector2.X;
            int y3 = (int)vector2.Y;

            for (int r = x3 - 1; r <= x3 + 1 && r > 0 && r < Main.maxTilesX; r++)
            {
                for (int s = y3 - 2; s <= y3 + 1 && s > 0 && s < Main.maxTilesY; s++)
                {
                    if (s == y3 + 1)
                    {
                        Main.tile[r, s].active(true);
                        Main.tile[r, s].type = 225;
                        Main.tile[r, s].slope(0);
                        Main.tile[r, s].halfBrick(false);
                    }
                    else
                    {
                        Main.tile[r, s].active(false);
                    }
                }
            }
            structures.AddStructure(new Rectangle(origin.X - 50, origin.Y - 50, 100, 100), 5);
            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 GenAction[]
            {
                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), 0))
            {
                return(false);
            }
            ShapeData data      = new ShapeData();
            Point     arg_12A_0 = origin;
            GenShape  arg_12A_1 = new Shapes.Slime(num);

            GenAction[] array = new GenAction[6];
            array[0] = new Modifiers.Blotches(num2, num2, num2, 1, 0.3).Output(data);
            array[1] = new Modifiers.Offset(0, -2);
            array[2] = new Modifiers.OnlyTiles(new ushort[]
            {
                53
            });
            array[3] = new Actions.SetTile(397, true, true);
            GenAction[] arg_116_0 = array;
            int         arg_116_1 = 4;

            byte[] types = new byte[1];
            arg_116_0[arg_116_1] = new Modifiers.OnlyWalls(types);
            array[5]             = new Actions.PlaceWall(16, true);
            WorldUtils.Gen(arg_12A_0, arg_12A_1, Actions.Chain(array));
            Point    arg_185_0 = origin;
            GenShape arg_185_1 = new ModShapes.All(data);

            GenAction[] array2 = new GenAction[5];
            array2[0] = new Actions.ClearTile(false);
            array2[1] = new Actions.SetLiquid(0, 0);
            array2[2] = new Actions.SetFrames(true);
            GenAction[] arg_171_0 = array2;
            int         arg_171_1 = 3;

            byte[] types2 = new byte[1];
            arg_171_0[arg_171_1] = new Modifiers.OnlyWalls(types2);
            array2[4]            = new Actions.PlaceWall(16, true);
            WorldUtils.Gen(arg_185_0, arg_185_1, Actions.Chain(array2));
            Point point;

            if (!WorldUtils.Find(origin, Searches.Chain(new Searches.Down(10), new GenCondition[]
            {
                new Conditions.IsSolid()
            }), out point))
            {
                return(false);
            }
            int  num3 = point.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 i = 0; i < num4; i++)
                {
                    int num6 = GenBase._random.Next(1, 3);
                    for (int j = 0; j < num6; j++)
                    {
                        WorldGen.PlaceTile(origin.X + num5 - i, num3 - j, 331, false, false, -1, 0);
                    }
                }
            }
            int num7 = (num - 3) * (flag ? -1 : 1);

            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X + num7, num3, 186, false, false, -1, 0);
            }
            if (GenBase._random.Next() % 10 != 0)
            {
                WorldGen.PlaceTile(origin.X, num3, 215, true, false, -1, 0);
                if (GenBase._tiles[origin.X, num3].active() && GenBase._tiles[origin.X, num3].type == 215)
                {
                    Tile expr_305 = GenBase._tiles[origin.X, num3];
                    expr_305.frameY += 36;
                    Tile expr_329 = GenBase._tiles[origin.X - 1, num3];
                    expr_329.frameY += 36;
                    Tile expr_34D = GenBase._tiles[origin.X + 1, num3];
                    expr_34D.frameY += 36;
                    Tile expr_371 = GenBase._tiles[origin.X, num3 - 1];
                    expr_371.frameY += 36;
                    Tile expr_397 = GenBase._tiles[origin.X - 1, num3 - 1];
                    expr_397.frameY += 36;
                    Tile expr_3BD = GenBase._tiles[origin.X + 1, num3 - 1];
                    expr_3BD.frameY += 36;
                }
            }
            structures.AddStructure(new Rectangle(origin.X - num, origin.Y - num, num * 2, num * 2), 4);
            return(true);
        }