Init.cs 997 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Threading;
  3. using CommandLine;
  4. namespace ET
  5. {
  6. public class Init
  7. {
  8. public void Start()
  9. {
  10. try
  11. {
  12. AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
  13. {
  14. Log.Error(e.ExceptionObject.ToString());
  15. };
  16. // 命令行参数
  17. Parser.Default.ParseArguments<Options>(System.Environment.GetCommandLineArgs())
  18. .WithNotParsed(error => throw new Exception($"命令行格式错误! {error}"))
  19. .WithParsed((o)=>World.Instance.AddSingleton(o));
  20. World.Instance.AddSingleton<Logger>().ILog = new NLogger(Options.Instance.AppType.ToString(), Options.Instance.Process, "../Config/NLog/NLog.config");
  21. ETTask.ExceptionHandler += Log.Error;
  22. World.Instance.AddSingleton<CodeLoader>();
  23. }
  24. catch (Exception e)
  25. {
  26. Log.Error(e);
  27. }
  28. }
  29. public void Update()
  30. {
  31. TimeInfo.Instance.Update();
  32. FiberManager.Instance.Update();
  33. }
  34. public void LateUpdate()
  35. {
  36. FiberManager.Instance.LateUpdate();
  37. }
  38. }
  39. }