Beispiel #1
0
        public Game(int conns)
        {
            this.ClientManager = new GameClientManager(conns);

            if (Essential.GetConfig().data["client.ping.enabled"] == "1")
            {
                this.ClientManager.StartPingTask();
            }

            DateTime now = DateTime.Now;

            Logging.Write("Connecting to the database.. ");

            try
            {
                using (DatabaseClient dbClient = Essential.GetDatabase().GetClient())
                {
                    Logging.WriteLine("completed!", ConsoleColor.Green);

                    Essential.Game = this;
                    this.LoadServerSettings(dbClient);
                    this.BanManager           = new ModerationBanManager();
                    this.RoleManager          = new RoleManager();
                    this.HelpTool             = new HelpTool();
                    this.Catalog              = new Catalog();
                    this.Navigator            = new Navigator();
                    this.ItemManager          = new ItemManager();
                    this.RoomManager          = new RoomManager();
                    this.PixelManager         = new PixelManager();
                    this.AchievementManager   = new AchievementManager();
                    this.ModerationTool       = new ModerationTool();
                    this.BotManager           = new BotManager();
                    this.Marketplace          = new Marketplace();
                    this.QuestManager         = new QuestManager();
                    this.EssentialEnvironment = new EssentialEnvironment();
                    this.GamesManager         = new GamesManager();
                    this.Groups    = new Groups();
                    this.StormWars = new WarsData();
                    EssentialEnvironment.LoadExternalTexts(dbClient);

                    this.BanManager.Initialise(dbClient);

                    this.RoleManager.Initialize(dbClient);

                    this.HelpTool.method_0(dbClient);
                    this.HelpTool.method_3(dbClient);

                    this.ModerationTool.method_1(dbClient);
                    this.ModerationTool.method_2(dbClient);
                    this.ItemManager.Initialize(dbClient);
                    this.Catalog.Initialize(dbClient);
                    this.Catalog.InitializeCache();
                    PetRace.Init(dbClient);
                    this.Navigator.Initialize(dbClient);
                    this.RoomManager.method_8(dbClient);
                    this.RoomManager.method_0();
                    this.NavigatorCache = new NavigatorCache();
                    this.RoomManager.LoadMagicTiles(dbClient);
                    this.RoomManager.LoadBillboards(dbClient);
                    this.BotManager.Initialize(dbClient);
                    AchievementManager.Load(dbClient);
                    this.PixelManager.Initialize();
                    ChatCommandHandler.Initialize(dbClient);
                    this.QuestManager.Initialize();
                    // this.GamesManager.LoadGameLocales(dbClient);
                    // this.GamesManager.LoadPowerupPackages(dbClient);
                    Groups.Initialize(dbClient);
                    guideManager = new GuideManager(dbClient);
                    this.RestoreStatistics(dbClient, 1);
                }
            }
            catch (MySql.Data.MySqlClient.MySqlException e)
            {
                Logging.WriteLine("failed!", ConsoleColor.Red);
                Logging.WriteLine(e.Message + " Check the given configuration details in config.conf\r\n", ConsoleColor.Yellow);
                Essential.Destroy("", true, true);

                return;
            }

            this.task_0 = new Task(new Action(LowPriorityWorker.Work));
            this.task_0.Start();

            StartGameLoop();
        }