AppStart_Init.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using System.Net;
  2. namespace ET
  3. {
  4. public class AppStart_Init: AEvent<EventType.AppStart>
  5. {
  6. protected override async ETTask Run(EventType.AppStart args)
  7. {
  8. Game.Scene.AddComponent<ConfigComponent>();
  9. ConfigComponent.GetAllConfigBytes = LoadConfigHelper.GetAllConfigBytes;
  10. ConfigComponent.GetOneConfigBytes = LoadConfigHelper.GetOneConfigBytes;
  11. await ConfigComponent.Instance.LoadAsync();
  12. StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);
  13. Game.Scene.AddComponent<TimerComponent>();
  14. Game.Scene.AddComponent<OpcodeTypeComponent>();
  15. Game.Scene.AddComponent<MessageDispatcherComponent>();
  16. Game.Scene.AddComponent<CoroutineLockComponent>();
  17. // 发送普通actor消息
  18. Game.Scene.AddComponent<ActorMessageSenderComponent>();
  19. // 发送location actor消息
  20. Game.Scene.AddComponent<ActorLocationSenderComponent>();
  21. // 访问location server的组件
  22. Game.Scene.AddComponent<LocationProxyComponent>();
  23. Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
  24. // 数值订阅组件
  25. Game.Scene.AddComponent<NumericWatcherComponent>();
  26. Game.Scene.AddComponent<NetThreadComponent>();
  27. Game.Scene.AddComponent<NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort);
  28. var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process);
  29. foreach (StartSceneConfig startConfig in processScenes)
  30. {
  31. await SceneFactory.Create(Game.Scene, startConfig.SceneId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig);
  32. }
  33. switch (Game.Options.AppType)
  34. {
  35. case AppType.Server:
  36. break;
  37. case AppType.Watcher:
  38. break;
  39. }
  40. if (Game.Options.Console == 1)
  41. {
  42. Game.Scene.AddComponent<ConsoleComponent>();
  43. }
  44. }
  45. }
  46. }