Init.cs 957 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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(World.Instance.AddSingleton);
  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. FiberManager.Instance.Update();
  32. }
  33. public void LateUpdate()
  34. {
  35. FiberManager.Instance.LateUpdate();
  36. }
  37. }
  38. }