using System; using CommandLine; namespace ET { /** * 服务器主入口 */ public static class Init { public static void Start() { try { AppDomain.CurrentDomain.UnhandledException += (sender, e) => { Log.Error(e.ExceptionObject.ToString()); }; // 异步方法全部会回掉到主线程 Game.AddSingleton(); // 命令行参数 Parser.Default.ParseArguments(System.Environment.GetCommandLineArgs()) .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}")) .WithParsed(Game.AddSingleton); Game.AddSingleton(); Game.AddSingleton().ILog = new NLogger(Options.Instance.AppType.ToString(), Options.Instance.Process, "../Config/NLog/NLog.config"); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); Game.AddSingleton(); ETTask.ExceptionHandler += Log.Error; Log.Console($"{Parser.Default.FormatCommandLine(Options.Instance)}"); Game.AddSingleton().Start(); } catch (Exception e) { Log.Error(e); } } public static void Update(int timeMS) { Game.Update(timeMS); } public static void LateUpdate() { Game.LateUpdate(); } public static void FrameFinishUpdate() { Game.FrameFinishUpdate(); } } }