Updated SyncListWithUserData

This commit is contained in:
MrGadget 2022-01-22 18:19:04 -05:00
parent 61eec62de9
commit be8cf781d9

View File

@ -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<T> 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<T> match)
{
List<T> toRemove = new List<T>();
@ -362,6 +350,17 @@ public int RemoveAll(Predicate<T> 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];