Entry.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Reflection;
  4. using MemoryPack;
  5. namespace ET
  6. {
  7. public struct EntryEvent1
  8. {
  9. }
  10. public struct EntryEvent2
  11. {
  12. }
  13. public struct EntryEvent3
  14. {
  15. }
  16. [MemoryPackable]
  17. [ComponentOf(typeof(Scene))]
  18. public partial class AA: Entity, IAwake
  19. {
  20. }
  21. [MemoryPackable]
  22. [ComponentOf(typeof(AA))]
  23. public partial class BB : Entity, IAwake, ISerializeToEntity
  24. {
  25. [MemoryPackInclude]
  26. public int B { get; set; }
  27. }
  28. [MemoryPackable]
  29. [ComponentOf(typeof(AA))]
  30. public partial class CC : Entity, IAwake //, ISerializeToEntity
  31. {
  32. [MemoryPackInclude]
  33. public int C { get; set; }
  34. }
  35. public static class Entry
  36. {
  37. public static void Init()
  38. {
  39. }
  40. public static void Start()
  41. {
  42. StartAsync().Coroutine();
  43. }
  44. private static async ETTask StartAsync()
  45. {
  46. WinPeriod.Init();
  47. // 注册Mongo type
  48. MongoRegister.Init();
  49. MemoryPackFormatterProvider.Register(new MemoryPackChildrenCollectionFormatter());
  50. MemoryPackFormatterProvider.Register(new MemoryPackComponentsCollectionFormatter());
  51. // 注册Entity序列化器
  52. EntitySerializeRegister.Init();
  53. World.Instance.AddSingleton<IdGenerater>();
  54. World.Instance.AddSingleton<OpcodeType>();
  55. World.Instance.AddSingleton<ObjectPool>();
  56. World.Instance.AddSingleton<MessageQueue>();
  57. World.Instance.AddSingleton<NetServices>();
  58. World.Instance.AddSingleton<NavmeshComponent>();
  59. World.Instance.AddSingleton<LogMsg>();
  60. // 创建需要reload的code singleton
  61. CodeTypes.Instance.CreateCode();
  62. await World.Instance.AddSingleton<ConfigLoader>().LoadAsync();
  63. await FiberManager.Instance.Create(SchedulerType.Main, ConstFiberId.Main, 0, SceneType.Main, "");
  64. }
  65. }
  66. }