Entry.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 MemoryPackSortedDictionaryFormatter<long, Entity>());
  50. // 注册Entity序列化器
  51. EntitySerializeRegister.Init();
  52. World.Instance.AddSingleton<IdGenerater>();
  53. World.Instance.AddSingleton<OpcodeType>();
  54. World.Instance.AddSingleton<ObjectPool>();
  55. World.Instance.AddSingleton<MessageQueue>();
  56. World.Instance.AddSingleton<NetServices>();
  57. World.Instance.AddSingleton<NavmeshComponent>();
  58. World.Instance.AddSingleton<LogMsg>();
  59. // 创建需要reload的code singleton
  60. CodeTypes.Instance.CreateCode();
  61. await World.Instance.AddSingleton<ConfigLoader>().LoadAsync();
  62. await FiberManager.Instance.Create(SchedulerType.Main, ConstFiberId.Main, 0, SceneType.Main, "");
  63. }
  64. }
  65. }