mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Code Cleanup: SyncList, SyncSet, SyncDictionary
Consistent order of things in all three
This commit is contained in:
parent
cd81e9dcdb
commit
c23914ca2b
@ -15,6 +15,17 @@ public class SyncIDictionary<TKey, TValue> : SyncObject, IDictionary<TKey, TValu
|
|||||||
/// <summary>This is called after the item is removed with TKey. TValue is the OLD item</summary>
|
/// <summary>This is called after the item is removed with TKey. TValue is the OLD item</summary>
|
||||||
public Action<TKey, TValue> OnRemove;
|
public Action<TKey, TValue> OnRemove;
|
||||||
|
|
||||||
|
/// <summary>This is called before the data is cleared</summary>
|
||||||
|
public Action OnClear;
|
||||||
|
|
||||||
|
public enum Operation : byte
|
||||||
|
{
|
||||||
|
OP_ADD,
|
||||||
|
OP_CLEAR,
|
||||||
|
OP_REMOVE,
|
||||||
|
OP_SET
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called for all changes to the Dictionary.
|
/// This is called for all changes to the Dictionary.
|
||||||
/// <para>For OP_ADD, TValue is the NEW value of the entry.</para>
|
/// <para>For OP_ADD, TValue is the NEW value of the entry.</para>
|
||||||
@ -23,9 +34,6 @@ public class SyncIDictionary<TKey, TValue> : SyncObject, IDictionary<TKey, TValu
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<Operation, TKey, TValue> OnChange;
|
public Action<Operation, TKey, TValue> OnChange;
|
||||||
|
|
||||||
/// <summary>This is called before the data is cleared</summary>
|
|
||||||
public Action OnClear;
|
|
||||||
|
|
||||||
protected readonly IDictionary<TKey, TValue> objects;
|
protected readonly IDictionary<TKey, TValue> objects;
|
||||||
|
|
||||||
public SyncIDictionary(IDictionary<TKey, TValue> objects)
|
public SyncIDictionary(IDictionary<TKey, TValue> objects)
|
||||||
@ -36,14 +44,6 @@ public SyncIDictionary(IDictionary<TKey, TValue> objects)
|
|||||||
public int Count => objects.Count;
|
public int Count => objects.Count;
|
||||||
public bool IsReadOnly => !IsWritable();
|
public bool IsReadOnly => !IsWritable();
|
||||||
|
|
||||||
public enum Operation : byte
|
|
||||||
{
|
|
||||||
OP_ADD,
|
|
||||||
OP_CLEAR,
|
|
||||||
OP_REMOVE,
|
|
||||||
OP_SET
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Change
|
struct Change
|
||||||
{
|
{
|
||||||
internal Operation operation;
|
internal Operation operation;
|
||||||
|
@ -6,15 +6,6 @@ namespace Mirror
|
|||||||
{
|
{
|
||||||
public class SyncList<T> : SyncObject, IList<T>, IReadOnlyList<T>
|
public class SyncList<T> : SyncObject, IList<T>, IReadOnlyList<T>
|
||||||
{
|
{
|
||||||
public enum Operation : byte
|
|
||||||
{
|
|
||||||
OP_ADD,
|
|
||||||
OP_SET,
|
|
||||||
OP_INSERT,
|
|
||||||
OP_REMOVEAT,
|
|
||||||
OP_CLEAR
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>This is called after the item is added with index</summary>
|
/// <summary>This is called after the item is added with index</summary>
|
||||||
public Action<int> OnAdd;
|
public Action<int> OnAdd;
|
||||||
|
|
||||||
@ -27,6 +18,18 @@ public enum Operation : byte
|
|||||||
/// <summary>This is called after the item is removed with index and OLD Value</summary>
|
/// <summary>This is called after the item is removed with index and OLD Value</summary>
|
||||||
public Action<int, T> OnRemove;
|
public Action<int, T> OnRemove;
|
||||||
|
|
||||||
|
/// <summary>This is called before the list is cleared so the list can be iterated</summary>
|
||||||
|
public Action OnClear;
|
||||||
|
|
||||||
|
public enum Operation : byte
|
||||||
|
{
|
||||||
|
OP_ADD,
|
||||||
|
OP_SET,
|
||||||
|
OP_INSERT,
|
||||||
|
OP_REMOVEAT,
|
||||||
|
OP_CLEAR
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called for all changes to the List.
|
/// This is called for all changes to the List.
|
||||||
/// <para>For OP_ADD and OP_INSERT, T is the NEW value of the entry.</para>
|
/// <para>For OP_ADD and OP_INSERT, T is the NEW value of the entry.</para>
|
||||||
@ -44,9 +47,6 @@ public enum Operation : byte
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<Operation, int, T, T> Callback;
|
public Action<Operation, int, T, T> Callback;
|
||||||
|
|
||||||
/// <summary>This is called before the list is cleared so the list can be iterated</summary>
|
|
||||||
public Action OnClear;
|
|
||||||
|
|
||||||
readonly IList<T> objects;
|
readonly IList<T> objects;
|
||||||
readonly IEqualityComparer<T> comparer;
|
readonly IEqualityComparer<T> comparer;
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ public class SyncSet<T> : SyncObject, ISet<T>
|
|||||||
/// <summary>This is called after the item is removed. T is the OLD item</summary>
|
/// <summary>This is called after the item is removed. T is the OLD item</summary>
|
||||||
public Action<T> OnRemove;
|
public Action<T> OnRemove;
|
||||||
|
|
||||||
|
/// <summary>This is called BEFORE the data is cleared</summary>
|
||||||
|
public Action OnClear;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is called for all changes to the Set.
|
/// This is called for all changes to the Set.
|
||||||
/// <para>For OP_ADD, T is the NEW value of the entry.</para>
|
/// <para>For OP_ADD, T is the NEW value of the entry.</para>
|
||||||
@ -20,9 +23,6 @@ public class SyncSet<T> : SyncObject, ISet<T>
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<Operation, T> OnChange;
|
public Action<Operation, T> OnChange;
|
||||||
|
|
||||||
/// <summary>This is called BEFORE the data is cleared</summary>
|
|
||||||
public Action OnClear;
|
|
||||||
|
|
||||||
protected readonly ISet<T> objects;
|
protected readonly ISet<T> objects;
|
||||||
|
|
||||||
public int Count => objects.Count;
|
public int Count => objects.Count;
|
||||||
|
Loading…
Reference in New Issue
Block a user