SceneFactory.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. namespace ET
  2. {
  3. public static class SceneFactory
  4. {
  5. public static async ETTask<Scene> Create(Entity parent, string name, SceneType sceneType)
  6. {
  7. long id = IdGenerater.GenerateId();
  8. return await Create(parent, id, parent.DomainZone(), name, sceneType);
  9. }
  10. public static async ETTask<Scene> Create(Entity parent, long id, int zone, string name, SceneType sceneType, StartSceneConfig startSceneConfig = null)
  11. {
  12. Scene scene = EntitySceneFactory.CreateScene(id, zone, sceneType, name);
  13. scene.Parent = parent;
  14. scene.AddComponent<MailBoxComponent, MailboxType>(MailboxType.UnOrderMessageDispatcher);
  15. switch (scene.SceneType)
  16. {
  17. case SceneType.Realm:
  18. scene.AddComponent<NetOuterComponent, string>(startSceneConfig.OuterAddress);
  19. break;
  20. case SceneType.Gate:
  21. scene.AddComponent<NetOuterComponent, string>(startSceneConfig.OuterAddress);
  22. scene.AddComponent<PlayerComponent>();
  23. scene.AddComponent<GateSessionKeyComponent>();
  24. break;
  25. case SceneType.Map:
  26. scene.AddComponent<UnitComponent>();
  27. break;
  28. case SceneType.Location:
  29. scene.AddComponent<LocationComponent>();
  30. break;
  31. }
  32. return scene;
  33. }
  34. }
  35. }