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

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/Demo/Router/RouterHelper.cs

@@ -32,14 +32,14 @@ namespace ET.Client
             RouterAddressComponent routerAddressComponent = clientScene.GetComponent<RouterAddressComponent>();
             IPEndPoint routerInfo = routerAddressComponent.GetAddress();
             
-            uint recvLocalConn = await Connect(routerInfo, address, localConn, remoteConn);
+            uint recvLocalConn = await Connect(clientScene, routerInfo, address, localConn, remoteConn);
             
             Log.Info($"finish get router address: {clientScene.Id} {address} {localConn} {remoteConn} {recvLocalConn} {routerInfo}");
             return (recvLocalConn, routerInfo);
         }
 
         // 向router申请
-        private static async ETTask<uint> Connect(IPEndPoint routerAddress, IPEndPoint realAddress, uint localConn, uint remoteConn)
+        private static async ETTask<uint> Connect(Scene clientScene, IPEndPoint routerAddress, IPEndPoint realAddress, uint localConn, uint remoteConn)
         {
             uint connectId = RandomGenerator.RandUInt32();
             
@@ -78,7 +78,7 @@ namespace ET.Client
                     socket.SendTo(sendCache, 0, addressBytes.Length + 13, SocketFlags.None, routerAddress);
                 }
                     
-                await Fiber.Instance.GetComponent<TimerComponent>().WaitFrameAsync();
+                await clientScene.Fiber().GetComponent<TimerComponent>().WaitFrameAsync();
                     
                 // 接收
                 if (socket.Available > 0)

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

@@ -17,7 +17,7 @@ namespace ET.Client
         
         public static Scene CreateCurrentScene(long id, int zone, string name, CurrentScenesComponent currentScenesComponent)
         {
-            Scene currentScene = EntitySceneFactory.CreateScene(id, Fiber.Instance.IdGenerater.GenerateInstanceId(), zone, SceneType.Current, name, currentScenesComponent);
+            Scene currentScene = EntitySceneFactory.CreateScene(id, currentScenesComponent.Fiber().IdGenerater.GenerateInstanceId(), zone, SceneType.Current, name, currentScenesComponent);
             currentScenesComponent.Scene = currentScene;
             
             EventSystem.Instance.Publish(currentScene, new EventType.AfterCreateCurrentScene());

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs

@@ -19,7 +19,7 @@ namespace ET.Server
         {
             await self.Fiber().GetComponent<TimerComponent>().WaitAsync(1000);
 
-            Scene scene = await SceneFactory.CreateServerScene(self, Fiber.Instance.IdGenerater.GenerateId(), Fiber.Instance.IdGenerater.GenerateInstanceId(),
+            Scene scene = await SceneFactory.CreateServerScene(self, self.Fiber().IdGenerater.GenerateId(), self.Fiber().IdGenerater.GenerateInstanceId(),
                 self.DomainZone(), "bechmark", SceneType.Benchmark);
             
             Client.NetClientComponent netClientComponent = scene.AddComponent<Client.NetClientComponent, AddressFamily>(AddressFamily.InterNetwork);