public static void Reload()
        {
            // ChapterSelect only updates the ID.
            string lastAreaSID = AreaData.Get(SaveData.Instance.LastArea.ID)?.ToKey().GetSID() ?? AreaKey.Default.GetSID();

            // Note: SaveData.Instance.LastArea is reset by AreaData.Interlude_Safe -> SaveData.LevelSetStats realizing that AreaOffset == -1
            // Store the "resolved" last selected area in a local variable, then re-set it after reloading.

            // Reload all maps.
            Everest.Content.Recrawl();
            AreaData.Unload();
            AreaData.Load();
            AreaData.ReloadMountainViews();

            // Fake a save data reload to resync the save data to the new area list.
            AreaData lastArea = AreaDataExt.Get(lastAreaSID);

            SaveData.Instance.LastArea = lastArea?.ToKey() ?? AreaKey.Default;
            SaveData.Instance.BeforeSave();
            SaveData.Instance.AfterInitialize();

            Overworld overworld = (Engine.Scene.Entities.FindFirst <Oui>())?.Overworld;

            if (overworld == null)
            {
                return;
            }
            if (overworld.Mountain.Area >= AreaData.Areas.Count)
            {
                overworld.Mountain.EaseCamera(0, AreaData.Areas[0].MountainIdle, null, true);
            }
            overworld.ReloadMenus((Overworld.StartMode)(-1));
        }
Beispiel #2
0
        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            if (!inGame)
            {
                if (Everest.Updater.HasUpdate)
                {
                    menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_update").Replace("((version))", Everest.Updater.Newest.Version.ToString())).Pressed(() => {
                        Everest.Updater.Update(OuiModOptions.Instance.Overworld.Goto <OuiLoggedProgress>());
                    }));
                }

                // Allow downgrading travis / dev builds.
                if (Celeste.PlayMode == Celeste.PlayModes.Debug || Everest.VersionSuffix.StartsWith("travis-") || Everest.VersionSuffix == "dev")
                {
                    menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_versionlist")).Pressed(() => {
                        OuiModOptions.Instance.Overworld.Goto <OuiVersionList>();
                    }));
                }
            }

            base.CreateModMenuSection(menu, inGame, snapshot);

            menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_recrawl")).Pressed(() => {
                Everest.Content.Recrawl();
                Everest.Content.Reprocess();
                VirtualContentExt.ForceReload();
                AreaData.Load();
            }));
        }
        void Start()
        {
            Debug.Log("==读取GamePlay的Texture");
            Gfx.Game        = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
            foregroundTiles = new Tiles(Path.Combine(Util.GAME_PATH_CONTENT, Path.Combine("Graphics", "ForegroundTiles.xml")));
            backgroundTiles = new Tiles(Path.Combine(Util.GAME_PATH_CONTENT, Path.Combine("Graphics", "BackgroundTiles.xml")));
            AreaData.Load();
            Stage stage = new Stage(0, AreaMode.Normal);

            stage.Load();

            //生成地图数据
            Autotiler.Behaviour fgBehaviour = new Autotiler.Behaviour()
            {
                EdgesExtend             = true,
                EdgesIgnoreOutOfLevel   = false,
                PaddingIgnoreOutOfLevel = true
            };
            Autotiler.Behaviour bgBehaviour = new Autotiler.Behaviour()
            {
                EdgesExtend             = true,
                EdgesIgnoreOutOfLevel   = false,
                PaddingIgnoreOutOfLevel = false
            };
            VirtualMap <char> foregroundData = stage.ForegroundData;

            this.colliderGrid = new ColliderGrid(foregroundData.Columns, foregroundData.Rows, 8f, 8f);
            for (int x = 0; x < foregroundData.Columns; x += 50)
            {
                for (int y = 0; y < foregroundData.Rows; y += 50)
                {
                    if (foregroundData.AnyInSegmentAtTile(x, y))
                    {
                        int index1 = x;
                        for (int index2 = Math.Min(index1 + 50, foregroundData.Columns); index1 < index2; ++index1)
                        {
                            int index3 = y;
                            for (int index4 = Math.Min(index3 + 50, foregroundData.Rows); index3 < index4; ++index3)
                            {
                                if (foregroundData[index1, index3] != '0')
                                {
                                    this.colliderGrid[index1, index3] = true;
                                }
                                else
                                {
                                    this.colliderGrid[index1, index3] = false;
                                }
                            }
                        }
                    }
                }
            }
            //VirtualMap<char> backgroundData = stage.BackgroundData;
            foregroundTiles.GenerateTiles(this.fgTilemap, foregroundData, 0, 0, foregroundData.Columns, foregroundData.Rows, false, '0', fgBehaviour, colliderGrid);
            //bgTileDictionary.GenerateTiles(this.bgTilemap, backgroundData, 0, 0, backgroundData.Columns, backgroundData.Rows, false, '0', bgBehaviour);
        }
Beispiel #4
0
        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            base.CreateModMenuSection(menu, inGame, snapshot);

            menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_recrawl")).Pressed(() => {
                Everest.Content.Recrawl();
                Everest.Content.Reprocess();
                VirtualContentExt.ForceReload();
                AreaData.Load();
            }));
        }
Beispiel #5
0
        public static void Reload(bool recrawl)
        {
            SaveData saveData = SaveData.Instance;

            // ChapterSelect only updates the ID.
            string lastAreaSID = saveData == null ? null : (AreaData.Get(saveData.LastArea.ID)?.ToKey().GetSID() ?? AreaKey.Default.GetSID());

            // Note: SaveData.Instance.LastArea is reset by AreaData.Interlude_Safe -> SaveData.LevelSetStats realizing that AreaOffset == -1
            // Store the "resolved" last selected area in a local variable, then re-set it after reloading.

            // Reload all maps.
            if (recrawl)
            {
                Everest.Content.Recrawl();
            }

            lock (AreaReloadLock) { // prevent anything from calling AreaData.Get during this.
                AreaData.Unload();
                AreaData.Load();
                AreaData.ReloadMountainViews();

                // Fake a save data reload to resync the save data to the new area list.
                if (saveData != null)
                {
                    AreaData lastArea = AreaDataExt.Get(lastAreaSID);
                    saveData.LastArea = lastArea?.ToKey() ?? AreaKey.Default;
                    saveData.BeforeSave();
                    saveData.AfterInitialize();
                }
            }

            if (Engine.Scene is Overworld overworld)
            {
                if (overworld.Mountain.Area >= AreaData.Areas.Count)
                {
                    overworld.Mountain.EaseCamera(0, AreaData.Areas[0].MountainIdle, null, true);
                }

                OuiChapterSelect chapterSelect = overworld.GetUI <OuiChapterSelect>();
                overworld.UIs.Remove(chapterSelect);
                overworld.Remove(chapterSelect);

                chapterSelect         = new OuiChapterSelect();
                chapterSelect.Visible = false;
                overworld.Add(chapterSelect);
                overworld.UIs.Add(chapterSelect);
                chapterSelect.IsStart(overworld, (Overworld.StartMode)(-1));
            }
        }
Beispiel #6
0
        private void LoadThread()
        {
            Console.WriteLine("GAME DISPLAYED : " + Stopwatch.ElapsedMilliseconds + "ms");
            MInput.Disabled = true;

            Audio.Init();

            // Original code loads audio banks here.

            /*
             * Audio.Banks.Master = Audio.Banks.Load("Master Bank", true);
             * Audio.Banks.Music = Audio.Banks.Load("music", false);
             * Audio.Banks.Sfxs = Audio.Banks.Load("sfx", false);
             * Audio.Banks.UI = Audio.Banks.Load("ui", false);
             * Audio.Banks.NewContent = Audio.Banks.Load("new_content", false);
             */

            Settings.Instance.ApplyVolumes();
            audioLoaded = true;

            Fonts.Load(); // Luckily, the textures for the fonts are preloaded.
            Dialog.Load();
            dialogLoaded = true;

            MInput.Disabled = false;

            if (!GFX.LoadedMainContent)
            {
                throw new Exception("GFX not loaded!");
            }
            GFX.LoadData(); // Load all related GFX metadata.

            AreaData.Load();

            if (!CoreModule.Settings.NonThreadedGL)
            {
                GFX.MountainTerrain   = ObjModel.Create(Path.Combine(Engine.ContentDirectory, "Overworld", "mountain.obj"));
                GFX.MountainBuildings = ObjModel.Create(Path.Combine(Engine.ContentDirectory, "Overworld", "buildings.obj"));
                GFX.MountainCoreWall  = ObjModel.Create(Path.Combine(Engine.ContentDirectory, "Overworld", "mountain_wall.obj"));
            }
            // Otherwise loaded in CoreModule.LoadContent

            Console.WriteLine("LOADED : " + Stopwatch.ElapsedMilliseconds + "ms");
            Stopwatch.Stop();
            Stopwatch = null;
            loaded    = true;
        }
Beispiel #7
0
        private void LoadThread()
        {
            MInput.Disabled        = true;
            MainThreadHelper.Boost = 25;
            Stopwatch timer = Stopwatch.StartNew();

            Audio.Init();
            // Original code loads audio banks here.
            Settings.Instance.ApplyVolumes();
            audioLoaded = true;
            Console.WriteLine(" - AUDIO LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();

            GFX.Load();
            MTN.Load();
            GFX.LoadData();
            MTN.LoadData();

            timer = Stopwatch.StartNew();
            Fonts.Prepare();
            Dialog.Load();
            Fonts.Load(Dialog.Languages["english"].FontFace);
            Fonts.Load(Dialog.Languages[Settings.Instance.Language].FontFace);
            dialogLoaded = true;
            Console.WriteLine(" - DIA/FONT LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();
            MInput.Disabled = false;

            timer = Stopwatch.StartNew();
            AreaData.Load();
            Console.WriteLine(" - LEVELS LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();

            timer = Stopwatch.StartNew();
            MainThreadHelper.Boost = 50;
            patch_VirtualTexture.WaitFinishFastTextureLoading();
            MainThreadHelper.Get(() => MainThreadHelper.Boost = 0).GetResult();
            // FIXME: There could be ongoing tasks which add to the main thread queue right here.
            Console.WriteLine(" - FASTTEXTURELOADING LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();

            Console.WriteLine("DONE LOADING (in " + Celeste.LoadTimer.ElapsedMilliseconds + "ms)");
            Celeste.LoadTimer.Stop();
            Celeste.LoadTimer = null;
            loaded            = true;
        }
Beispiel #8
0
        private void LoadThread()
        {
            MInput.Disabled = true;
            Stopwatch timer = Stopwatch.StartNew();

            Audio.Init();
            // Original code loads audio banks here.
            Settings.Instance.ApplyVolumes();
            audioLoaded = true;
            Console.WriteLine(" - AUDIO LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();

            if (!CoreModule.Settings.NonThreadedGL)
            {
                GFX.Load();
                MTN.Load();
                GFX.LoadData();
                MTN.LoadData();
            }
            // Otherwise loaded in CoreModule.LoadContent

            timer = Stopwatch.StartNew();
            Fonts.Prepare();
            Dialog.Load();
            Fonts.Load(Dialog.Languages["english"].FontFace);
            Fonts.Load(Dialog.Languages[Settings.Instance.Language].FontFace);
            dialogLoaded = true;
            Console.WriteLine(" - DIA/FONT LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();
            MInput.Disabled = false;

            timer = Stopwatch.StartNew();
            AreaData.Load();
            Console.WriteLine(" - LEVELS LOAD: " + timer.ElapsedMilliseconds + "ms");
            timer.Stop();

            Console.WriteLine("DONE LOADING (in " + Celeste.LoadTimer.ElapsedMilliseconds + "ms)");
            Celeste.LoadTimer.Stop();
            Celeste.LoadTimer = null;
            loaded            = true;
        }
Beispiel #9
0
        public void Start()
        {
            //读取GamePlay的MTexture文件
            Debug.Log("==读取GamePlay的Texture");
            Gfx.Game        = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
            Gfx.BGAutotiler = new Autotiler(Path.Combine("Graphics", "BackgroundTiles.xml"));
            Gfx.FGAutotiler = new Autotiler(Path.Combine("Graphics", "ForegroundTiles.xml"));

            //Gfx.SceneryTiles = new Tileset(Gfx.Game["tilesets/scenery"], 8, 8);
            //Gfx.AnimatedTilesBank = new AnimatedTilesBank();
            //foreach (XmlElement xml in (XmlNode)XmlUtils.LoadContentXML(Path.Combine("Graphics", "AnimatedTiles.xml"))["Data"])
            //{
            //    if (xml != null)
            //        Gfx.AnimatedTilesBank.Add(xml.Attr("name"), xml.AttrFloat("delay", 0.0f), xml.AttrVector2("posX", "posY", Vector2.zero), xml.AttrVector2("origX", "origY", Vector2.zero), Gfx.Game.GetAtlasSubtextures(xml.Attr("path")));
            //}
            Debug.Log("==加载AreaData文件");
            SaveData.Start(new SaveData
            {
                Name        = "test001",
                AssistMode  = true,
                VariantMode = true
            }, 0);
            //加载区域
            AreaData.Load();

            Debug.Log("==创建Session,读取关卡地图");
            Session session = new Session(new AreaKey(0, AreaMode.Normal), null, null);
            bool    flag    = level != null && session.MapData.Get(level) != null;

            if (flag)
            {
                session.Level      = level;
                session.FirstLevel = false;
            }

            Debug.Log("==加载关卡LevelLoad");
            LevelLoader loader = new LevelLoader(session, null);

            //StartCoroutine(DrawTiles(loader.Level.BgTiles.Tiles));
            StartCoroutine(DrawTiles(loader.solidTiles.Tiles));
        }
Beispiel #10
0
        static bool LoadAreaFiles()
        {
            string listContents;

            try
            {
                listContents = Encoding.ASCII.GetString(File.ReadAllBytes(Path.Combine(areaPath, areaList)));
            }
            catch (Exception e)
            {
                log.Error(e.Message);
                return(false);
            }

            using (var sr = new StringReader(listContents))
            {
                for (;;)
                {
                    var curFile = sr.ReadLine().Trim();
                    if (string.IsNullOrWhiteSpace(curFile))
                    {
                        continue;
                    }
                    if (curFile.StartsWith("$"))
                    {
                        break;
                    }

                    if (curFile.StartsWith("-"))
                    {
                        // ??????
                        // fpArea = stdin;
                        continue;
                    }

                    log.Info($"loadding {curFile}");
                    string areaContents;
                    try
                    {
                        areaContents = Encoding.ASCII.GetString(File.ReadAllBytes(Path.Combine(areaPath, curFile)));
                    }
                    catch (Exception e)
                    {
                        log.Error(e.Message);
                        return(false);
                    }


                    using (var ar = new StringReader(areaContents))
                    {
                        AreaData lastArea = null;
                        for (;;)
                        {
                            var word = ar.ReadWord();
                            if (!word.StartsWith("#"))
                            {
                                return(false);
                            }

                            word = word.Substring(1);
                            if (word.StartsWith("$"))
                            {
                                break;
                            }

                            switch (word)
                            {
                            case "AREA":
                                lastArea = AreaData.Load(ar, curFile);
                                break;

                            case "HELPS":
                                HelpData.LoadFromArea(ar);
                                break;

                            case "MOBILES":
                                MobileDef.LoadFromArea(ar, lastArea);
                                break;

                            case "OBJECTS":
                                ObjectDef.LoadFromArea(ar, lastArea);
                                break;

                            case "RESETS":
                                ResetData.LoadFromArea(ar);
                                break;

                            case "ROOMS":
                                RoomDef.LoadFromArea(ar, lastArea);
                                break;

                            case "SHOPS":
                                ShopData.LoadFromArea(ar);
                                break;

                            case "SPECIALS":
                                SpecType.LoadFromArea(ar);
                                break;

                            // OLC
                            case "AREADATA":
                                lastArea = AreaData.NewLoad(ar, curFile);
                                break;

                            // OLC 1.1b
                            case "ROOMDATA":
                                RoomDef.NewLoadFromArea(ar, lastArea);
                                break;

                            default:
                                log.Error($"Boot_db: bad section name '{word}'.");
                                return(false);
                            }
                        }
                    }
                }

                return(true);
            }
        }
Beispiel #11
0
        public override void CreateModMenuSection(TextMenu menu, bool inGame, EventInstance snapshot)
        {
            if (!inGame)
            {
                if (Everest.Updater.HasUpdate)
                {
                    menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_update").Replace("((version))", Everest.Updater.Newest.Version.ToString())).Pressed(() => {
                        Everest.Updater.Update(OuiModOptions.Instance.Overworld.Goto <OuiLoggedProgress>());
                    }));
                }

                // Allow downgrading travis / dev builds.
                if (Celeste.PlayMode == Celeste.PlayModes.Debug || Everest.VersionSuffix.StartsWith("travis-") || Everest.VersionSuffix == "dev")
                {
                    menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_versionlist")).Pressed(() => {
                        OuiModOptions.Instance.Overworld.Goto <OuiVersionList>();
                    }));
                }
            }

            base.CreateModMenuSection(menu, inGame, snapshot);

            // Get all Input GUI prefixes and add a slider for switching between them.
            List <string> inputGuiPrefixes = new List <string>();

            inputGuiPrefixes.Add(""); // Auto
            foreach (KeyValuePair <string, MTexture> kvp in GFX.Gui.GetTextures())
            {
                string path = kvp.Key;
                if (!path.StartsWith("controls/"))
                {
                    continue;
                }
                path = path.Substring(9);
                int indexOfSlash = path.IndexOf('/');
                if (indexOfSlash == -1)
                {
                    continue;
                }
                path = path.Substring(0, indexOfSlash);
                if (!inputGuiPrefixes.Contains(path))
                {
                    inputGuiPrefixes.Add(path);
                }
            }

            menu.Add(
                new TextMenu.Slider(Dialog.Clean("modoptions_coremodule_inputgui"), i => {
                string inputGuiPrefix = inputGuiPrefixes[i];
                string fullName       = $"modoptions_coremodule_inputgui_{inputGuiPrefix.ToLowerInvariant()}";
                return(fullName.DialogCleanOrNull() ?? inputGuiPrefix.ToUpperInvariant());
            }, 0, inputGuiPrefixes.Count - 1, Math.Max(0, inputGuiPrefixes.IndexOf(Settings.InputGui)))
                .Change(i => {
                Settings.InputGui         = inputGuiPrefixes[i];
                Input.OverrideInputPrefix = inputGuiPrefixes[i];
            })
                );

            if (Celeste.PlayMode == Celeste.PlayModes.Debug)
            {
                menu.Add(new TextMenu.Button(Dialog.Clean("modoptions_coremodule_recrawl")).Pressed(() => {
                    Everest.Content.Recrawl();
                    Everest.Content.Reprocess();
                    VirtualContentExt.ForceReload();
                    AreaData.Load();
                }));
            }
        }
Beispiel #12
0
    void Start()
    {
        //读取配置文件
        Gfx.Game = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Gameplay"), Atlas.AtlasDataFormat.Packer);
        Gfx.Misc = Atlas.FromAtlas(Path.Combine("Graphics", "Atlases", "Misc"), Atlas.AtlasDataFormat.PackerNoAtlas);

        Gfx.SceneryTiles = new Tileset(Gfx.Game["tilesets/scenery"], 8, 8);
        //读取前景配置文件
        Gfx.BGAutotiler = new Autotiler(Path.Combine("Graphics", "BackgroundTiles.xml"));
        Gfx.FGAutotiler = new Autotiler(Path.Combine("Graphics", "ForegroundTiles.xml"));

        Debug.Log("==加载AreaData文件");
        SaveData.Start(new SaveData
        {
            Name        = "test001",
            AssistMode  = true,
            VariantMode = true
        }, 0);
        //加载区域
        AreaData.Load();

        Debug.Log("==创建Session,读取关卡地图");

        Session session = new Session(new AreaKey(0, AreaMode.Normal), null, null);

        MapData   mapData   = session.MapData;
        LevelData levelData = mapData.Levels[0];

        Debug.Log(levelData);

        Rectangle         tileBounds1 = mapData.TileBounds;
        VirtualMap <char> data1       = new VirtualMap <char>(tileBounds1.Width, tileBounds1.Height, '0');
        VirtualMap <char> data2       = new VirtualMap <char>(tileBounds1.Width, tileBounds1.Height, '0');
        VirtualMap <bool> virtualMap  = new VirtualMap <bool>(tileBounds1.Width, tileBounds1.Height, false);
        Regex             regex       = new Regex("\\r\\n|\\n\\r|\\n|\\r");

        foreach (LevelData level in mapData.Levels)
        {
            Rectangle tileBounds2 = level.TileBounds;
            int       left1       = tileBounds2.Left;
            tileBounds2 = level.TileBounds;
            int      top1      = tileBounds2.Top;
            string[] strArray1 = regex.Split(level.Bg);
            for (int index1 = top1; index1 < top1 + strArray1.Length; ++index1)
            {
                for (int index2 = left1; index2 < left1 + strArray1[index1 - top1].Length; ++index2)
                {
                    data1[index2 - tileBounds1.X, index1 - tileBounds1.Y] = strArray1[index1 - top1][index2 - left1];
                }
            }

            string[] strArray2 = regex.Split(level.Solids);
            for (int index1 = top1; index1 < top1 + strArray2.Length; ++index1)
            {
                for (int index2 = left1; index2 < left1 + strArray2[index1 - top1].Length; ++index2)
                {
                    data2[index2 - tileBounds1.X, index1 - tileBounds1.Y] = strArray2[index1 - top1][index2 - left1];
                }
            }
            tileBounds2 = level.TileBounds;
            int left2 = tileBounds2.Left;
            while (true)
            {
                int num1 = left2;
                tileBounds2 = level.TileBounds;
                int right = tileBounds2.Right;
                if (num1 < right)
                {
                    tileBounds2 = level.TileBounds;
                    int top2 = tileBounds2.Top;
                    while (true)
                    {
                        int num2 = top2;
                        tileBounds2 = level.TileBounds;
                        int bottom = tileBounds2.Bottom;
                        if (num2 < bottom)
                        {
                            virtualMap[left2 - tileBounds1.Left, top2 - tileBounds1.Top] = true;
                            ++top2;
                        }
                        else
                        {
                            break;
                        }
                    }
                    ++left2;
                }
                else
                {
                    break;
                }
            }
            Gfx.FGAutotiler.LevelBounds.Add(new Rectangle(level.TileBounds.X - tileBounds1.X, level.TileBounds.Y - tileBounds1.Y, level.TileBounds.Width, level.TileBounds.Height));
        }

        foreach (Rectangle rectangle in mapData.Filler)
        {
            for (int left = rectangle.Left; left < rectangle.Right; ++left)
            {
                for (int top = rectangle.Top; top < rectangle.Bottom; ++top)
                {
                    char ch1 = '0';
                    if (rectangle.Top - tileBounds1.Y > 0)
                    {
                        char ch2 = data2[left - tileBounds1.X, rectangle.Top - tileBounds1.Y - 1];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0' && rectangle.Left - tileBounds1.X > 0)
                    {
                        char ch2 = data2[rectangle.Left - tileBounds1.X - 1, top - tileBounds1.Y];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0' && rectangle.Right - tileBounds1.X < tileBounds1.Width - 1)
                    {
                        char ch2 = data2[rectangle.Right - tileBounds1.X, top - tileBounds1.Y];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0' && rectangle.Bottom - tileBounds1.Y < tileBounds1.Height - 1)
                    {
                        char ch2 = data2[left - tileBounds1.X, rectangle.Bottom - tileBounds1.Y];
                        if (ch2 != '0')
                        {
                            ch1 = ch2;
                        }
                    }
                    if (ch1 == '0')
                    {
                        ch1 = '1';
                    }
                    data2[left - tileBounds1.X, top - tileBounds1.Y]      = ch1;
                    virtualMap[left - tileBounds1.X, top - tileBounds1.Y] = true;
                }
            }
        }
        using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
        {
label_85:
            while (enumerator.MoveNext())
            {
                LevelData current     = enumerator.Current;
                Rectangle tileBounds2 = current.TileBounds;
                int       left1       = tileBounds2.Left;
                while (true)
                {
                    int num1 = left1;
                    tileBounds2 = current.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = current.TileBounds;
                        int  top = tileBounds2.Top;
                        char ch1 = data1[left1 - tileBounds1.X, top - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, top - tileBounds1.Y - index]; ++index)
                        {
                            data1[left1 - tileBounds1.X, top - tileBounds1.Y - index] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num2 = tileBounds2.Bottom - 1;
                        char ch2  = data1[left1 - tileBounds1.X, num2 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, num2 - tileBounds1.Y + index]; ++index)
                        {
                            data1[left1 - tileBounds1.X, num2 - tileBounds1.Y + index] = ch2;
                        }
                        ++left1;
                    }
                    else
                    {
                        break;
                    }
                }
                tileBounds2 = current.TileBounds;
                int num3 = tileBounds2.Top - 4;
                while (true)
                {
                    int num1 = num3;
                    tileBounds2 = current.TileBounds;
                    int num2 = tileBounds2.Bottom + 4;
                    if (num1 < num2)
                    {
                        tileBounds2 = current.TileBounds;
                        int  left2 = tileBounds2.Left;
                        char ch1   = data1[left2 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left2 - tileBounds1.X - index, num3 - tileBounds1.Y]; ++index)
                        {
                            data1[left2 - tileBounds1.X - index, num3 - tileBounds1.Y] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num4 = tileBounds2.Right - 1;
                        char ch2  = data1[num4 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[num4 - tileBounds1.X + index, num3 - tileBounds1.Y]; ++index)
                        {
                            data1[num4 - tileBounds1.X + index, num3 - tileBounds1.Y] = ch2;
                        }
                        ++num3;
                    }
                    else
                    {
                        goto label_85;
                    }
                }
            }
        }

        using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
        {
label_100:
            while (enumerator.MoveNext())
            {
                LevelData current     = enumerator.Current;
                Rectangle tileBounds2 = current.TileBounds;
                int       left        = tileBounds2.Left;
                while (true)
                {
                    int num1 = left;
                    tileBounds2 = current.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = current.TileBounds;
                        int top = tileBounds2.Top;
                        if (data2[left - tileBounds1.X, top - tileBounds1.Y] == '0')
                        {
                            for (int index = 1; index < 8; ++index)
                            {
                                virtualMap[left - tileBounds1.X, top - tileBounds1.Y - index] = true;
                            }
                        }
                        tileBounds2 = current.TileBounds;
                        int num2 = tileBounds2.Bottom - 1;
                        if (data2[left - tileBounds1.X, num2 - tileBounds1.Y] == '0')
                        {
                            for (int index = 1; index < 8; ++index)
                            {
                                virtualMap[left - tileBounds1.X, num2 - tileBounds1.Y + index] = true;
                            }
                        }
                        ++left;
                    }
                    else
                    {
                        goto label_100;
                    }
                }
            }
        }
        using (List <LevelData> .Enumerator enumerator = mapData.Levels.GetEnumerator())
        {
label_122:
            while (enumerator.MoveNext())
            {
                LevelData current     = enumerator.Current;
                Rectangle tileBounds2 = current.TileBounds;
                int       left1       = tileBounds2.Left;
                while (true)
                {
                    int num1 = left1;
                    tileBounds2 = current.TileBounds;
                    int right = tileBounds2.Right;
                    if (num1 < right)
                    {
                        tileBounds2 = current.TileBounds;
                        int  top = tileBounds2.Top;
                        char ch1 = data2[left1 - tileBounds1.X, top - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, top - tileBounds1.Y - index]; ++index)
                        {
                            data2[left1 - tileBounds1.X, top - tileBounds1.Y - index] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num2 = tileBounds2.Bottom - 1;
                        char ch2  = data2[left1 - tileBounds1.X, num2 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left1 - tileBounds1.X, num2 - tileBounds1.Y + index]; ++index)
                        {
                            data2[left1 - tileBounds1.X, num2 - tileBounds1.Y + index] = ch2;
                        }
                        ++left1;
                    }
                    else
                    {
                        break;
                    }
                }
                tileBounds2 = current.TileBounds;
                int num3 = tileBounds2.Top - 4;
                while (true)
                {
                    int num1 = num3;
                    tileBounds2 = current.TileBounds;
                    int num2 = tileBounds2.Bottom + 4;
                    if (num1 < num2)
                    {
                        tileBounds2 = current.TileBounds;
                        int  left2 = tileBounds2.Left;
                        char ch1   = data2[left2 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[left2 - tileBounds1.X - index, num3 - tileBounds1.Y]; ++index)
                        {
                            data2[left2 - tileBounds1.X - index, num3 - tileBounds1.Y] = ch1;
                        }
                        tileBounds2 = current.TileBounds;
                        int  num4 = tileBounds2.Right - 1;
                        char ch2  = data2[num4 - tileBounds1.X, num3 - tileBounds1.Y];
                        for (int index = 1; index < 4 && !virtualMap[num4 - tileBounds1.X + index, num3 - tileBounds1.Y]; ++index)
                        {
                            data2[num4 - tileBounds1.X + index, num3 - tileBounds1.Y] = ch2;
                        }
                        ++num3;
                    }
                    else
                    {
                        goto label_122;
                    }
                }
            }
        }
        Vector2         position        = new Vector2((float)tileBounds1.X, (float)tileBounds1.Y) * 8f;
        BackgroundTiles backgroundTiles = new BackgroundTiles(position, data1);


        //MTexture mTexture = Gfx.Game["tilesets/dirt"];
        //草地等等
        //MTexture mTexture = Gfx.Game["tilesets/scenery"];
        //StartCoroutine(DrawTiles(backgroundTiles.Tiles, Vector3.zero));


        /////////////////////////////////////////////////////
        ///构建BgTiles
        /////////////////////////////////////////////////////
        int  l8     = levelData.TileBounds.Left;
        int  t8     = levelData.TileBounds.Top;
        int  w8     = levelData.TileBounds.Width;
        int  h8     = levelData.TileBounds.Height;
        bool flag14 = !string.IsNullOrEmpty(levelData.BgTiles);

        if (flag14)
        {
            int[,] tiles = Util.ReadCSVIntGrid(levelData.BgTiles, w8, h8);
            backgroundTiles.Tiles.Overlay(Gfx.SceneryTiles, tiles, l8 - tileBounds1.X, t8 - tileBounds1.Y);
        }

        //BackdropRenderer backgroundRenderer = new BackdropRenderer();
        //backgroundRenderer.Backdrops = mapData.CreateBackdrops(mapData.Background);

        //BackdropRenderer foregroundRenderer = new BackdropRenderer();
        //foregroundRenderer.Backdrops = mapData.CreateBackdrops(mapData.Foreground);
        //foreach(Backdrop backdrop in backgroundRenderer.Backdrops)
        //{
        //    if(backdrop is Parallax)
        //    {
        //        ShowSprite((backdrop as Parallax).Texture);
        //    }

        //}
        //StartCoroutine(DrawTiles(backgroundTiles.Tiles, Vector3.zero));



        //foreach (DecalData bgDecal in levelData.BgDecals)
        //{
        //    new Decal(bgDecal.Texture, Vector3.zero + bgDecal.Position, bgDecal.Scale, 9000);
        //}
    }