Exemple #1
0
        public static Task AsyncGenerateIsland(int island, int posX, int posY)
        {
            WorldRefill.isTaskRunning = true;
            WorldRefill.realcount     = 1;
            switch (island)
            {
            case 0:
                WorldGen.FloatingIsland(posX, posY);
                for (int x = posX - 20; x < posX + 20; x++)
                {
                    int cloudsurface()
                    {
                        int cY = posY;

                        while (Main.tile[x, cY].active())
                        {
                            cY--;
                        }
                        cY++;
                        return(cY);
                    };
                    WorldGen.SpreadGrassDirect(posX, cloudsurface());
                }
                WorldGen.IslandHouse(posX, posY - 6 /*, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]*/);
                break;

            case 3:
                WorldGen.CloudLake(posX, posY);
                break;

            case 4:
                WorldGen.CloudIsland(posX, posY);
                for (int x = posX - 20; x < posX + 20; x++)
                {
                    int cloudsurface()
                    {
                        int cY = posY;

                        while (Main.tile[x, cY].active())
                        {
                            cY--;
                        }
                        cY++;
                        return(cY);
                    };
                    WorldGen.SpreadGrassDirect(posX, cloudsurface());
                }
                WorldGen.IslandHouse(posX, posY - 6 /*, WorldGen.floatingIslandStyle[WorldGen.genRand.Next(0, WorldGen.floatingIslandStyle.Count() - 1)]*/);
                break;
            }
            return(Task.Run(() => { WorldRefill.isTaskRunning = false; }));
        }
Exemple #2
0
        public override void ModMenuAction(TehModAPI api, MenuOption opt)
        {
            if (!toolkit.IsInGame() || Main.netMode != 0)
            {
                return;
            }
            try
            {
                switch (opt.action)
                {
                case "addSnow":
                    WriteSnow();
                    UpdateFrames();
                    break;

                case "convertSnow":
                    bool doet;
                    if (ConfirmAction.TryGetValue("convertSnow", out doet))
                    {
                        ConfirmAction.Remove("convertSnow");
                        OverwriteSnow();
                        UpdateFrames();
                    }
                    else
                    {
                        Main.NewText("Please click the button again to confirm that you want to do this.", 255, 0, 0);
                        ConfirmAction.Add("convertSnow", false);
                    }
                    break;

                case "convertWorldSnow":
                    if (ConfirmAction.TryGetValue("convertWorldSnow", out doet))
                    {
                        ConfirmAction.Remove("convertWorldSnow");
                        OverwriteSnowTotal();
                        UpdateFrames();
                    }
                    else
                    {
                        Main.NewText("Please click the button again to confirm that you want to do this.", 255, 0, 0);
                        ConfirmAction.Add("convertWorldSnow", false);
                    }
                    break;

                case "exitNoSave":
                    QuitGame();
                    break;

                case "addDungeon":
                    WorldGen.MakeDungeon((int)(toolkit.GetPlayer().position.X / 16), (int)(toolkit.GetPlayer().position.Y / 16));
                    UpdateFrames();
                    Main.NewText("Made a dungeon.");
                    break;

                case "addHell":
                    WorldGen.HellHouse((int)(toolkit.GetPlayer().position.X / 16), (int)(toolkit.GetPlayer().position.Y / 16));
                    UpdateFrames();
                    Main.NewText("Made a hell house.");
                    break;

                case "addIsland":
                    WorldGen.FloatingIsland((int)(toolkit.GetPlayer().position.X / 16), (int)(toolkit.GetPlayer().position.Y / 16));
                    UpdateFrames();
                    Main.NewText("Made a floating island.");
                    break;

                case "addIslandHouse":
                    WorldGen.IslandHouse((int)(toolkit.GetPlayer().position.X / 16), (int)(toolkit.GetPlayer().position.Y / 16));
                    UpdateFrames();
                    Main.NewText("Made a floating island house.");
                    break;

                case "addMineHouse":
                    WorldGen.MineHouse((int)(toolkit.GetPlayer().position.X / 16), (int)(toolkit.GetPlayer().position.Y / 16));
                    UpdateFrames();
                    Main.NewText("Made a mine house.");
                    break;

                case "startHm":
                    WorldGen.StartHardmode();
                    break;

                case "startHm2":
                    Main.hardMode = true;
                    Main.NewText("Enabled hardmode.");
                    break;

                case "stopHm":
                    Main.hardMode = false;
                    Main.NewText("Disabled hardmode.");
                    break;

                case "convertCorruption":
                    ConvertCorruption();
                    UpdateFrames();
                    break;

                case "convertHallow":
                    ConvertHallow();
                    UpdateFrames();
                    break;

                case "convertCorruptionNormal":
                    ConvertCorruptionNormal();
                    UpdateFrames();
                    break;

                case "convertHallowNormal":
                    ConvertHallowNormal();
                    UpdateFrames();
                    break;

                case "startGoblin":
                    Main.StartInvasion();
                    Main.NewText("Started a goblin invasion.");
                    break;

                case "startFrost":
                    Main.StartInvasion(2);
                    Main.NewText("Started a Frost Legion invasion.");
                    break;

                case "stopInvade":
                    Main.invasionSize = 0;
                    Main.NewText("Invasion has been stopped.");
                    break;

                case "xMas":
                    Main.xMas = xMas;
                    break;
                }
            }
            catch (Exception e)
            {
                Main.NewText("ERROR: " + e.Message, 255, 0, 0);
            }
        }
Exemple #3
0
        private bool PrivateReplenisher(GenType type, int amount, ushort oretype = 0, CommandArgs args = null)
        {
            int  counter = 0;
            bool success;

            for (int i = 0; i < TIMEOUT; i++)
            {
                success = false;
                int xRandBase = WorldGen.genRand.Next(1, Main.maxTilesX);
                int y         = 0;
                switch (type)
                {
                case GenType.ore:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    if (oretype != Terraria.ID.TileID.Hellstone)
                    {
                        WorldGen.OreRunner(xRandBase, y, 2.0, amount, oretype);
                    }
                    else
                    {
                        WorldGen.OreRunner(xRandBase, WorldGen.genRand.Next((int)(Main.maxTilesY) - 200, Main.maxTilesY), 2.0, amount, oretype);
                    }
                    success = true;
                    break;

                case GenType.chests:
                    if (amount == 0)
                    {
                        int tmpEmpty = 0, empty = 0;
                        for (int x = 0; x < 1000; x++)
                        {
                            if (Main.chest[x] != null)
                            {
                                tmpEmpty++;
                                bool found = false;
                                foreach (Item itm in Main.chest[x].item)
                                {
                                    if (itm.netID != 0)
                                    {
                                        found = true;
                                    }
                                }
                                if (found == false)
                                {
                                    empty++;
                                    WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, false, false, false);
                                    Main.chest[x] = null;
                                }
                            }
                        }
                        args.Player.SendSuccessMessage("Uprooted {0} empty out of {1} chests.", empty, tmpEmpty);
                        return(true);
                    }
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 200, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    success = WorldGen.AddBuriedChest(xRandBase, y);
                    break;

                case GenType.pots:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    success = WorldGen.PlacePot(xRandBase, y);
                    break;

                case GenType.lifecrystals:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    success = WorldGen.AddLifeCrystal(xRandBase, y);
                    break;

                case GenType.altars:
                    y = WorldGen.genRand.Next((int)(Main.worldSurface) - 12, Main.maxTilesY);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    WorldGen.Place3x2(xRandBase, y, 26);
                    success = Main.tile[xRandBase, y].type == 26;
                    break;

                case GenType.trees:
                    WorldGen.AddTrees();
                    success = true;
                    break;

                case GenType.floatingisland:
                    y = WorldGen.genRand.Next((int)Main.worldSurface + 175, (int)Main.worldSurface + 300);
                    if (TShock.Regions.InAreaRegion(xRandBase, y).Any() && !config.GenerateInProtectedAreas)
                    {
                        success = false;
                        break;
                    }
                    WorldGen.FloatingIsland(xRandBase, y);
                    success = true;
                    break;

                case GenType.pyramids:
                    //TODO
                    break;
                }
                if (success)
                {
                    counter++;
                    if (counter >= amount)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }