Переглянути джерело

调整location lock的逻辑,更合理一些

tanghai 3 роки тому
батько
коміт
148bfe58e5

+ 10 - 6
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/LocationComponentSystem.cs

@@ -53,14 +53,18 @@
 
 
             if (time > 0)
             if (time > 0)
             {
             {
-                long lockInfoInstanceId = lockInfo.InstanceId;
-                await TimerComponent.Instance.WaitAsync(time);
-                if (lockInfo.InstanceId != lockInfoInstanceId)
+                async ETTask TimeWaitAsync()
                 {
                 {
-                    return;
+                    long lockInfoInstanceId = lockInfo.InstanceId;
+                    await TimerComponent.Instance.WaitAsync(time);
+                    if (lockInfo.InstanceId != lockInfoInstanceId)
+                    {
+                        return;
+                    }
+                    Log.Info($"location timeout unlock key: {key} instanceId: {instanceId} newInstanceId: {instanceId}");
+                    self.UnLock(key, instanceId, instanceId);
                 }
                 }
-
-                self.UnLock(key, instanceId, instanceId);
+                TimeWaitAsync().Coroutine();
             }
             }
         }
         }
 
 

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/ActorLocation/ObjectLockRequestHandler.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
     {
         protected override async ETTask Run(Scene scene, ObjectLockRequest request, ObjectLockResponse response, Action reply)
         protected override async ETTask Run(Scene scene, ObjectLockRequest request, ObjectLockResponse response, Action reply)
         {
         {
-            scene.GetComponent<LocationComponent>().Lock(request.Key, request.InstanceId, request.Time).Coroutine();
+            await scene.GetComponent<LocationComponent>().Lock(request.Key, request.InstanceId, request.Time);
 
 
             reply();
             reply();