예제 #1
0
        public static Task AsyncGenerateWorld(int seed)
        {
            WorldRefill.isTaskRunning = true;
            WorldRefill.realcount     = 1;

            if (WorldRefill.config.UseInfiniteChests)
            {
                InfChestsDatabase WRConn = new InfChestsDatabase();
                WRConn.DeleteChests(Main.worldID);
            }

            WorldGen.clearWorld();

            return(Task.Run(() => WorldGen.GenerateWorld(seed)).ContinueWith((d) => FinishGen()));
        }
예제 #2
0
        private static Task AsyncRemoveEmptyChests()
        {
            return(Task.Run(() =>
            {
                WorldRefill.isTaskRunning = true;


                if (!WorldRefill.config.UseInfiniteChests)
                {
                    for (int x = 0; x < Main.chest.Length; x++)
                    {
                        if (Main.chest[x] != null)
                        {
                            bool found = false;
                            foreach (Item itm in Main.chest[x].item)
                            {
                                if (itm.netID != 0)
                                {
                                    found = true;
                                }
                            }
                            if (found == false)
                            {
                                WorldGen.KillTile(Main.chest[x].x, Main.chest[x].y, noItem: true);
                                Main.chest[x] = null;
                            }
                        }
                    }
                }
                else
                {
                    InfChestsDatabase WRConn = new InfChestsDatabase();

                    List <Point> EmpChestCoords = WRConn.PruneChests().Result;
                    foreach (Point point in EmpChestCoords)
                    {
                        WorldGen.KillTile(point.X, point.Y, noItem: true);
                    }
                }
            }));
        }
예제 #3
0
        private static void FinishGen()
        {
            WorldRefill.isTaskRunning = false;

            if (WorldRefill.realcount != 0)
            {
                foreach (TSPlayer player in TShock.Players)
                {
                    if (player != null)
                    {
                        NetMessage.PlayNetSound(new NetMessage.NetSoundInfo(player.TPlayer.position, 1, 0, 10, -16));
                    }
                }
            }
            if (WorldRefill.config.UseInfiniteChests && Main.chest.Where(p => p != null).Count() > 0)
            {
                InfChestsDatabase WRConn = new InfChestsDatabase();
                WRConn.AddChests();
                WRConn.Dispose();
                TShock.Utils.SaveWorld();
            }
        }