Exemplo n.º 1
0
        private void InitializeGame(IProgressReceiver progressReceiver)
        {
            progressReceiver.UpdateProgress(0, "Initializing...");
            Extensions.Init(GraphicsDevice);
            MCPacketFactory.Load();

            ConfigureServices();

            var options = Services.GetService <IOptionsProvider>();

            string pluginDirectoryPaths = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            var pluginDir = options.AlexOptions.ResourceOptions.PluginDirectory;

            if (!string.IsNullOrWhiteSpace(pluginDir))
            {
                pluginDirectoryPaths = pluginDir;
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(LaunchSettings.WorkDir) && Directory.Exists(LaunchSettings.WorkDir))
                {
                    pluginDirectoryPaths = LaunchSettings.WorkDir;
                }
            }

            foreach (string dirPath in pluginDirectoryPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
            {
                string directory = dirPath;
                if (!Path.IsPathRooted(directory))
                {
                    directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), dirPath);
                }

                PluginManager.DiscoverPlugins(directory);
            }


            ProfileManager.LoadProfiles(progressReceiver);

            //	Log.Info($"Loading resources...");
            Resources = new ResourceManager(GraphicsDevice, Storage, options);
            if (!Resources.CheckResources(GraphicsDevice, progressReceiver,
                                          OnResourcePackPreLoadCompleted))
            {
                Console.WriteLine("Press enter to exit...");
                Console.ReadLine();
                Exit();
                return;
            }

            GuiRenderer.LoadResourcePack(Resources.ResourcePack);
            AnvilWorldProvider.LoadBlockConverter();

            if (LaunchSettings.ModelDebugging)
            {
                GameStateManager.SetActiveState <ModelDebugState>();
            }
            else
            {
                GameStateManager.SetActiveState <TitleState>("title");
                var player = new Player(GraphicsDevice, this, null, null, new Skin(), null, PlayerIndex.One);
                player.Inventory.IsPeInventory = true;

                /*Random rnd = new Random();
                 * for (int i = 0; i < player.Inventory.SlotCount; i++)
                 * {
                 *      player.Inventory[i] = new ItemBlock(BlockFactory.AllBlockstates.ElementAt(rnd.Next() % BlockFactory.AllBlockstates.Count).Value)
                 *      {
                 *              Count = rnd.Next(1, 64)
                 *      };
                 * }*/
                //GuiManager.ShowDialog(new GuiPlayerInventoryDialog(player, player.Inventory));
            }

            GameStateManager.RemoveState("splash");
        }