From c23914ca2b48e972875ec786146e1b1b29a60ef2 Mon Sep 17 00:00:00 2001 From: MrGadget <9826063+MrGadget1024@users.noreply.github.com> Date: Tue, 15 Oct 2024 05:34:18 -0400 Subject: [PATCH] Code Cleanup: SyncList, SyncSet, SyncDictionary Consistent order of things in all three --- Assets/Mirror/Core/SyncDictionary.cs | 22 +++++++++++----------- Assets/Mirror/Core/SyncList.cs | 24 ++++++++++++------------ Assets/Mirror/Core/SyncSet.cs | 6 +++--- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/Assets/Mirror/Core/SyncDictionary.cs b/Assets/Mirror/Core/SyncDictionary.cs index b07d6e058..950358fe6 100644 --- a/Assets/Mirror/Core/SyncDictionary.cs +++ b/Assets/Mirror/Core/SyncDictionary.cs @@ -15,6 +15,17 @@ public class SyncIDictionary : SyncObject, IDictionaryThis is called after the item is removed with TKey. TValue is the OLD item public Action OnRemove; + /// This is called before the data is cleared + public Action OnClear; + + public enum Operation : byte + { + OP_ADD, + OP_CLEAR, + OP_REMOVE, + OP_SET + } + /// /// This is called for all changes to the Dictionary. /// For OP_ADD, TValue is the NEW value of the entry. @@ -23,9 +34,6 @@ public class SyncIDictionary : SyncObject, IDictionary public Action OnChange; - /// This is called before the data is cleared - public Action OnClear; - protected readonly IDictionary objects; public SyncIDictionary(IDictionary objects) @@ -36,14 +44,6 @@ public SyncIDictionary(IDictionary objects) public int Count => objects.Count; public bool IsReadOnly => !IsWritable(); - public enum Operation : byte - { - OP_ADD, - OP_CLEAR, - OP_REMOVE, - OP_SET - } - struct Change { internal Operation operation; diff --git a/Assets/Mirror/Core/SyncList.cs b/Assets/Mirror/Core/SyncList.cs index cf27a75e3..3986725c2 100644 --- a/Assets/Mirror/Core/SyncList.cs +++ b/Assets/Mirror/Core/SyncList.cs @@ -6,15 +6,6 @@ namespace Mirror { public class SyncList : SyncObject, IList, IReadOnlyList { - public enum Operation : byte - { - OP_ADD, - OP_SET, - OP_INSERT, - OP_REMOVEAT, - OP_CLEAR - } - /// This is called after the item is added with index public Action OnAdd; @@ -27,6 +18,18 @@ public enum Operation : byte /// This is called after the item is removed with index and OLD Value public Action OnRemove; + /// This is called before the list is cleared so the list can be iterated + public Action OnClear; + + public enum Operation : byte + { + OP_ADD, + OP_SET, + OP_INSERT, + OP_REMOVEAT, + OP_CLEAR + } + /// /// This is called for all changes to the List. /// For OP_ADD and OP_INSERT, T is the NEW value of the entry. @@ -44,9 +47,6 @@ public enum Operation : byte /// public Action Callback; - /// This is called before the list is cleared so the list can be iterated - public Action OnClear; - readonly IList objects; readonly IEqualityComparer comparer; diff --git a/Assets/Mirror/Core/SyncSet.cs b/Assets/Mirror/Core/SyncSet.cs index 52517b87d..6ab1f3b88 100644 --- a/Assets/Mirror/Core/SyncSet.cs +++ b/Assets/Mirror/Core/SyncSet.cs @@ -12,6 +12,9 @@ public class SyncSet : SyncObject, ISet /// This is called after the item is removed. T is the OLD item public Action OnRemove; + /// This is called BEFORE the data is cleared + public Action OnClear; + /// /// This is called for all changes to the Set. /// For OP_ADD, T is the NEW value of the entry. @@ -20,9 +23,6 @@ public class SyncSet : SyncObject, ISet /// public Action OnChange; - /// This is called BEFORE the data is cleared - public Action OnClear; - protected readonly ISet objects; public int Count => objects.Count;