AfterScenesAdd_CreateScene.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. namespace ET
  2. {
  3. [Event(EventIdType.AfterScenesAdd)]
  4. public class AfterScenesAdd_CreateScene: AEvent
  5. {
  6. public override void Run()
  7. {
  8. Options options = Game.Scene.GetComponent<Options>();
  9. StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(options.Process);
  10. Game.Scene.AddComponent<TimerComponent>();
  11. Game.Scene.AddComponent<OpcodeTypeComponent>();
  12. Game.Scene.AddComponent<MessageDispatcherComponent>();
  13. Game.Scene.AddComponent<ConfigComponent>();
  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. }