EntryEvent2_InitServer.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System.Net;
  2. namespace ET.Server
  3. {
  4. [Event(SceneType.Process)]
  5. public class EntryEvent2_InitServer: AEvent<EventType.EntryEvent2>
  6. {
  7. protected override async ETTask Run(Scene scene, 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. StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Options.Instance.Process);
  19. Log.Debug($"AppType: {Options.Instance.AppType}");
  20. switch (Options.Instance.AppType)
  21. {
  22. case AppType.Server:
  23. {
  24. Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(processConfig.InnerIPPort);
  25. var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Options.Instance.Process);
  26. foreach (StartSceneConfig startConfig in processScenes)
  27. {
  28. await SceneFactory.CreateServerScene(ServerSceneManagerComponent.Instance, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
  29. startConfig.Type, startConfig);
  30. }
  31. break;
  32. }
  33. case AppType.Watcher:
  34. {
  35. StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
  36. WatcherComponent watcherComponent = Root.Instance.Scene.AddComponent<WatcherComponent>();
  37. watcherComponent.Start(Options.Instance.CreateScenes);
  38. Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"));
  39. break;
  40. }
  41. case AppType.GameTool:
  42. break;
  43. }
  44. if (Options.Instance.Console == 1)
  45. {
  46. Root.Instance.Scene.AddComponent<ConsoleComponent>();
  47. }
  48. }
  49. }
  50. }