From be8cf781d908a99a466b7faf60fb1c6cf5929802 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Sat, 22 Jan 2022 18:19:04 -0500 Subject: [PATCH] Updated SyncListWithUserData --- Assets/Mirror/Runtime/SyncListWithUserData.cs | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Assets/Mirror/Runtime/SyncListWithUserData.cs b/Assets/Mirror/Runtime/SyncListWithUserData.cs index 789a52d31..ad7f4b5f1 100644 --- a/Assets/Mirror/Runtime/SyncListWithUserData.cs +++ b/Assets/Mirror/Runtime/SyncListWithUserData.cs @@ -238,7 +238,6 @@ public override void OnDeserializeDelta(NetworkReader reader) { oldItem = objects[index]; objects[index] = newItem; - //InternalUserData[index] = default; } break; } @@ -271,7 +270,7 @@ public void AddRange(IEnumerable range) public void Clear() { objects.Clear(); - //InternalUserData.Clear(); + InternalUserData.Clear(); AddOperation(Operation.OP_CLEAR, 0, default, default, default); } @@ -338,17 +337,6 @@ public bool Remove(T item) return result; } - public void RemoveAt(int index) - { - T oldItem = objects[index]; - UnityEngine.Debug.LogWarning($"objects RemoveAt {index}"); - objects.RemoveAt(index); - UnityEngine.Debug.LogWarning($"InternalUserData RemoveAt {index}"); - TUserData userData = InternalUserData[index]; - InternalUserData.RemoveAt(index); - AddOperation(Operation.OP_REMOVEAT, index, oldItem, default, userData); - } - public int RemoveAll(Predicate match) { List toRemove = new List(); @@ -362,6 +350,17 @@ public int RemoveAll(Predicate match) return toRemove.Count; } + public void RemoveAt(int index) + { + T oldItem = objects[index]; + TUserData userData = InternalUserData[index]; + UnityEngine.Debug.LogWarning($"objects RemoveAt {index}"); + objects.RemoveAt(index); + UnityEngine.Debug.LogWarning($"InternalUserData RemoveAt {index}"); + InternalUserData.RemoveAt(index); + AddOperation(Operation.OP_REMOVEAT, index, oldItem, default, userData); + } + public T this[int i] { get => objects[i];