Exemple #1
0
 public static void DoTrees()
 {
     for (int i = 0; (double)i < (double)Main.maxTilesX * 0.001; i++)
     {
         int num  = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
         int num2 = WorldGen.genRand.Next(25, 50);
         for (int j = num - num2; j < num + num2; j++)
         {
             for (int k = 20; (double)k < Main.worldSurface; k++)
             {
                 if (!IsProtected(num, num2))
                 {
                     WorldGen.GrowEpicTree(j, k);
                 }
             }
         }
     }
     WorldGen.AddTrees();
     TSPlayer.All.SendMessage("[i:27] [c/595959:;] [c/996633:Drzewa] [c/595959:;] Wygenerowano nowe drzewa.", new Color(210, 166, 121));
 }
Exemple #2
0
        public static Task AsyncGenerateTrees()
        {
            WorldRefill.isTaskRunning = true;
            //int count = 0;
            //for (int counter = 0; counter < Main.maxTilesX * 0.003; counter++)
            //{
            //    int tryX = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
            //    int tryY = WorldGen.genRand.Next(25, 50);
            //    for (var tick = tryX - tryY; tick < tryX + tryY; tick++)
            //    {

            //        for (int offset = 20; offset < Main.worldSurface; offset++)
            //        {
            //            WorldGen.GrowEpicTree(tick, offset);
            //            count++;
            //        }
            //    }
            //}
            WorldGen.AddTrees();
            return(Task.Run(() => { WorldRefill.isTaskRunning = false; }));
        }
Exemple #3
0
        public static Task AsyncGenerateTrees()
        {
            WorldRefill.isTaskRunning = true;
            WorldRefill.realcount     = 1;

            for (int counter = 0; counter < Main.maxTilesX * 0.003; counter++)
            {
                int tryX = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
                int tryY = WorldGen.genRand.Next(25, 50);
                for (var tick = tryX - tryY; tick < tryX + tryY; tick++)
                {
                    for (int offset = 20; offset < Main.worldSurface; offset++)
                    {
                        if (!WorldRefill.IsProtected(tryX, tryY))
                        {
                            WorldGen.GrowEpicTree(tick, offset);
                        }
                    }
                }
            }
            return(Task.Run(() => WorldGen.AddTrees()).ContinueWith((d) => FinishGen()));
        }
Exemple #4
0
        private void DoTrees(CommandArgs args)
        {
            var counter = 0;

            while ((double)counter < (double)Main.maxTilesX * 0.003)
            {
                int tryX = WorldGen.genRand.Next(50, Main.maxTilesX - 50);
                int tryY = WorldGen.genRand.Next(25, 50);
                for (var tick = tryX - tryY; tick < tryX + tryY; tick++)
                {
                    var offset = 20;
                    while ((double)offset < Main.worldSurface)
                    {
                        WorldGen.GrowEpicTree(tick, offset);
                        offset++;
                    }
                }
                counter++;
            }
            WorldGen.AddTrees();
            args.Player.SendSuccessMessage("Enjoy your trees.");
            InformPlayers();
        }
Exemple #5
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);
        }