Просмотр исходного кода

去掉SceneFactory,现在基本上都是Fiber了

tanghai 2 лет назад
Родитель
Сommit
e42190e8c9

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/SceneFactory.cs → Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/CurrentSceneFactory.cs

@@ -1,8 +1,8 @@
 namespace ET.Client
 {
-    public static partial class SceneFactory
+    public static class CurrentSceneFactory
     {
-        public static Scene CreateCurrentScene(long id, string name, CurrentScenesComponent currentScenesComponent)
+        public static Scene Create(long id, string name, CurrentScenesComponent currentScenesComponent)
         {
             Scene currentScene = EntitySceneFactory.CreateScene(currentScenesComponent, id, currentScenesComponent.Fiber().IdGenerater.GenerateInstanceId(), SceneType.Current, name);
             currentScenesComponent.Scene = currentScene;

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/SceneFactory.cs.meta → Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/CurrentSceneFactory.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: f71b231485c5cdc42b0e12c0d4973364
+guid: d7e7628945100a44193d11f6c86856fb
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/SceneChangeHelper.cs

@@ -9,7 +9,7 @@
             
             CurrentScenesComponent currentScenesComponent = root.GetComponent<CurrentScenesComponent>();
             currentScenesComponent.Scene?.Dispose(); // 删除之前的CurrentScene,创建新的
-            Scene currentScene = SceneFactory.CreateCurrentScene(sceneInstanceId, sceneName, currentScenesComponent);
+            Scene currentScene = CurrentSceneFactory.Create(sceneInstanceId, sceneName, currentScenesComponent);
             UnitComponent unitComponent = currentScene.AddComponent<UnitComponent>();
          
             // 可以订阅这个事件中创建Loading界面

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Gate/C2G_EnterMapHandler.cs

@@ -9,7 +9,7 @@
 
 			// 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了
 			GateMapComponent gateMapComponent = player.AddComponent<GateMapComponent>();
-			gateMapComponent.Scene = await SceneFactory.CreateMapScene(gateMapComponent, player.Id, session.Fiber().IdGenerater.GenerateInstanceId(), SceneType.Map, "GateMap");
+			gateMapComponent.Scene = await GateMapFactory.Create(gateMapComponent, player.Id, session.Fiber().IdGenerater.GenerateInstanceId(), "GateMap");
 
 			Scene scene = gateMapComponent.Scene;
 			

+ 20 - 0
Unity/Assets/Scripts/Hotfix/Server/Demo/Gate/GateMapFactory.cs

@@ -0,0 +1,20 @@
+namespace ET.Server
+{
+    public static class GateMapFactory
+    {
+        public static async ETTask<Scene> Create(Entity parent, long id, long instanceId, string name)
+        {
+            await ETTask.CompletedTask;
+            Scene scene = EntitySceneFactory.CreateScene(parent, id, instanceId, SceneType.Map, name);
+
+            scene.AddComponent<UnitComponent>();
+            scene.AddComponent<AOIManagerComponent>();
+            scene.AddComponent<RoomManagerComponent>();
+            
+            scene.AddComponent<MailBoxComponent, MailBoxType>(MailBoxType.UnOrderedMessage);
+            
+            return scene;
+        }
+        
+    }
+}

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Map/SceneFactory.cs.meta → Unity/Assets/Scripts/Hotfix/Server/Demo/Gate/GateMapFactory.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: c25b0dbf4c6fc204689e2a0b75543509
+guid: b5df8fb8c84869f4ea1310d4a0839013
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 28
Unity/Assets/Scripts/Hotfix/Server/Demo/Map/SceneFactory.cs

@@ -1,28 +0,0 @@
-using System.Net;
-using System.Net.Sockets;
-
-namespace ET.Server
-{
-    public static partial class SceneFactory
-    {
-        public static async ETTask<Scene> CreateMapScene(Entity parent, long id, long instanceId, SceneType sceneType, string name, StartSceneConfig startSceneConfig = null)
-        {
-            await ETTask.CompletedTask;
-            Scene scene = EntitySceneFactory.CreateScene(parent, id, instanceId, sceneType, name);
-
-            scene.AddComponent<MailBoxComponent, MailBoxType>(MailBoxType.UnOrderedMessage);
-
-            switch (scene.SceneType)
-            {
-                case SceneType.Map:
-                    scene.AddComponent<UnitComponent>();
-                    scene.AddComponent<AOIManagerComponent>();
-                    scene.AddComponent<RoomManagerComponent>();
-                    break;
-            }
-
-            return scene;
-        }
-        
-    }
-}