Esempio n. 1
0
        private void reset(CommandArgs args)
        {
            if (args.Parameters.Count != 0)
            {
                int second = int.Parse(args.Parameters[0]);
                for (int i = 0; i < second; i++)
                {
                    TShock.Utils.Broadcast("服务器即将重置,倒计时:" + (second - i), Color.Red);
                    Thread.Sleep(1000);
                }
            }
            //Kick all players
            status = Status.Cleaning;
            Main.WorldFileMetadata = null;
            foreach (var player in TShock.Players)
            {
                if (player != null)
                //player.Kick("服务器正在重置,请稍后进入", true);
                {
                    //TShock.Utils.Kick(player, "服务器正在重置,请稍后进入", true);
                    player.Disconnect("服务器正在重置,请稍后进入");
                }
            }

            //Reset World Map
            Main.gameMenu = true;
            //Main.serverGenLock = true;
            generationProgress = new GenerationProgress();
            Task task = WorldGen.CreateNewWorld(generationProgress);

            status = Status.Generating;

            while (!task.IsCompleted)//Main.serverGenLock)
            {
                TShock.Log.ConsoleInfo(GetProgress());
                Thread.Sleep(100);
            }
            //Reload world map
            status    = Status.Cleaning;
            Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
            WorldFile.LoadWorld(false);
            Main.dayTime    = WorldFile._tempDayTime;
            Main.time       = WorldFile._tempTime;
            Main.raining    = WorldFile._tempRaining;
            Main.rainTime   = WorldFile._tempRainTime;
            Main.maxRaining = WorldFile._tempMaxRain;
            Main.cloudAlpha = WorldFile._tempMaxRain;
            Main.moonPhase  = WorldFile._tempMoonPhase;
            Main.bloodMoon  = WorldFile._tempBloodMoon;
            Main.eclipse    = WorldFile._tempEclipse;

            //Reset player data
            TShock.DB.Query("DELETE FROM tsCharacter", Array.Empty <object>());

            //Reset status to playing
            Main.gameMenu      = false;
            generationProgress = null;
            status             = Status.Available;
        }
        public override void Load()
        {
            Tuple <List <int>, bool, string> conf = WorldGenSeedSearch.readConfigFile();

            if (conf.Item2 == true)
            {
                Main.menuMode = 10; //does not work
                WorldGen.CreateNewWorld(null);
            }
        }
Esempio n. 3
0
        private void FinishCreatingWorld()
        {
            ProcessSeed(out var processedSeed);
            switch (_optionSize)
            {
            case WorldSizeId.Small:
                Main.maxTilesX = 4200;
                Main.maxTilesY = 1200;
                break;

            case WorldSizeId.Medium:
                Main.maxTilesX = 6400;
                Main.maxTilesY = 1800;
                break;

            case WorldSizeId.Large:
                Main.maxTilesX = 8400;
                Main.maxTilesY = 2400;
                break;
            }
            WorldGen.setWorldSize();
            switch (_optionDifficulty)
            {
            case WorldDifficultyId.Creative:
                Main.GameMode = 3;
                break;

            case WorldDifficultyId.Normal:
                Main.GameMode = 0;
                break;

            case WorldDifficultyId.Expert:
                Main.GameMode = 1;
                break;

            case WorldDifficultyId.Master:
                Main.GameMode = 2;
                break;
            }
            switch (_optionEvil)
            {
            case WorldEvilId.Random:
                WorldGen.WorldGenParam_Evil = -1;
                break;

            case WorldEvilId.Corruption:
                WorldGen.WorldGenParam_Evil = 0;
                break;

            case WorldEvilId.Crimson:
                WorldGen.WorldGenParam_Evil = 1;
                break;
            }
            Main.ActiveWorldFileData = WorldFile.CreateMetadata(Main.worldName = _optionwWorldName.Trim(), SocialAPI.Cloud != null && SocialAPI.Cloud.EnabledByDefault, Main.GameMode);
            if (processedSeed.Length == 0)
            {
                Main.ActiveWorldFileData.SetSeedToRandom();
            }
            else
            {
                Main.ActiveWorldFileData.SetSeed(processedSeed);
            }
            Main.menuMode = 10;
            WorldGen.CreateNewWorld();
        }
Esempio n. 4
0
        public void PutMeInAWorld()
        {
            var config = ModContent.GetInstance <Config>();

            WorldGen.gen = true;
            WorldFileData temp = new WorldFileData(ModLoader.ModPath + "/TempWorld", false);

            temp.SetAsActive();

            if (config.size == WorldSize.small)
            {
                temp.SetWorldSize(4200, 1200);
                Main.maxTilesX = 4200;
                Main.maxTilesY = 1200;
                Main.tile      = new Tile[4200, 1200];
            }

            if (config.size == WorldSize.medium)
            {
                temp.SetWorldSize(6400, 1800);
                Main.maxTilesX = 6400;
                Main.maxTilesY = 1800;
                Main.tile      = new Tile[6400, 1800];
            }

            if (config.size == WorldSize.large)
            {
                temp.SetWorldSize(8400, 2400);
                Main.maxTilesX = 8400;
                Main.maxTilesY = 2400;
                Main.tile      = new Tile[8400, 2400];
            }

            if (config.size == WorldSize.custom)
            {
                temp.SetWorldSize(config.customWidth, config.customHeight);
                Main.maxTilesX = config.customWidth;
                Main.maxTilesY = config.customHeight;
                Main.tile      = new Tile[config.customWidth, config.customHeight];
            }

            if (config.evil == Evil.corruption)
            {
                temp.HasCrimson = false;
            }
            if (config.evil == Evil.crimson)
            {
                temp.HasCrimson = true;
            }

            temp.IsExpertMode = config.expert;
            Main.expertMode   = config.expert;

            if (config.seed == "" || config.seed is null)
            {
                temp.SetSeedToRandom();
            }
            else
            {
                temp.SetSeed(config.seed);
            }

            Main.ActiveWorldFileData = temp;

            WorldGen.CreateNewWorld();
        }
Esempio n. 5
0
        private void OnNpcKilled(NpcKilledEventArgs args)
        {
            if (args.npc.type != NPCID.MoonLordCore)
            {
                return;
            }
            if (--Count > 0)
            {
                TShock.Utils.Broadcast($"离重置地图还需要击败{Count}次月球领主", 0, 255, 255);
                return;
            }

            //Kick all players
            status = Status.Cleaning;
            Main.WorldFileMetadata = null;
            foreach (var player in TShock.Players)
            {
                if (player != null)
                //player.Kick("服务器正在重置,请稍后进入", true);
                {
                    //TShock.Utils.Kick(player, "服务器正在重置,请稍后进入", true);
                    player.Disconnect("服务器正在重置,请稍后进入,重置进度:");
                }
            }

            //Reset World Map
            Main.gameMenu = true;
            //Main.serverGenLock = true;
            Main.autoGen       = true;
            generationProgress = new GenerationProgress();
            WorldGen.CreateNewWorld(generationProgress);
            status = Status.Generating;

            while (Main.autoGen) //Main.serverGenLock)
            {
                TShock.Log.ConsoleInfo(GetProgress());
                Thread.Sleep(100);
            }

            //Reload world map
            status    = Status.Cleaning;
            Main.rand = new UnifiedRandom((int)DateTime.Now.Ticks);
            WorldFile.LoadWorld(false);
            Main.dayTime    = WorldFile._tempDayTime;
            Main.time       = WorldFile._tempTime;
            Main.raining    = WorldFile._tempRaining;
            Main.rainTime   = WorldFile._tempRainTime;
            Main.maxRaining = WorldFile._tempMaxRain;
            Main.cloudAlpha = WorldFile._tempMaxRain;
            Main.moonPhase  = WorldFile._tempMoonPhase;
            Main.bloodMoon  = WorldFile._tempBloodMoon;
            Main.eclipse    = WorldFile._tempEclipse;

            //Reset player data
            TShock.DB.Query("DELETE FROM tsCharacter", Array.Empty <object>());

            //Reset status to playing
            Main.gameMenu      = false;
            generationProgress = null;
            status             = Status.Available;
        }