InitServer.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System.Net;
  2. namespace ET.Server
  3. {
  4. [Callback(CallbackType.InitServer)]
  5. public class InitServer: IFunc<ETTask>
  6. {
  7. public async ETTask Handle()
  8. {
  9. // 发送普通actor消息
  10. Game.Scene.AddComponent<ActorMessageSenderComponent>();
  11. // 发送location actor消息
  12. Game.Scene.AddComponent<ActorLocationSenderComponent>();
  13. // 访问location server的组件
  14. Game.Scene.AddComponent<LocationProxyComponent>();
  15. Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
  16. Game.Scene.AddComponent<RobotCaseDispatcherComponent>();
  17. Game.Scene.AddComponent<RobotCaseComponent>();
  18. Game.Scene.AddComponent<NavmeshComponent>();
  19. StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);
  20. switch (Game.Options.AppType)
  21. {
  22. case AppType.Server:
  23. {
  24. Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, CallbackType.SessionStreamDispatcherServerInner);
  25. var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process);
  26. foreach (StartSceneConfig startConfig in processScenes)
  27. {
  28. await SceneFactory.Create(Game.Scene, 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 = Game.Scene.AddComponent<WatcherComponent>();
  37. watcherComponent.Start(Game.Options.CreateScenes);
  38. Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), CallbackType.SessionStreamDispatcherServerInner);
  39. break;
  40. }
  41. case AppType.GameTool:
  42. break;
  43. }
  44. if (Game.Options.Console == 1)
  45. {
  46. Game.Scene.AddComponent<ConsoleComponent>();
  47. }
  48. }
  49. }
  50. }