Пример #1
0
        private void Load()
        {
            Log.Info("Starting asset loading thread");

            SaveManager.Load(gameArea, SaveType.Global);
            checkFullscreen = true;
            progress++;

            var t = DateTime.Now.Millisecond;
            var c = DateTime.Now.Millisecond;

            Assets.Load(ref progress);
            Log.Info($"Assets took {(DateTime.Now.Millisecond - c) / 1000f} seconds");
            c = DateTime.Now.Millisecond;

            Dialogs.Load();
            progress++;
            CommonAse.Load();
            progress++;
            ImGuiHelper.BindTextures();
            progress++;
            Shaders.Load();
            progress++;
            Prefabs.Load();
            progress++;
            Items.Load();
            progress++;
            LootTables.Load();
            progress++;
            Mods.Load();
            progress++;             // Should be 13 here
            Log.Info($"Custom assets took {(DateTime.Now.Millisecond - c) / 1000f} seconds");

            Log.Info("Done loading assets! Loading level now.");

            Lights.Init();
            Physics.Init();
            gameArea = new Area();

            Run.Level = null;
            Tilesets.Load();
            progress++;

            Achievements.Load();
            c = DateTime.Now.Millisecond;

            if (!LoadEditor)
            {
                SaveManager.Load(gameArea, SaveType.Game);
                progress++;
                Log.Info($"Game took {(DateTime.Now.Millisecond - c) / 1000f} seconds");
                c = DateTime.Now.Millisecond;

                Rnd.Seed = $"{Run.Seed}_{Run.Depth}";

                SaveManager.Load(gameArea, SaveType.Level);
                progress++;
                Log.Info($"Level took {(DateTime.Now.Millisecond - c) / 1000f} seconds");
                c = DateTime.Now.Millisecond;

                if (Run.Depth > 0)
                {
                    SaveManager.Load(gameArea, SaveType.Player);
                }
                else
                {
                    SaveManager.Generate(gameArea, SaveType.Player);
                }

                Log.Info($"Player took {(DateTime.Now.Millisecond - c) / 1000f}");
            }

            progress++;             // Should be 18 here
            Log.Info($"Done loading level! ({(DateTime.Now.Millisecond - t) / 1000f} seconds) Going to menu.");

            Engine.AssetsLoaded?.Invoke();
            ready = true;
        }
Пример #2
0
        public override void Init()
        {
            base.Init();

            pixel = new TextureRegion(Textures.FastLoad("Content/pixel.png"));

            Ui.Add(logoCard = new PhotoCard {
                Region   = new TextureRegion(Textures.FastLoad("Content/logo.png")),
                Url      = "https://twitter.com/rexcellentgames",
                Name     = "Rexcellent Games",
                Position = new Vector2(240, Display.UiHeight + 60),
                Target   = new Vector2(240, 115),
                Scale    = 1
            });

            Ui.Add(tipLabel = new UiString(Font.Small));

            GenerateNewTip();

            logoCard.Start.Y = -90;
            progress         = 0;

            var thread = new Thread(() => {
                var sw = Stopwatch.StartNew();

                Log.Info("Starting asset loading thread");

                LoadSection(() => SaveManager.Load(gameArea, SaveType.Global), "Global saves");

                checkFullscreen = true;

                if (Assets.LoadMusic)
                {
                    LoadSection(() => Audio.ThreadLoad("Void"), "Audio");
                }
                else
                {
                    progress++;
                }

                LoadSection(() => Assets.Load(ref progress), "Assets");

                if (Assets.LoadMusic)
                {
                    LoadSection(() => Audio.ThreadLoad("Menu", false), "More audio");
                }
                else
                {
                    progress++;
                }

                LoadSection(Dialogs.Load, "Dialogs");

                CommonAse.Load();
                progress++;

                try {
                    ImGuiHelper.BindTextures();
                } catch (Exception e) {
                    Log.Error(e);
                }

                progress++;

                LoadSection(Shaders.Load, "Shaders");
                LoadSection(Prefabs.Load, "Prefabs");
                LoadSection(Items.Load, "Items");
                LoadSection(LootTables.Load, "Loot tables");
                LoadSection(Mods.Load, "Mods");

                Log.Info("Done loading assets! Loading level now.");

                LoadSection(() => {
                    Lights.Init();
                    Physics.Init();
                }, "Lights & physics");

                gameArea  = new Area();
                Run.Level = null;

                LoadSection(Tilesets.Load, "Tilesets");
                LoadSection(Achievements.Load, "Achievements");

                LoadSection(() => {
                    SaveManager.Load(gameArea, SaveType.Game);
                }, "Game saves");

                Rnd.Seed = $"{Run.Seed}_{Run.Depth}";

                LoadSection(() => {
                    SaveManager.Load(gameArea, SaveType.Level);
                }, "Level saves");

                LoadSection(() => {
                    if (Run.Depth > 0)
                    {
                        SaveManager.Load(gameArea, SaveType.Player);
                    }
                    else
                    {
                        SaveManager.Generate(gameArea, SaveType.Player);
                    }
                }, "Player saves");

                Log.Info($"Done loading level in {sw.ElapsedMilliseconds} ms! Going to menu.");

                ready = true;
            });

            thread.Start();
        }