AfterScenesAdd_CreateScene.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. namespace ET
  2. {
  3. [Event(EventIdType.AfterScenesAdd)]
  4. public class AfterScenesAdd_CreateScene: AEvent
  5. {
  6. public override void Run()
  7. {
  8. Game.Scene.AddComponent<ConfigComponent>();
  9. Options options = Game.Scene.GetComponent<Options>();
  10. StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(options.Process);
  11. Game.Scene.AddComponent<TimerComponent>();
  12. Game.Scene.AddComponent<OpcodeTypeComponent>();
  13. Game.Scene.AddComponent<MessageDispatcherComponent>();
  14. Game.Scene.AddComponent<CoroutineLockComponent>();
  15. // 发送普通actor消息
  16. Game.Scene.AddComponent<ActorMessageSenderComponent>();
  17. // 发送location actor消息
  18. Game.Scene.AddComponent<ActorLocationSenderComponent>();
  19. // 访问location server的组件
  20. Game.Scene.AddComponent<LocationProxyComponent>();
  21. Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
  22. // 数值订阅组件
  23. Game.Scene.AddComponent<NumericWatcherComponent>();
  24. // 控制台组件
  25. Game.Scene.AddComponent<ConsoleComponent>();
  26. Game.Scene.AddComponent<NetInnerComponent, string>(processConfig.InnerAddress);
  27. RunInner().Coroutine();
  28. }
  29. public async ETVoid RunInner()
  30. {
  31. var processScenes = StartSceneConfigCategory.Instance.GetByProcess(IdGenerater.Process);
  32. foreach (StartSceneConfig startConfig in processScenes)
  33. {
  34. await SceneFactory.Create(Game.Scene, startConfig.SceneId, startConfig.Zone, startConfig.Name, startConfig.Type, startConfig);
  35. }
  36. }
  37. }
  38. }