瀏覽代碼

增加一个防错Log

大爷 2 年之前
父節點
當前提交
66ac82f414
共有 1 個文件被更改,包括 10 次插入3 次删除
  1. 10 3
      Common/CommonAI/ZoneClient/ZoneLayer.cs

+ 10 - 3
Common/CommonAI/ZoneClient/ZoneLayer.cs

@@ -115,11 +115,18 @@ namespace CommonAI.ZoneClient
             ZoneLayer.s_active_object_count++;
             this.IsLoaded = false;
             this.DataRoot = dataroot;
-            this.Templates = dataroot.Templates;
             this.LayerClient = client;
             this.ActorSyncMode = SyncMode.ForceByServer;
-            this.AsyncUnitPosModifyMaxRange = Templates.CFG.CLIENT_UNIT_MOVE_MODIFY_MAX_RANGE;
-            this.MinStep = MoveHelper.GetDistance(1000 / Templates.CFG.SYSTEM_FPS, Templates.CFG.OBJECT_MOVE_TO_MIN_STEP_SEC);
+            this.Templates = dataroot?.Templates;
+            if (Templates == null)
+            {
+                log.Error("dataroot cannot set to null");
+            }
+            else
+            {
+                this.AsyncUnitPosModifyMaxRange = Templates.CFG.CLIENT_UNIT_MOVE_MODIFY_MAX_RANGE;
+                this.MinStep = MoveHelper.GetDistance(1000 / Templates.CFG.SYSTEM_FPS, Templates.CFG.OBJECT_MOVE_TO_MIN_STEP_SEC);
+            }
         }
         //-------------------------------------------------------------------------------------------
         ~ZoneLayer()