mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
parent
13e4e6fe3a
commit
1ec8910575
@ -5,11 +5,11 @@
|
||||
namespace Mirror
|
||||
{
|
||||
[EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public abstract class SyncDictionary<TKey, TValue> : IDictionary<TKey, TValue>, SyncObject
|
||||
public abstract class SyncIDictionary<TKey, TValue> : IDictionary<TKey, TValue>, SyncObject
|
||||
{
|
||||
public delegate void SyncDictionaryChanged(Operation op, TKey key, TValue item);
|
||||
|
||||
readonly IDictionary<TKey, TValue> objects;
|
||||
protected readonly IDictionary<TKey, TValue> objects;
|
||||
|
||||
public int Count => objects.Count;
|
||||
public bool IsReadOnly { get; private set; }
|
||||
@ -53,17 +53,7 @@ protected virtual void SerializeItem(NetworkWriter writer, TValue item) { }
|
||||
// this should be called after a successfull sync
|
||||
public void Flush() => changes.Clear();
|
||||
|
||||
protected SyncDictionary()
|
||||
{
|
||||
objects = new Dictionary<TKey, TValue>();
|
||||
}
|
||||
|
||||
protected SyncDictionary(IEqualityComparer<TKey> eq)
|
||||
{
|
||||
objects = new Dictionary<TKey, TValue>(eq);
|
||||
}
|
||||
|
||||
protected SyncDictionary(IDictionary<TKey, TValue> objects)
|
||||
protected SyncIDictionary(IDictionary<TKey, TValue> objects)
|
||||
{
|
||||
this.objects = objects;
|
||||
}
|
||||
@ -301,8 +291,26 @@ public bool Remove(KeyValuePair<TKey, TValue> item)
|
||||
return result;
|
||||
}
|
||||
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() => ((IDictionary<TKey, TValue>)objects).GetEnumerator();
|
||||
public IEnumerator<KeyValuePair<TKey, TValue>> GetEnumerator() => objects.GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => objects.GetEnumerator();
|
||||
}
|
||||
|
||||
public abstract class SyncDictionary<TKey, TValue>: SyncIDictionary<TKey, TValue>
|
||||
{
|
||||
protected SyncDictionary() : base(new Dictionary<TKey, TValue>())
|
||||
{
|
||||
}
|
||||
|
||||
protected SyncDictionary(IEqualityComparer<TKey> eq) : base(new Dictionary<TKey,TValue>(eq))
|
||||
{
|
||||
}
|
||||
|
||||
public new Dictionary<TKey, TValue>.ValueCollection Values => ((Dictionary<TKey,TValue>)objects).Values;
|
||||
|
||||
public new Dictionary<TKey, TValue>.KeyCollection Keys => ((Dictionary<TKey,TValue>)objects).Keys;
|
||||
|
||||
public new Dictionary<TKey, TValue>.Enumerator GetEnumerator() => ((Dictionary<TKey, TValue>)objects).GetEnumerator();
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => ((IDictionary<TKey, TValue>)objects).GetEnumerator();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user