EntryEvent2_InitServer.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Net;
  2. namespace ET.Server
  3. {
  4. [Event(SceneType.Process)]
  5. public class EntryEvent2_InitServer: AEvent<ET.EventType.EntryEvent2>
  6. {
  7. protected override async ETTask Run(Scene scene, ET.EventType.EntryEvent2 args)
  8. {
  9. // 发送普通actor消息
  10. Root.Instance.Scene.AddComponent<ActorMessageSenderComponent>();
  11. // 发送location actor消息
  12. Root.Instance.Scene.AddComponent<ActorLocationSenderComponent>();
  13. // 访问location server的组件
  14. Root.Instance.Scene.AddComponent<LocationProxyComponent>();
  15. Root.Instance.Scene.AddComponent<ActorMessageDispatcherComponent>();
  16. Root.Instance.Scene.AddComponent<ServerSceneManagerComponent>();
  17. Root.Instance.Scene.AddComponent<RobotCaseComponent>();
  18. Root.Instance.Scene.AddComponent<NavmeshComponent>();
  19. StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Options.Instance.Process);
  20. Log.Debug($"AppType: {Options.Instance.AppType}");
  21. switch (Options.Instance.AppType)
  22. {
  23. case AppType.Server:
  24. {
  25. Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort);
  26. var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Options.Instance.Process);
  27. foreach (StartSceneConfig startConfig in processScenes)
  28. {
  29. await SceneFactory.CreateServerScene(ServerSceneManagerComponent.Instance, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
  30. startConfig.Type, startConfig);
  31. }
  32. break;
  33. }
  34. case AppType.Watcher:
  35. {
  36. StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
  37. WatcherComponent watcherComponent = Root.Instance.Scene.AddComponent<WatcherComponent>();
  38. watcherComponent.Start(Options.Instance.CreateScenes);
  39. Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"));
  40. break;
  41. }
  42. case AppType.GameTool:
  43. break;
  44. }
  45. if (Options.Instance.Console == 1)
  46. {
  47. Root.Instance.Scene.AddComponent<ConsoleComponent>();
  48. }
  49. }
  50. }
  51. }