Kaynağa Gözat

还原之前的LSUpdater,上次修改忘记了Remove掉失效的Id

tanghai 1 yıl önce
ebeveyn
işleme
a33ab02192

+ 6 - 2
Unity/Assets/Scripts/Model/Share/Demo/LockStep/LSUpdater.cs

@@ -5,8 +5,8 @@ namespace ET
 {
     public class LSUpdater: Object
     {
-        private readonly NativeCollection.SortedSet<long> updateIds = new();
-        private readonly NativeCollection.SortedSet<long> newUpdateIds = new();
+        private List<long> updateIds = new();
+        private List<long> newUpdateIds = new();
 
         private readonly Dictionary<long, EntityRef<LSEntity>> lsEntities = new();
 
@@ -18,6 +18,7 @@ namespace ET
                 {
                     this.updateIds.Add(id);
                 }
+                this.updateIds.Sort();
                 this.newUpdateIds.Clear();
             }
 
@@ -29,8 +30,11 @@ namespace ET
                     this.lsEntities.Remove(id);
                     continue;
                 }
+                this.newUpdateIds.Add(id);
                 LSEntitySystemSingleton.Instance.LSUpdate(entity);
             }
+            this.updateIds.Clear();
+            ObjectHelper.Swap(ref this.updateIds, ref this.newUpdateIds);
         }
         
         public void Add(LSEntity entity)