コード例 #1
0
        public static void Replace(Level old, Level lvl)
        {
            LevelDB.SaveBlockDB(old);
            LevelInfo.Remove(old);
            LevelInfo.Add(lvl);

            old.SetPhysics(0);
            old.ClearPhysics();
            lvl.StartPhysics();

            Player[] players = PlayerInfo.Online.Items;
            foreach (Player pl in players)
            {
                if (pl.level != old)
                {
                    continue;
                }
                pl.level = lvl;
                ReloadFor(Player.Console, pl, false);
            }

            old.Unload(true, false);
            if (old == Server.mainLevel)
            {
                Server.mainLevel = lvl;
            }
        }
コード例 #2
0
        static void GenerateMain()
        {
            Logger.Log(LogType.SystemActivity, "main level not found, generating..");
            mainLevel = new Level(Server.Config.MainLevel, 128, 64, 128);

            MapGen.Find("Flat").Generate(Player.Console, mainLevel, "");
            mainLevel.Save();
            LevelInfo.Add(mainLevel);
        }
コード例 #3
0
        public static Level Load(Player p, string map, bool announce)
        {
            map = map.ToLower();
            if (!LevelInfo.MapExists(map))
            {
                p.Message("Level \"{0}\" does not exist", map); return(null);
            }

            Level cur = LevelInfo.FindExact(map);

            if (cur != null)
            {
                p.Message("%WLevel {0} %Wis already loaded.", cur.ColoredName); return(null);
            }

            try {
                Level lvl = ReadLevel(p, map);
                if (lvl == null || !lvl.CanJoin(p))
                {
                    return(null);
                }

                cur = LevelInfo.FindExact(map);
                if (cur != null)
                {
                    p.Message("%WLevel {0} %Wis already loaded.", cur.ColoredName); return(null);
                }

                LevelInfo.Add(lvl);
                if (!announce)
                {
                    return(lvl);
                }

                string autoloadMsg = "Level " + lvl.ColoredName + " %Sloaded.";
                Chat.Message(ChatScope.All, autoloadMsg, null, Chat.FilterVisible(p));
                return(lvl);
            } finally {
                Server.DoGC();
            }
        }