예제 #1
0
        static void JoinMuseum(Player p, string formattedMuseumName, string mapName, string path)
        {
            Level lvl = IMapImporter.GetFor(path).Read(path, formattedMuseumName, false);

            lvl.MapName = mapName;

            SetLevelProps(lvl);
            Level.LoadMetadata(lvl);
            PlayerActions.ChangeMap(p, lvl);
        }
예제 #2
0
        static void ImportFrom(Player p, Stream src, string path)
        {
            IMapImporter imp = IMapImporter.GetFor(path);

            if (imp == null)
            {
                string formats = IMapImporter.Formats.Join(x => x.Extension);
                p.Message("&WCannot import {0} as only {1} formats are supported.", path, formats);
                return;
            }

            string map = Path.GetFileNameWithoutExtension(path);

            Import(p, imp, src, map);
        }
예제 #3
0
        bool DoRestore(Player p, Vec3S32[] marks, object state, BlockID block)
        {
            string path   = (string)state;
            Level  source = IMapImporter.GetFor(path).Read(path, "templevel", false);

            RestoreSelectionDrawOp op = new RestoreSelectionDrawOp();

            op.Source = source;
            if (DrawOpPerformer.Do(op, null, p, marks))
            {
                return(false);
            }

            // Not high enough draw limit
            source.Dispose();
            return(false);
        }
예제 #4
0
            public void FromMap(string map)
            {
                this.Name = map; MapName = map;
                string  path = LevelInfo.MapPath(map);
                Vec3U16 dims = IMapImporter.GetFor(path).ReadDimensions(path);

                Width          = dims.X; Height = dims.Y; Length = dims.Z;
                BlockDBEntries = BlockDBFile.CountEntries(map);

                path = LevelInfo.PropsPath(map);
                LevelConfig cfg = new LevelConfig();

                cfg.Load(path);

                Config = cfg;
                Visit  = new LevelAccessController(cfg, map, true);
                Build  = new LevelAccessController(cfg, map, false);
            }
예제 #5
0
        public static Level Load(string name, string path)
        {
            bool cancel = false;

            OnLevelLoadEvent.Call(name, path, ref cancel);
            if (cancel)
            {
                return(null);
            }

            if (!File.Exists(path))
            {
                Logger.Log(LogType.Warning, "Attempted to load level {0}, but {1} does not exist.", name, path);
                return(null);
            }

            try {
                Level lvl = IMapImporter.GetFor(path).Read(path, name, true);
                lvl.backedup = true;
                LoadMetadata(lvl);
                BotsFile.Load(lvl);

                object locker = ThreadSafeCache.DBCache.GetLocker(name);
                lock (locker) {
                    LevelDB.LoadZones(lvl, name);
                    LevelDB.LoadPortals(lvl, name);
                    LevelDB.LoadMessages(lvl, name);
                }

                Logger.Log(LogType.SystemActivity, "Level \"{0}\" loaded.", lvl.name);
                OnLevelLoadedEvent.Call(lvl);
                return(lvl);
            } catch (Exception ex) {
                Logger.LogError("Error loading map from " + path, ex);
                return(null);
            }
        }