Entry.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System;
  2. using System.Linq;
  3. using System.Reflection;
  4. using System.Threading;
  5. namespace ET
  6. {
  7. public class Entry : IEntry
  8. {
  9. public void Start()
  10. {
  11. try
  12. {
  13. SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
  14. string[] assemblyNames = { "Unity.Model.dll", "Unity.Hotfix.dll", "Unity.ModelView.dll", "Unity.HotfixView.dll" };
  15. foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
  16. {
  17. string assemblyName = assembly.ManifestModule.Name;
  18. if (!assemblyNames.Contains(assemblyName))
  19. {
  20. continue;
  21. }
  22. Game.EventSystem.Add(assembly);
  23. }
  24. ProtobufHelper.Init();
  25. Game.Options = new Options();
  26. Game.EventSystem.Publish(new EventType.AppStart());
  27. }
  28. catch (Exception e)
  29. {
  30. Log.Error(e);
  31. }
  32. }
  33. public void Update()
  34. {
  35. ThreadSynchronizationContext.Instance.Update();
  36. Game.EventSystem.Update();
  37. }
  38. public void LateUpdate()
  39. {
  40. Game.EventSystem.LateUpdate();
  41. }
  42. public void OnApplicationQuit()
  43. {
  44. Game.Close();
  45. }
  46. }
  47. }